memset(&pkg, 0, sizeof(pkg)); pkg.cmd = REQ_ID_STREAM_INFO; pkg.payload.stream_info.width = camera.width(); pkg.payload.stream_info.height = camera.height(); Udp.beginPacket(ctx->ip, ctx->port); Udp.write((uint8_t *)&pkg, sizeof(pkg)); Udp.endPacket(); // frame proper memset(&pkg, 0, sizeof(pkg)); pkg.cmd = REQ_ID_STREAM_FRAME; pkg.payload.frame_size = camera.frameSize(); Udp.beginPacket(ctx->ip, ctx->port); Udp.write((uint8_t *)&pkg, sizeof(pkg)); Udp.write(camera.raw(), 30);//camera.frameSize()); Udp.endPacket(); // OCCASIONAL FAILURE HERE
The last line occasionally fails.
I've noticed it doesn't fail when I reduce the number of bytes written to the second frame
or when I introduce a delay between two packets.
Can I check somehow that the packet has been sent
Your proof seems to be non-existent.What do you mean by "second frame"? Reduce the number from what to what?What two packets? That code sends ONE packet.The endPacket() method returns a value, so, yes, you can.
I call beginPacket/endPacket two times.