-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Description
Hi, I feel rather stupid to report such a profound issue. I followed the instructions which are pretty easy and it did not help.
This is the function I added:
inline void convertToJson(const char& src, JsonVariant dst) {
char buf[32];
snprintf(buf, sizeof(buf), "%c", src);
dst.set(buf);
}
The strange thing is, the code used to work just perfectly until I involuntary updated the PlatformIO configuration. In that moment, quite a lot of packages got updated and I can't figure out, which ones.
I mean, wouldn't it be kind of to be expected that ArduinoJson is perfectly capable of serialize a simple char?
I can go around the issue by putting my char into a const char* but it just feels wrong.
Any hint of what the real reason behind this issue could be?
Troubleshooter's report
- The issue happens at compile time
- Error says "no matching function for call to ..."
- Error says "no matching function for call to
convertToJson(...)" - Converting the value doesn't fix the issue
Environment
- Microcontroller: ESP32S2
- Core/Framework: Arduino / espressif32 (#v4.2.0 - #v6.2.0) / board = adafruit_qtpy_esp32s2
- IDE: VS PlatformIO Core 6.1.6·Home 3.4.3
Reproduction code
class Settings
{
public:
char get_char(ESettingName id) const {return getReference(id).as_char();}
...
};
class WebServer
{
public:
template <size_t N>
void append_flexEVSEsettings(StaticJsonDocument<N>& doc)
{
StaticJsonDocument<N>& doc
auto doc_AP = doc["AP"];
doc_AP["_ApTimeOutMode"] = settings_.get_char(Settings::ESettingName::_ApTimeOutMode);
}
...
};
WebServer webServer_;
StaticJsonDocument<3000> response_doc;
webServer_.append_flexEVSEsettings(response_doc);Remarks
I made sure that my extra convertToJson was actually compiled by just adding a syntax error in front of the function declaration and got the expected error from the compiler.
I can not figure out why the compiler would not be satisfied with my convertToJson function. But much more curious actually is, why do I get the error in the first place? I'm sure ArduinoJson would be able to encode a simple char. Other types work perfectly, I mean: bool, int, unsigned int, const char*, doubles, String etc.
Thanks a lot for your time to read this!
BR
Phil