I am using an ESP32 Dev board and I am trying to get TCP messages sent to Node-Red. All the connectivity is working but my messages are consistently broken up or not send completely.
The project is meant to connect to a LoRaWan board via a serial port and then send the message to Node-Red via TCP.
The message looks like this.
Code: Select all
{" type":"sensor","unique_id":"TopTankWaterLevel","sensor":2,"payload":4325}
Code: Select all
{"2
type":"sensor","unique_id":"TopTankWaterLevel","sensor":1,"payload":100}
74
Code: Select all
msg : Object
object
_msgid: "63c458aa1560dad9"
payload: "{""
1/3/2024, 4:31:06 PMnode: 1febf83796b23888
msg : Object
object
_msgid: "63c458aa1560dad9"
payload: "type":"sensor","unique_id":"TopTankWaterLevel","sensor":2,"payload":4325}↵"
Code: Select all
uint8_t ccnt = 0;
for (byte cln = 0; cln < MAX_NMEA_CLIENTS; cln++)
{
if (TCPClient[num][cln])
{
TCPClient[num]->flush();
// this writes the message out
ccnt = TCPClient[num][cln].write(buf2[num], i2[num]);
// this is s print of the message to show what it looks like
COM[0]->write(buf2[num], i2[num]); //// debug only
COM[0]->println(ccnt); //// debug only
COM[0]->flush();
}
}
I am sure that I am missing something stupid so some help will be appreciated.