Skip to content

Commit cef427b

Browse files
committed
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
2 parents 27becc6 + d229e35 commit cef427b

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

components/esp_rainmaker/include/esp_rmaker_core.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,30 @@ esp_err_t esp_rmaker_param_add_valid_str_list(const esp_rmaker_param_t *param, c
731731
*/
732732
esp_err_t esp_rmaker_param_add_array_max_count(const esp_rmaker_param_t *param, int count);
733733

734+
735+
/* Update a parameter
736+
*
737+
* This will just update the value of a parameter with esp rainmaker core, without actually reporting
738+
* it. This can be used when multiple parameters need to be reported together.
739+
* Eg. If x parameters are to be reported, this API can be used for the first x -1 parameters
740+
* and the last one can be updated using esp_rmaker_param_update_and_report().
741+
* This will report all parameters which were updated prior to this call.
742+
*
743+
* Sample:
744+
*
745+
* esp_rmaker_param_update(param1, esp_rmaker_float(10.2));
746+
* esp_rmaker_param_update(param2, esp_rmaker_int(55));
747+
* esp_rmaker_param_update(param3, esp_rmaker_int(95));
748+
* esp_rmaker_param_update_and_report(param1, esp_rmaker_bool(true));
749+
*
750+
* @param[in] param Parameter handle.
751+
* @param[in] val New value of the parameter.
752+
*
753+
* @return ESP_OK if the parameter was updated successfully.
754+
* @return error in case of failure.
755+
*/
756+
esp_err_t esp_rmaker_param_update(const esp_rmaker_param_t *param, esp_rmaker_param_val_t val);
757+
734758
/** Update and report a parameter
735759
*
736760
* Calling this API will update the parameter and report it to ESP RainMaker cloud.

components/esp_rainmaker/src/core/esp_rmaker_param.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -701,6 +701,7 @@ esp_err_t esp_rmaker_param_update(const esp_rmaker_param_t *param, esp_rmaker_pa
701701
default:
702702
return ESP_ERR_INVALID_ARG;
703703
}
704+
_param->flags |= RMAKER_PARAM_FLAG_VALUE_CHANGE;
704705
if (_param->prop_flags & PROP_FLAG_PERSIST) {
705706
esp_rmaker_param_store_value(_param);
706707
}
@@ -713,7 +714,6 @@ esp_err_t esp_rmaker_param_report(const esp_rmaker_param_t *param)
713714
ESP_LOGE(TAG, "Param handle cannot be NULL.");
714715
return ESP_ERR_INVALID_ARG;
715716
}
716-
((_esp_rmaker_param_t *)param)->flags |= RMAKER_PARAM_FLAG_VALUE_CHANGE;
717717
return esp_rmaker_report_param_internal(RMAKER_PARAM_FLAG_VALUE_CHANGE);
718718
}
719719

0 commit comments

Comments
 (0)