Merge branch 'task/multi_param_update' into 'master'

esp_rmaker_core: Expose esp_rmaker_param_update() API to assist in multi param updates

See merge request app-frameworks/esp-rainmaker!284
This commit is contained in:
Piyush Shah
2022-02-21 13:14:36 +00:00
2 changed files with 25 additions and 1 deletions

View File

@@ -731,6 +731,30 @@ esp_err_t esp_rmaker_param_add_valid_str_list(const esp_rmaker_param_t *param, c
*/
esp_err_t esp_rmaker_param_add_array_max_count(const esp_rmaker_param_t *param, int count);
/* Update a parameter
*
* This will just update the value of a parameter with esp rainmaker core, without actually reporting
* it. This can be used when multiple parameters need to be reported together.
* Eg. If x parameters are to be reported, this API can be used for the first x -1 parameters
* and the last one can be updated using esp_rmaker_param_update_and_report().
* This will report all parameters which were updated prior to this call.
*
* Sample:
*
* esp_rmaker_param_update(param1, esp_rmaker_float(10.2));
* esp_rmaker_param_update(param2, esp_rmaker_int(55));
* esp_rmaker_param_update(param3, esp_rmaker_int(95));
* esp_rmaker_param_update_and_report(param1, esp_rmaker_bool(true));
*
* @param[in] param Parameter handle.
* @param[in] val New value of the parameter.
*
* @return ESP_OK if the parameter was updated successfully.
* @return error in case of failure.
*/
esp_err_t esp_rmaker_param_update(const esp_rmaker_param_t *param, esp_rmaker_param_val_t val);
/** Update and report a parameter
*
* Calling this API will update the parameter and report it to ESP RainMaker cloud.

View File

@@ -701,6 +701,7 @@ esp_err_t esp_rmaker_param_update(const esp_rmaker_param_t *param, esp_rmaker_pa
default:
return ESP_ERR_INVALID_ARG;
}
_param->flags |= RMAKER_PARAM_FLAG_VALUE_CHANGE;
if (_param->prop_flags & PROP_FLAG_PERSIST) {
esp_rmaker_param_store_value(_param);
}
@@ -713,7 +714,6 @@ esp_err_t esp_rmaker_param_report(const esp_rmaker_param_t *param)
ESP_LOGE(TAG, "Param handle cannot be NULL.");
return ESP_ERR_INVALID_ARG;
}
((_esp_rmaker_param_t *)param)->flags |= RMAKER_PARAM_FLAG_VALUE_CHANGE;
return esp_rmaker_report_param_internal(RMAKER_PARAM_FLAG_VALUE_CHANGE);
}