espressif / esp-rainmaker

ESP RainMaker Agent for firmware development
Apache License 2.0
431 stars 145 forks source link

Time Series PUT from a custom mobile app and from a node local storage log (MEGH-4900) #280

Open farmersfish opened 10 months ago

farmersfish commented 10 months ago

Answers checklist.

General issue report

Hi Team,

There is a case when the node doesn't have an Internet connection, and we need to save the data log (time series) to local storage, in this case, sdcard. I want to find a way to sync data from the node to the RainMaker whenever it gets the Internet connection. Is that possible?

Can I also PUT the same data log from the custom mobile phone app to the RainMaker backend? It happens when the mobile phone and the node don't have an Internet connection when they exchange data.

shahpiyushv commented 10 months ago

There is a case when the node doesn't have an Internet connection, and we need to save the data log (time series) to local storage, in this case, sdcard. I want to find a way to sync data from the node to the RainMaker whenever it gets the Internet connection. Is that possible?

The SDK itself does not support backing up data in case of No internet connectivity and then trying when Internet is back. However, since we use QOS1, it improves reliability in case of flaky connection. Additionally, you can monitor the RMAKER_MQTT_EVENT_PUBLISHED event to get assurance that MQTT publish has succeeded. Additionally, you can make use of RMAKER_MQTT_EVENT_CONNECTED and RMAKER_MQTT_EVENT_DISCONNECTED events in your application code to decide whether to store the data somewhere (if disconnected) or send right away. Handling of events can be found in the switch example.

Can I also PUT the same data log from the custom mobile phone app to the RainMaker backend? It happens when the mobile phone and the node don't have an Internet connection when they exchange data.

We do not support this. Each device has its unique id and mutually authenticated session with the cloud backend. Only the device can report its data and no other entity can report it in behalf of the device.

farmersfish commented 10 months ago

There is a case when the node doesn't have an Internet connection, and we need to save the data log (time series) to local storage, in this case, sdcard. I want to find a way to sync data from the node to the RainMaker whenever it gets the Internet connection. Is that possible?

The SDK itself does not support backing up data in case of No internet connectivity and then trying when Internet is back. However, since we use QOS1, it improves reliability in case of flaky connection. Additionally, you can monitor the RMAKER_MQTT_EVENT_PUBLISHED event to get assurance that MQTT publish has succeeded. Additionally, you can make use of RMAKER_MQTT_EVENT_CONNECTED and RMAKER_MQTT_EVENT_DISCONNECTED events in your application code to decide whether to store the data somewhere (if disconnected) or send right away. Handling of events can be found in the switch example.

Can I also PUT the same data log from the custom mobile phone app to the RainMaker backend? It happens when the mobile phone and the node don't have an Internet connection when they exchange data.

We do not support this. Each device has its unique id and mutually authenticated session with the cloud backend. Only the device can report its data and no other entity can report it in behalf of the device.

Thanks for a great explanation!

farmersfish commented 10 months ago

There is a case when the node doesn't have an Internet connection, and we need to save the data log (time series) to local storage, in this case, sdcard. I want to find a way to sync data from the node to the RainMaker whenever it gets the Internet connection. Is that possible?

The SDK itself does not support backing up data in case of No internet connectivity and then trying when Internet is back. However, since we use QOS1, it improves reliability in case of flaky connection. Additionally, you can monitor the RMAKER_MQTT_EVENT_PUBLISHED event to get assurance that MQTT publish has succeeded. Additionally, you can make use of RMAKER_MQTT_EVENT_CONNECTED and RMAKER_MQTT_EVENT_DISCONNECTED events in your application code to decide whether to store the data somewhere (if disconnected) or send right away. Handling of events can be found in the switch example.

Can I also PUT the same data log from the custom mobile phone app to the RainMaker backend? It happens when the mobile phone and the node don't have an Internet connection when they exchange data.

We do not support this. Each device has its unique id and mutually authenticated session with the cloud backend. Only the device can report its data and no other entity can report it in behalf of the device.

One more question, just in case the node wasn't able to update and report a param due to Internet connectivity lost, can the node update the param later with a specific timestamp in the past? esp_rmaker_param_update_and_report function seems not take the node's timestamp as a variable. Seems as a struct esp_rmaker_param struct esp_rmaker_param { char *name; char *type; uint8_t flags; uint8_t prop_flags; char *ui_type; esp_rmaker_param_val_t val; esp_rmaker_param_bounds_t *bounds; esp_rmaker_param_valid_str_list_t *valid_str_list; struct esp_rmaker_device *parent; struct esp_rmaker_param * next; };