I am trying to interact between ArduinoJson and Preferences.h and ESP32WebServer. For reasons too long to go into for this question, I would like to use the getString method in Preferences.h with the following signature:
size_t getString(const char* key, char* value, size_t maxLen);
I have tried many iterations but cannot figure out how to get the method to accept my parameters, including (size_t)197 and size_t s=197;
Rather than waste everyone's time showing all the things I tried, which didn't work, can someone tell me what I should do or if they have the same problem?
Thanks
getString in Preference not working
-
- Posts: 829
- Joined: Mon Jul 22, 2019 3:20 pm
Re: getString in Preference not working
You don't show where you define jCharArray, but it is an array of char pointers. The first overload of getString wants just a char pointer, or else an array which it will cast to a pointer. The (much simpler) second overload will return a String, and just needs the key name. Try just calling String jString = prefs.getString("sparams"); and then convert that to a char array with jString.c_str() where needed.
Who is online
Users browsing this forum: No registered users and 49 guests