Skip to content

Commit

Permalink
bugfix: Application registered callback was getting skipped for persi…
Browse files Browse the repository at this point in the history
…stent params

If the new bulk write callback is registered for a device/service instead of regular
callback, it was getting skipped for persistent params during initialisation.
  • Loading branch information
shahpiyushv committed Dec 24, 2024
1 parent 7d50642 commit 4ee7cc2
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 4ee7cc2

Please sign in to comment.