Enhance NVS module with a dedicated background task
- Implemented a dedicated background task to decouple long-running code from the main application task. - Improved the NVS commit code logic, especially for batch writes to minimize flash wear. - Updated NVS functions to support asynchronous writes and synchronous reads. - Added default value parameters to `get` functions for better usability. - Improved error handling and logging in NVS operations. - Refactored related code in multiple source files to accommodate these changes. Refs #1085, #1096 and closes #1098
This commit is contained in:
@@ -38,10 +38,8 @@ esp_err_t relay_chn_ctl_init(relay_chn_output_t *outputs, relay_chn_run_info_t *
|
||||
uint16_t run_limit_sec = CONFIG_RELAY_CHN_RUN_LIMIT_DEFAULT_SEC;
|
||||
#if CONFIG_RELAY_CHN_ENABLE_NVS
|
||||
// Load run limit value from NVS
|
||||
ret = relay_chn_nvs_get_run_limit(chn_ctl->id, &run_limit_sec);
|
||||
if (ret != ESP_OK && ret != ESP_ERR_NVS_NOT_FOUND) {
|
||||
ESP_LOGE(TAG, "Failed to load run limit from NVS for channel %d with error: %s", i, esp_err_to_name(ret));
|
||||
}
|
||||
ret = relay_chn_nvs_get_run_limit(chn_ctl->id, &run_limit_sec, CONFIG_RELAY_CHN_RUN_LIMIT_DEFAULT_SEC);
|
||||
ESP_RETURN_ON_ERROR(ret, TAG, "Failed to load run limit from NVS for #%d with error: %s", i, esp_err_to_name(ret));
|
||||
#endif
|
||||
chn_ctl->run_limit_sec = run_limit_sec;
|
||||
ret = relay_chn_init_run_limit_timer(chn_ctl);
|
||||
|
||||
Reference in New Issue
Block a user