Best approach to control devices


I would like to share my scenario with you, i am willing to connect more than one android device to remote gateway through exosite cloud to control devices connected over zigbee with the gateway.
these devices which are connected over zigbee with the gateway are various such as sensors and lighting devices, so they are controlled by the gateway using command protocol developed by me, now my idea to control these devices using the android devices connected to the cloud is to create a device which represent the gateway and add data to it which are 2 variables command and command_state and send the command to and from the gateway and android devices by passing the command to these variables.
The problem is that how to send a command from gateway to the all the controlling android devices and make sure that they all will receive the reading for examples, or if 2 devices for example read and write at the same time from the device what would be the case.

What would be the best approach if not using these 2 variables to control the devices??


Generally, we suggest having only one writer to any dataport to prevent the contention that you mention from having two different devices. If you need to have two different devices writing to a single dataport, I’d suggest adding some sort of unique identifier to each command so that you can match up commands and responses and have the android device retry in the case that there was con conflict.