-->
Page 1 of 2

ESP8266-01 Missing Packet Data?

PostPosted: Thu Feb 04, 2016 7:01 am
by Trey
Hopefully someone can give me a logical explanation for this.

I have external code on 3 platforms. This code communicates with my ESP via UDP.

Right off I realized sending large packets caused the esp to reset/panic.

I changed my code to send smaller packets and it works great. Now to get to the issue.

The esp is getting getting 28 byte packages. That represent int's for settings.

What I can't figure out is why bytes 8 9 11 12 always return 0 on the receiving side, when I see that the data is being passed correctly from all external apps.

Example Code:

byte packetBuffer[] = "28";
Udp.read(packetBuffer,28);

ArrayToInteger converter;
converter.array[0] = packetBuffer[8];
converter.array[1] = packetBuffer[9];
converter.array[2] = packetBuffer[10];
converter.array[3] = packetBuffer[11];
data_between_8_and_11 = converter.integer;
yield();

Thanks in advance.

Re: ESP8266-01 Missing Packet Data?

PostPosted: Thu Feb 04, 2016 7:17 am
by Pablo2048
Your
Code: Select allbyte packetBuffer[] = "28";
is array of 3 bytes, use
Code: Select allbyte packetBuffer[28];
instead... Also I suggest to change
Code: Select allUdp.read(packetBuffer,28);
into
Code: Select allUdp.read(packetBuffer, sizeof(packetBuffer));

Re: ESP8266-01 Missing Packet Data?

PostPosted: Thu Feb 04, 2016 4:08 pm
by Trey
Thanks I will give that a shot.

Re: ESP8266-01 Missing Packet Data?

PostPosted: Thu Feb 04, 2016 4:29 pm
by Trey
So I am able to get a value from 8,9,10 & 11 now. Thank you.
However my data is coming out with blanks still if i fill up the 8 bytes I have been leaving blank.

(1st set of 4 is packet id that gets sent in a response and checked before the next packet is sent
2nd Set of 4 bytes holds a pointer to the proper copy to index in a larger array that can not exceed 5080 bytes)

converter.array[0] = packetBuffer[4];
converter.array[1] = packetBuffer[5];
converter.array[2] = packetBuffer[6];
converter.array[3] = packetBuffer[7];
packet_index = converter.integer;

//before works bytes 16 thru 28
//std::copy(packetBuffer + 16, packetBuffer + 28, pixelData + packet_index );

This mangles data and is full of 0's
std::copy(packetBuffer + 8, packetBuffer + 28, pixelData + packet_index );

Same thing if I increase the packet size to 32 or 36 bytes