Skip to content

Commit

Permalink
Merge branch 'bugfix/bulk_cb' into 'master'
Browse files Browse the repository at this point in the history
bugfix: Application registered callback was getting skipped for persistent params

See merge request app-frameworks/esp-rainmaker!499
  • Loading branch information
shahpiyushv committed Dec 30, 2024
2 parents 7d50642 + 4ee7cc2 commit e5c4b8e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions components/esp_rainmaker/src/core/esp_rmaker_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,19 @@ esp_err_t esp_rmaker_device_add_param(const esp_rmaker_device_t *device, const e
/* The device callback should be invoked once with the stored value, so
* that applications can do initialisations as required.
*/
if (_device->write_cb) {
if (_device->bulk_write_cb) {
/* However, the callback should be invoked, only if the parameter is not
* of type ESP_RMAKER_PARAM_NAME, as it has special handling internally.
*/
if (!(_new_param->type && strcmp(_new_param->type, ESP_RMAKER_PARAM_NAME) == 0)) {
esp_rmaker_write_ctx_t ctx = {
.src = ESP_RMAKER_REQ_SRC_INIT,
};
_device->write_cb(device, param, stored_val, _device->priv_data, &ctx);
esp_rmaker_param_write_req_t write_req = {
.param = (esp_rmaker_param_t *)param,
.val = stored_val,
};
_device->bulk_write_cb(device, &write_req, 1, _device->priv_data, &ctx);
}
}
} else {
Expand Down

0 comments on commit e5c4b8e

Please sign in to comment.