Hi
I have been using Losant with ESP8266 and ESP32 for a while now, always exchanging numbers and bolleans between the dashboard and the microcontroller. But now I need to send a string from the Dashboard to the microcontrollers (some 40 chars).
So, I create a String attribute -> create an input text box on Dashboard with that attribute set on the ‘Attribute’ field -> give a name to thee template id in thatinput box -> Add a button trigger and set its payload as follows:
{
"Some_text":{{Template_id}}
}
And that’s it on the Losant side, on the Arduino IDE side, I have the hanles as follows:
void handleCommand(LosantCommand *command) {
JsonObject& payload = *command->payload;
serializeJson(payload, Serial);
if (strcmp(command->name, "Template_id") == 0) {
msgs[1] = payload["Some_text"].as<String>();
Serial.println(msgs[1]);
}
}
All works fine with numbers, for example, if I send 45 on the input box, I get the print on Arduino IDE:
{"Some_text":45}
But if I send letters…all I get is null.
On the Device Log, on Losant, I can see, for example if I send an Hello:
"name":"Send_switch"
"payload":"{\r\n \"Some_text\":Hello\r\n}\r\n"
"time":"2020-08-17T22:49:22.450Z"
But on Arduino, always a null =
Any ideia?
I have been reading all I can find about Strings ectraction on payloads, theres a few posts but none of the solutions solved my problem =\
Thank you.
Cheers, Luís Pereira.
I’m adding some pictures for clarification: