Closed alexpopof closed 2 years ago
There should not be a minimum number of fields. Can you try deletePrefs()
before writePrefs()
after changing the struct?
Thanks for the quick response! I did try this, including garbage collection, by uncommenting that section of your code. For clarity, the code and output are below. Perhaps I am missing something obvious, but it definitely seems strange. run2.txt
You found a bug in the logic of the library. I will try to fix it ASAP.
I think I fixed it. Can you try the current library code? Just replace NanoBLEFlashPrefs.h
and NanoBLEFlashPrefs.cpp
in /Users/<you>/Documents/Arduino/libraries/NanoBLEFlashPrefs/src/
with the new files from the repository.
Also, remove all the waiting code
// Wait until completion
while (!myFlashPrefs.operationCompleted()) {
}
from your Arduino sketch. The functions are all synchronous now.
Please let me know if it works, I will then update the rest of the repository to reflect the changes.
Functionally, the fix seems good for the four-item struct and the single-item struct (i.e. only char someString[64];
).
Other minor comments you may be aware of already but figured I would mention:
writePrefs
still has some debugging code Serial.println(record.data.length_words);
In any case, thanks again for the quick response and fix. The synchronous change is a nice bonus too!
- I think your new sample .ino is missing the lines to actually write the prefs
- Upon compilation, there are a few warnings -- most looked benign but a clean compile is always nice
writePrefs
still has some debugging codeSerial.println(record.data.length_words);
Yes, I was in a hurry. This should all be fixed now and version 1.1 of the library should appear in the Arduino library manager soon.
Thanks for your bug report!
Sounds great, and happy to help.
The example code works great and this library is cool. I was trying to reduce the sample to the smallest possible example. To do this, I commented out all fields other than the first one (and updated the read/write code accordingly, of course):
Interestingly, in the serial output, it will just hang on "Write preferences...". I added back the int field and things worked as expected. Are there certain requirements for the struct used in your library?