Resilient Distributed Constraint Reasoning to Autonomously Configure and Adapt IoT Environments