From 4ee7cc20e83ef7a9603a60afbaa7b862ab60d79a Mon Sep 17 00:00:00 2001 From: Piyush Shah Date: Mon, 23 Dec 2024 17:22:49 +0530 Subject: [PATCH] bugfix: Application registered callback was getting skipped for persistent 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. --- components/esp_rainmaker/src/core/esp_rmaker_device.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/components/esp_rainmaker/src/core/esp_rmaker_device.c b/components/esp_rainmaker/src/core/esp_rmaker_device.c index 169f9275..bbb19999 100644 --- a/components/esp_rainmaker/src/core/esp_rmaker_device.c +++ b/components/esp_rainmaker/src/core/esp_rmaker_device.c @@ -181,7 +181,7 @@ 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. */ @@ -189,7 +189,11 @@ esp_err_t esp_rmaker_device_add_param(const esp_rmaker_device_t *device, const e 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 {