|
@ -10,14 +10,13 @@ using namespace std; |
|
|
#define TAG "ZNVS"
|
|
|
#define TAG "ZNVS"
|
|
|
#define MARK_S 0x12345678
|
|
|
#define MARK_S 0x12345678
|
|
|
#define MARK_E 0x87654321
|
|
|
#define MARK_E 0x87654321
|
|
|
#ifdef IFLYTOP_NVS_CONFIG_FLASH_SECTOR
|
|
|
|
|
|
|
|
|
|
|
|
ZNVS& ZNVS::ins() { |
|
|
ZNVS& ZNVS::ins() { |
|
|
static ZNVS s_ins; |
|
|
static ZNVS s_ins; |
|
|
return s_ins; |
|
|
return s_ins; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void ZNVS::initialize() { zsimple_flash_init(IFLYTOP_NVS_CONFIG_FLASH_SECTOR); } |
|
|
|
|
|
|
|
|
void ZNVS::initialize(int32_t flash_sector) { zsimple_flash_init(flash_sector); } |
|
|
bool ZNVS::alloc_config(const char* key, uint8_t* data, size_t datalen) { |
|
|
bool ZNVS::alloc_config(const char* key, uint8_t* data, size_t datalen) { |
|
|
ZASSERT(m_index_num < ZARRAY_SIZE(m_index)); |
|
|
ZASSERT(m_index_num < ZARRAY_SIZE(m_index)); |
|
|
m_index[m_index_num].name = key; |
|
|
m_index[m_index_num].name = key; |
|
@ -83,5 +82,8 @@ bool ZNVS::set_config(const char* key, uint8_t* data, size_t len) { |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return false; |
|
|
} |
|
|
} |
|
|
void ZNVS::flush() { zsimple_flash_write((uint8_t*)m_cfgcache, m_cfgcachesize); } |
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
void ZNVS::flush() { |
|
|
|
|
|
ZLOGI(TAG, "flush config to flash"); |
|
|
|
|
|
zsimple_flash_write((uint8_t*)m_cfgcache, m_cfgcachesize); |
|
|
|
|
|
ZLOGI(TAG, "flush config to flash done"); |
|
|
|
|
|
} |