The problem is that although I can save it properly ( the print reads the exact string it should ) it can not load it, and gives me a blank space
Here is the saving code:
Code: Select all
printf("wOS: Saving collected data into NVS...\n");
const char* data = GetDataCollected();
printf("%s\n", data ); //Prints the correct value
err = nvs_set_str(storage_device, "DataCollected", data );
printf((err != ESP_OK) ? "wOS: Failed to save Collected Data\n" : "wOS: Successfully saved Collected Data!\n");
Code: Select all
size_t required_size;
err = nvs_get_str(storage_device, "DataCollected", NULL, &required_size );
switch (err) {
case ESP_OK:
printf("wOS: Successfully grabbed size, loading in value..\n");
char* SavedData = malloc(required_size);
err = nvs_get_str( storage_device, "DataCollected", &SavedData, &required_size );
printf( "Downloaded Data: %s\n", SavedData );
ApplyLoadedData( &SavedData );
int timr = 0;
nvs_get_i32( storage_device, "CurrentTime", &timr );
printf( "Timer: %d", timr );
SetTimeKeeper( timr );
printf("wOS: Successfully loaded data!\n");
break;
case ESP_ERR_NVS_NOT_FOUND:
printf("wOS: There is no saved data on file.\n");
break;
default :
printf("wOS: Error (%d) reading!\n", err);
} size_t required_size;
err = nvs_get_str(storage_device, "DataCollected", NULL, &required_size );
switch (err) {
case ESP_OK:
printf("wOS: Successfully grabbed size, loading in value..\n");
char* SavedData = malloc(required_size);
err = nvs_get_str( storage_device, "DataCollected", &SavedData, &required_size );
printf( "Downloaded Data: %s\n", SavedData ); //Prints completely blank
ApplyLoadedData( &SavedData );
int timr = 0;
nvs_get_i32( storage_device, "CurrentTime", &timr );
printf( "Timer: %d", timr );
SetTimeKeeper( timr );
printf("wOS: Successfully loaded data!\n");
break;
case ESP_ERR_NVS_NOT_FOUND:
printf("wOS: There is no saved data on file.\n");
break;
default :
printf("wOS: Error (%d) reading!\n", err);
}