I just bought the development kit from Digi that contains: ConnectPort X4 gateway, L/T sensor and Smart Plug.
My previous experience with xbees was the creation of a C# library to communicate with xbee nodes (Remote/ Queued/ Regular AT Commands, Send/ Receive Serial Data ). The communication was asynchronous (when a xbee sends a packet then i fired a new event).
I am not experienced with python. Is there any way to receive asynchronous without the IS command call?
The current version of my script calls function from DigiXBeeDrivers.zip library. Every time I call the sensor.sample() then the code blocks until the sensor’s response. The Smart Plug replies immediately but the L/T Sensor (uses sleep mode) replies when it wakes up. Thus, if i set the L/T Sensor to sleep for 1 min, i have to wait (in worst case) 1 min to retrieve data from Smart Plug.
My first thought was to use a different thread for each sensor. As I realized there is not enough memory in ConnectPort X4 gateway to afford the extra threads (is this right?).
Another thought was to keep a timer variable for each sensor and to call the sensor.sample() every time the sleep time expires (-1 sec). But i thing this is not a good idea (synchronization problems + difficulties with extra sensors).
Which is the best programmatic pattern for this case?