I'm trying to store a byte array in non volatile memory, but I'm always getting the ESP_ERR_NVS_VALUE_TOO_LONG error... Here is the code:
Code: Select all
typedef struct {
uint8_t month;
uint8_t year;
} prodDate;
prodDate productionDate;
Code: Select all
productionDate.month = spp_data[5];
productionDate.year = spp_data[6];
err = nvs_open(STORAGE_NAMESPACE, NVS_READWRITE, &my_handle);
if(err != ESP_OK){
ESP_LOGI(SPP_TAG, "something went wrong 1");
}
nvsSize1 = sizeof(productionDate);
ESP_LOGI(SPP_TAG, "nvssize = %d",nvsSize1);
err = nvs_set_blob(my_handle, "prod_date", &productionDate, &nvsSize1);
if(err != ESP_OK){
ESP_LOGI(SPP_TAG, "something went wrong 2");
ESP_LOGI(SPP_TAG, "%s",esp_err_to_name(err));
if(err == ESP_ERR_NVS_INVALID_HANDLE)
ESP_LOGI(SPP_TAG, "invalid handle");
if(err == ESP_ERR_NVS_READ_ONLY)
ESP_LOGI(SPP_TAG, "read only");
if(err == ESP_ERR_NVS_INVALID_NAME)
ESP_LOGI(SPP_TAG, "invalid name");
if(err == ESP_ERR_NVS_NOT_ENOUGH_SPACE)
ESP_LOGI(SPP_TAG, "not enough space");
if(err == ESP_ERR_NVS_REMOVE_FAILED)
ESP_LOGI(SPP_TAG, "remove failed");
if(err == ESP_ERR_NVS_VALUE_TOO_LONG)
ESP_LOGI(SPP_TAG, "value too long");
}
err = nvs_commit(my_handle);
if(err != ESP_OK){
ESP_LOGI(SPP_TAG, "something went wrong 3");
}
nvs_close(my_handle);