Today IoT (Internet of Things) world has a great advantage of distributed system. Your wireless lamp driven by your cell phone can be connected directly to phone, or to local router or to internet. The data between cell and lamp can go many ways.
The control logic of devices can be executed at many places like in device itself, on gateway, in cloud or in customer device. Anyway the good practice is to host and execute it on the right place. For example software routine ensuring emergency turn on of light should be done in light firmware and not in cloud or user device. You can do it there, but please take into account what happens when internet connectivity is down or big latency between cloud and end device slows down your work.
Do control logic on right place.
End device control
End device must work even when the cloud or internet are down. they have to work even when local gateway or radio wireless is down. Therefore in every end device (lamp, heater, production machine, robot, etc..) is local firmware ensuring device control logic.
If your devices does not have any firmware e.g. it’s an easy ON/OF device, there is a great chance to keep this logic in wireless transceivers. E.g. IQRF transceivers include control chip where you can put your logic on behalf of your device e.g. when central gateway does not respond, then turn light off.
Gateway controls all connected devices therefore it can execute a little bit higher level of logic with devices. Typical gateway controls lights in specific zones based on received input from a sensor of movement.
This control logic is independent of any higher level of control. When gateway is disconnected from cloud services it still perfectly performs control logic.
More about gateways you can get here: http://logimic.org/what-is-a-gateway-role/
Cloud has connected many gateways and much more end devices via each gateway. This means that cloud can perform high level tasks with all these devices and besides that stores data and performs big data computing and analytics.
Typical cloud operation is oversight of gateway online status, or oversight and distribution of end devices alerts – when something goes wrong, you as an end user can receive SMS, e-mail or voice call.
One of the big advantage of cloud is the reliability so you can store here data, make big computing and more..
End phones and computers usually serve as user interface. They transform user clicks, key pushes, gestures, voice and more to commands sent via API (Application Interface) to cloud or gateways.
We usually recognize dashboards – mostly providing visual information without other user interaction, then control application enabling full control with user and finally special interfaces like virtual reality and more.
Control logic is mostly distributed through end devices, gateways, cloud and user devices. The way of distribution must always be considered with respect to application and its hardware and software architecture.