

Due to a large number of connected devices and their ability to control critical physical assets, intended attacks on them and/or unintended failure events such as mechanical failure of devices, communication failure and unforeseen bad interactions between connected devices may cause an IoT-based system to enter into unsafe and dangerous physical states. Safety and security are two such challenges that can hamper the widespread adoption of new IoT applications. While such systems have changed the way of our life, they brought new challenges that can adversely affect our life and the environment. The exponential growth of the Internet of Things (IoT) has paved the way for safety-critical cyber-physical systems to enter our everyday activities. The Web-App was developed using PHP, with Apache HTTP Server 2.4.29 which is an open-source cross platform Web Server. We use SamSung SmartThings Hub Version 2 with Motion Sensor and two Sengled Smart Connected LED Bulbs. The collected data is stored in a local (home) database that is implemented as a MySQL database.

The Web-App runs on localhost that simulates the RES-Hub and makes calls to the SmartApp endpoint in the SmartThings Cloud for specific request such as get device status, etc. The Web Server is implemented on a Raspberry PI.hub that simulates the RES-Hub. The Web Services SmartApp is developed in the SmartThings IDE user account and exposes the API endpoints that allow the Web-App to control a device, the device needs to register and pair with this SmartApp. We implemented a Web Services SmartApp, Web Server and Web-App to synchronize resource state, which is depicted in figure 4. Resource state synchronization and Notification modules.
SMARTTHINGS DEVICE HANDLER SEND MESSAGE TO CALLING SMARTAPP SOFTWARE
We describe an IoTivity-based software architecture that is used to implement RES-Hub in a flexible and expendable way and discuss our implementation. During the normal functioning of the system, RES-Hub will receive regular status updates from cloud, and will use this information to continue to provide the user specified services when it detects the cloud is down. We discuss possible effects of such unavailability on the functionalities that are commonly available in smart homes, including security and safety related services as well as support for health and well-being of home users, and propose RES-Hub, a hub that can provide the required functionalities when the cloud is unavailable. We ask the following question: what if the cloud is not available? This can happen not only by accident or natural causes, but also due to targeted attacks. The role of the hub in this setup is effectively message passing between the devices and the cloud, while the required analytics, computation, and control are all performed by the cloud. Cloud runs various applications and analytics on the collected data, and generates commands according to the users' specifications that are sent to the actuators to control the environment. Today's Smart Home platforms such as Samsung SmartThings and Amazon AWS IoT are primarily cloud based: devices in the home sense the environment and send the collected data, directly or through a hub, to the cloud.
