espressif / esp-rainmaker

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

esp_rmaker_param_add_valid_str_list() - possible list update? (MEGH-4202) #226

Closed jacek12345 closed 1 year ago

jacek12345 commented 1 year ago

Is it possible to update valid string list after it was added? When is the list sended to server? I can't see it in monitor. Is it possible to place string list in RAM, not in FLASH?

sanketwadekar commented 1 year ago

Yes, it is possible. If you want to add/remove any devices and want the changes to get reflected in the phone app, then you need to call the esp_rmaker_report_node_details() API after you add/remove the device. To see the logs, you have to set the Log Output level to "Debug" from idf.py menuconfig.

jacek12345 commented 1 year ago

Thank You @sanketwadekar I know and use esp_rmaker_report_node_details() API. Generally, using esp_rmaker_param_add_valid_str_list(const esp_rmaker_param_t *param, const char *strs[], uint8_t count) and const char *valid_strs[] = {"row1", "row2"} for valid string list. So should implement *valid_strs[] in RAM rather than FLASH (ommit 'const') and can modify this list on the fly and use esp_rmaker_report_node_details() after modification, right? Next question is: Can I change 'count' parameter after esp_rmaker_param_add_valid_str_list() used? Or Can use esp_rmaker_param_add_valid_str_list() a few times for the same device parameter (or is there any API for re-create valid string list with count parameter modified?)?

sanketwadekar commented 1 year ago

If you are increasing/decreasing items in the list of valid strings, then you should also change your count parameter accordingly. You can call the esp_rmaker_param_add_valid_str_list API multiple times (with the updated list and count) for the same parameter.

jacek12345 commented 1 year ago

thank You @sanketwadekar that's exactly what I wanted to get

jacek12345 commented 1 year ago

You can call the esp_rmaker_param_add_valid_str_list API multiple times (with the updated list and count) for the same parameter.

I suggest adding this information to esp_rmaker_param_add_valid_str_list API description.

I succesfully implemented dynamic valid_str_list for parameter. Thank You.

jacek12345 commented 1 year ago

Can You confirm if calling esp_rmaker_param_update_and_report() will report parameter valid_str_list also (earlier updated), or have to call esp_rmaker_report_node_details() ?

shahpiyushv commented 1 year ago

Since valid_str_list is part of node config, you will have to call esp_rmaker_report_node_details() to update any changes related to it.

jacek12345 commented 1 year ago

Thank You @shahpiyushv Is it possible to add some API for valid_str_list report? We're using dynamic valid_str_lists and have to unnecessarily increase traffic on each valid_str_list update.

shahpiyushv commented 1 year ago

The backend actually just overwrites whatever config is sent by the node. Adding a facility to update smaller snippets would require changes in backend logic including support for new topics for this. We may not consider this in near future. Are the changes really that frequent to cause an impact on network traffic?

jacek12345 commented 1 year ago

Are the changes really that frequent to cause an impact on network traffic?

No, it is not raported very often. Usually while device configurating only. I though about AWS costs rather than network overload. sometimes x thousands_of_users = bigger_AWS_costs. But I understand, it doesn't make sense since it is not simple to add this API to backend and we can live with it.

shahpiyushv commented 1 year ago

@jacek12345 , AWS IoT messages are anyways metered in 5 KB increments. So, if your node config is less than 5KB, the optimisation of message size would not help. Moreover, ESP RainMaker now uses basic ingest topics and so, there is no messaging cost, but only processing cost.

jacek12345 commented 1 year ago

Thank You for clarification.