2022-09-19, 02:11 PM
(2022-09-19, 01:36 PM)Erikblade Wrote: That is if I send the deltas to signalk through Serial.print(), since the Json issue, even using the ArduinoJson.h library, I am not able to understand or master them.
This rang a few bells... I use micropython now with an esp32 to do stuff then send data as signalk, but before it was arduino code, and also had issues with json, looking at the vscode ini looks like it had to be an ArduinoJson@<6.0.0
https://github.com/boatybits/DATA_SENDER...formio.ini
Feel free to take any code which might be useful >
https://github.com/boatybits/DATA_SENDER...c/main.cpp
Code:
void sendSigK(String sigKey, float data)
{
if (sendSig_Flag == 1)
{
DynamicJsonBuffer jsonBuffer;
String deltaText;
// build delta message
JsonObject &delta = jsonBuffer.createObject();
//updated array
JsonArray &updatesArr = delta.createNestedArray("updates");
JsonObject &thisUpdate = updatesArr.createNestedObject(); //Json Object nested inside delta [...
JsonArray &values = thisUpdate.createNestedArray("values"); // Values array nested in delta[ values....
JsonObject &thisValue = values.createNestedObject();
thisValue["path"] = sigKey;
thisValue["value"] = data;
thisUpdate["Source"] = "ESP32";
// Send UDP packet
Udp.beginPacket(remoteIp, remotePort);
delta.printTo(Udp);
Udp.println();
Udp.endPacket();
delta.printTo(Serial);
Serial.println();
}
} //___________________________________________________________