ubidots / ubidots-mqtt-esp

MIT License
40 stars 23 forks source link

request subscription update #4

Closed universam1 closed 7 years ago

universam1 commented 7 years ago

Don't know how close this is related to this library, but in practical use it turns out to be a design issue if I cant request an update of the subscription on bootup.

Given that my IoT device might reboot or sleep I found no way to request or trigger an update of the subscribed topic. Also, if the device might have been disconnected how can I retrieve the latest value?

Thanks

jotathebest commented 7 years ago

You may implement at your boot routine this:

client.subscribe(); while(!client.subscribe()){ client.subscribe() delay(5000); //trying to subscribe every 5 minutes }

Regards

universam1 commented 7 years ago

Maybe I was unclear. When I'm subscribed, my callback will fire with a change of that subscribed value when it happens. Now, when my device is offline, it will not get this update. When it comes up again, how can I get this last value?

jotathebest commented 7 years ago

If you wan to get the last value of your variable you should use HTTP GET method instead a MQTT subscribe.

For getting the last value with MQTT we need to implement the MQTT retained last value feature, actually Ubidots doesn't support this, we hope to implement it in the next months.

Regards.