Skip to content

Commit e385522

Browse files
committed
esp_param_name: Give an option to handle name param in application callback
1 parent d4d2795 commit e385522

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Diff for: components/esp_rainmaker/Kconfig.projbuild

+8
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ menu "ESP RainMaker Config"
7979
can take appropriate action w.r.t user permissions. It is recommended to enable this option
8080
for security reasons.
8181

82+
config RMAKER_NAME_PARAM_CB
83+
bool "Call device callback for Name param"
84+
default n
85+
help
86+
By default, the "Name" parameter (esp.param.name) changes are handled internally. If Applications
87+
want to handle this themselves, this config option can be enabled. Please ensure that you update
88+
and report the name parameter in your callback so that it reflects correctly everywhere.
89+
If no device callback is registered, the name paramater will be handled internally.
8290

8391
config ESP_RMAKER_LOCAL_CTRL_ENABLE
8492
bool "ESP RainMaker Local Control"

Diff for: components/esp_rainmaker/src/core/esp_rmaker_param.c

+12
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,19 @@ static esp_err_t esp_rmaker_device_set_params(_esp_rmaker_device_t *device, jpar
357357
* of calling the registered callback.
358358
*/
359359
if (param->type && (strcmp(param->type, ESP_RMAKER_PARAM_NAME) == 0)) {
360+
#ifdef CONFIG_RMAKER_NAME_PARAM_CB
361+
if (device->write_cb) {
362+
esp_rmaker_write_ctx_t ctx = {
363+
.src = src,
364+
};
365+
device->write_cb((esp_rmaker_device_t *)device, (esp_rmaker_param_t *)param,
366+
new_val, device->priv_data, &ctx);
367+
} else {
368+
esp_rmaker_param_update_and_report((esp_rmaker_param_t *)param, new_val);
369+
}
370+
#else
360371
esp_rmaker_param_update_and_report((esp_rmaker_param_t *)param, new_val);
372+
#endif
361373
} else if (device->write_cb) {
362374
esp_rmaker_write_ctx_t ctx = {
363375
.src = src,

0 commit comments

Comments
 (0)