Program Listing for File Storage.h

Return to documentation for file (components/NVS/src/Storage.h)

#ifndef NVS_H
#define NVS_H

#include <esp_err.h>
#include <nvs_flash.h>
#include <string>

namespace storage
{
    esp_err_t init();

    class NVS
    {
    public:
        NVS();

        ~NVS();

        esp_err_t open(const char* name, nvs_open_mode open_mode);

        void close();

        esp_err_t set_bool(const char* key, bool value);

        esp_err_t get_bool(const char* key, bool& value);

        esp_err_t getIsConfigured(bool& is_configured);

        esp_err_t setString(std::string key, std::string data);

        esp_err_t getString(std::string key, char* buffer, size_t* length);

        esp_err_t commit();


    private:
        bool m_is_opened;
        nvs_handle m_handle;
    };

} // namespace storage

#endif //