WiFiClient->write does not send complte message
Posted: Wed Jan 03, 2024 2:37 pm
Hi,
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.
The result from WiFiClient->write is a number of bytes sent. That is the number at the end of each string. So I write the complete string but only two bytes are sent and then the rest.
This is the output from Node-Red and that reflects what I see from the transmit side.
And this is the piece of cose that writes the message out.
I am sure that I am missing something stupid so some help will be appreciated.
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.