espressif / esp-homekit-sdk

541 stars 98 forks source link

Lightbulb: save status on flash #133

Closed leotordo closed 1 month ago

leotordo commented 2 months ago

Hello, is it possible to save status of led (on/off and % of pwm) in flash memory. I want to recover it every time I restart the board. Thanks Stefano

shahpiyushv commented 2 months ago

The SDK itself does not inherently support this, but you can store the values using NVS APIs whenever your write callback is invoked or the value changes by some other means and then, on a reboot, restore it from NVS and pass it to the API which creates the characteristics.

leotordo commented 2 months ago

hello. I found this example https://github.com/espressif/esp-idf/blob/v5.2.1/examples/storage/nvs_rw_value/main/nvs_value_example_main.c may I write simple code where I want to save vaues? I need to save Status (on/off) and Level (PWM) May be useful this example? Thanks Stefano

leotordo commented 1 month ago

I confirm that example above solves my request. Bye Stefano