1

I can see how a datastream/channel can be used to send commands to a device (e.g. an actuator). The device can periodically poll the channel for incoming commands, but if the device has no storage of its own how can it tell which commands it has already received/processed?

RobM
  • 49
  • 6

1 Answers1

0

This all depends on your implementation and hardware choices. And the real answer to this question lays far beyond the scope of Xively. You say that the device has no storage of its own, but I assume it has some kind of volatile memory at the very least.

The best thing to do would be to store the timestamp of the last datapoint that was received and compare it to whatever current data you have. If the timestamp is greater than the one in memory then you know it is new data.

An alternative to HTTP polling would be to use a socket with some kind of publish/subscribe interface that will allow you to received only new data from the server. Xively offers this on it's TCP, WebSockets, and MQTT socket servers.

calumb
  • 1,051
  • 2
  • 10
  • 24
  • Hi calumb, thank you for your answer. Yes the device has volatile storage, but when it starts up and requests any pending messages it can't tell which ones it has previously received and processed. I've taken a look at the TCP/subscribe option and that's definitely interesting, but has the same problem I think. Perhaps the answer is for the device to delete the Datapoint from the Datastream after it has read it? – RobM Jan 06 '14 at 09:48
  • RobM, yes, this is one approach but then you have no long term storage of the data. One thing to look into would be the MQTT QoS levels which can ensure delivery once and only once. This may be helpful. Another thing you could do is create a separate datastream (channel) and send the last processed timestamp to it, then when you do your HTTP GET, you can do a feed get, get both values and compare the timestamp this way. That way you do not need to rely on volatile memory. Hope this helps! – calumb Jan 06 '14 at 16:01