描述:
nvs_get_blob(nvshandle,“nvconfig0”, phone_set_val.firststart,&phone_set_val_len);
“nvconfig0"键名直接字符串没有问题,但是采用数组
nvconfig[12]={0};
memset(nvconfig,0,sizeof(nvconfig));
sprintf(nvconfig,”%s%d",“nvconfig”,0);
无法读出键值
static esp_err_t nvs_get_str_or_blob(nvs_handle_t c_handle, nvs::ItemType type, const char* key, void* out_value, size_t* length)
{
Lock lock;
ESP_LOGD(TAG, “%s %s”, func, key);
NVSHandleSimple *handle;
auto err = nvs_find_ns_handle(c_handle, &handle);
if (err != ESP_OK) {
return err;
}
size_t dataSize;
err = handle->get_item_size(type, key, dataSize);
if (err != ESP_OK) {
return err;
}
if (length == nullptr) {
return ESP_ERR_NVS_INVALID_LENGTH;
} else if (out_value == nullptr) {
*length = dataSize;
return ESP_OK;
} else if (*length < dataSize) {
*length = dataSize;
return ESP_ERR_NVS_INVALID_LENGTH;
}
//原
*length = dataSize;
测试打印
for(int i=0;i<12;i++)
printf(“%x,”,key[i]);
ESP_LOGI(TAG, “\n”);
//原
return handle->get_typed_item(type, key, out_value, dataSize);
改
// err =handle->get_typed_item(type, key, out_value, dataSize);
// *length = dataSize;
// return err;
}
原代码错误输出
乐鑫ESP32 NVS读错误BUG:nvs_get_blob
最新推荐文章于 2024-06-26 20:37:46 发布