Sending data over udp in larger packets

currently i send a struct over udp like this from esp32 to esp8266,

  Udp.beginPacket(custom, 4210);
  Udp.print("ALDATA");
  Udp.write((uint8_t*)&ts1, sizeof(ts1)); //cast to bytes
  Udp.endPacket();

the size of ts1 is 262 bytes, When i send this message it seems like slow transmission, and slow receive. How can i speed this up. if i try to send like this would it send larger chunks?

  Udp.beginPacket(custom, 4210);
  Udp.print("ALDATA");
  Udp.write((uint32_t*)&ts1, sizeof(ts1)); 
  Udp.endPacket();

I also need help understand the variable size between arduino mega and esp32. If i make a struct on arduino mega,

struct test {
uint8_t a;
};
test t;

then i try to send it to the esp32 over serial,

Serial2.write((uint8_t*)&t, sizeof(t));

but when i receive it on the esp32 the struct size on the esp32 dont match the arduino struct and the struct is corrupted.
type or paste code here

I figured out why it was going slow, i was reading *39 uint32_t " 1248 bytes into a 255 byte buffer..

The problem with the variable sizes between the two cpu's is still a problem. i have a chart that explains the difference between arduino cpu's. but i cant seem to find a chart that explains the esp32 or 8266.

the simplest thing is to run a program to print the sizeof() a type, e.g.

void setup() {
  Serial.begin(115200);
  delay(1000);
  Serial.println();
  Serial.println(sizeof(int));

}

void loop() {}

gives

ESP32 4
esp8266 4
Arduino Mega 2

when transferring data between systems in binary as well as the sizeof() of different types one may have to consider the endianness

Thanks i had not thought about that. Good idea

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.