Preference fetchString not working..... user error?
Posted: Wed Jul 12, 2017 10:49 am
I've got some issues with the Preferences library for Arduino.
The following snippet is responsible for storing a variable to EEPROM:
This outputs '16', which is correct given the input I give it.
When i try to fetch the before stored variable using this code:
This outputs '0' and ''
I can't seem to understand what's happening. Both methods receive the same key:
Is this user error of is there something else going on?
The following snippet is responsible for storing a variable to EEPROM:
Code: Select all
int DeviceSettings::storeString(const char* key, const char* value){
preferences.begin(name_space, false);
Serial.println(preferences.putString(key, value), DEC);
preferences.end();
}
When i try to fetch the before stored variable using this code:
Code: Select all
void DeviceSettings::fetchString(const char* key, char* value){
preferences.begin(name_space, false);
Serial.println(preferences.getString(key, value, 200), DEC);
Serial.println(value);
preferences.end();
}
I can't seem to understand what's happening. Both methods receive the same key:
Code: Select all
settings.storeString(SETTINGS_APP_NAME,"Chris van Diemen");
char * s;
settings.fetchString(SETTINGS_APP_NAME, s);