Preferences "begin" sometimes return false when trying to open a namespace
Posted: Wed Sep 20, 2023 3:03 am
Hi,
I'm trying using Preferences. I have the setup values in setup() like this:
And I have this in my loop():
Sometimes, I'm getting zero values for some or all keys. I have some task that access those too and asign to a variable and sometimes the variable is zero.
Searching for the possible cause I discovered that sometimes begin return a false value, according the Docs:
"true if the namespace was opened successfully; false otherwise."
So when doing a get when the namespace could not be opened I will get a value of zero.
But I would like to know why I sometimes I'm getting false as a result
Thanks
I'm trying using Preferences. I have the setup values in setup() like this:
Code: Select all
// Preferencias ParĂ¡metros
prefParam.begin("Param", false);
if (!prefParam.getUShort("VMax", 0))
prefParam.putUShort("VMax", 410);
if (!prefParam.getUShort("VMin", 0))
prefParam.putUShort("VMin", 370);
if(!prefParam.getUChar("PAMax", 0))
prefParam.putUChar("PAMax", 150);
if(!prefParam.getUShort("FMax", 0))
prefParam.putUShort("FMax", 520);
if(!prefParam.getUShort("FMin", 0))
prefParam.putUShort("FMin", 480);
prefParam.end();
Code: Select all
prefParam.begin("Param", true);
Serial.println (prefParam.getUShort("VMax"));
Serial.println (prefParam.getUShort("VMin"));
Serial.println (prefParam.getUShort("FMax"));
Serial.println (prefParam.getUShort("FMin"));
Serial.println (prefParam.getUChar("PAMax"));
prefParam.end();
vTaskDelay (1000);
Searching for the possible cause I discovered that sometimes begin return a false value, according the Docs:
"true if the namespace was opened successfully; false otherwise."
So when doing a get when the namespace could not be opened I will get a value of zero.
But I would like to know why I sometimes I'm getting false as a result
Thanks