How to persistently store a parameter configuration so that it can be restored after a power loss

liuchuan1
Posts: 1
Joined: Sat Mar 21, 2026 1:28 am

How to persistently store a parameter configuration so that it can be restored after a power loss

Postby liuchuan1 » Sat Mar 21, 2026 1:37 am

How to persistently store a parameter configuration so that it can be restored after a power loss。
Add PROP_FLAG_PERSIST when esp_rmaker_param_create ?
If a param is PROP_FLAG_PERSIST,it will be stored in NVS when it updates?
However, it seems to be ineffective. After I made the modification, the default values were restored after power loss.

Code: Select all

    param = esp_rmaker_param_create(CUSTOM_PARAM_REPORT_PERIOD, CUSTOM_PARAM_REPORT_PERIOD_TYPE,
                                    esp_rmaker_int(REPORT_PERIOD_DEFAULT), PROP_FLAG_READ | PROP_FLAG_WRITE | PROP_FLAG_PERSIST);
    if (param)
    {
        esp_rmaker_param_add_ui_type(param, ESP_RMAKER_UI_SLIDER);
        esp_rmaker_param_add_bounds(param, esp_rmaker_int(REPORT_PERIOD_MIN), esp_rmaker_int(REPORT_PERIOD_MAX), esp_rmaker_int(1));
        esp_rmaker_device_add_param(temp_sensor_device, param);
        esp_rmaker_device_add_cb(temp_sensor_device, report_period_write_cb, NULL);
    }

Piyush
Espressif staff
Espressif staff
Posts: 372
Joined: Wed Feb 20, 2019 7:02 am

Re: How to persistently store a parameter configuration so that it can be restored after a power loss

Postby Piyush » Mon Mar 23, 2026 4:02 am

For persistent parameters, the device callback gets invoked with ESP_RMAKER_REQ_SRC_INIT as the source and your application can decide what to do with it and then call esp_rmaker_param_update_and_report(). However, for that to work, your callback needs to be registered before adding the parameter. Swapping the order of function calls would be sufficient

Code: Select all

        esp_rmaker_device_add_cb(temp_sensor_device, report_period_write_cb, NULL);
        esp_rmaker_device_add_param(temp_sensor_device, param);

Who is online

Users browsing this forum: No registered users and 1 guest