esp32-sk6812/include/UDPProto.h
Thomas Kolb dc8bc98193 Circumvent problems with UDP fragmentation
The ESP’s IP stack seems not to support UDP packet fragmentation and
drops such packets silently which is problematic for setups with many
LEDs and huge updates.

With this patch, the UDP server processes up to 3 full UDP packets per
frame, allowing much larger updates. Additionally, the new END_OF_UPDATE
flag allows to signal when a update sequence is finished. If this flag
is encountered, no further UDP packets are processed in the current
frame.
2020-04-14 21:03:39 +02:00

33 lines
466 B
C++

#pragma once
#include <WiFiUdp.h>
class Fader;
class UDPProto
{
public:
enum {
SET_COLOUR = 0,
FADE_COLOUR = 1,
ADD_COLOUR = 2,
SET_FADESTEP = 3,
END_OF_UPDATE = 254,
ACK_REQUEST = 255
};
UDPProto(Fader *fader);
bool start(uint16_t port);
bool check(void);
bool loop(void);
private:
const static uint32_t MAX_PACKETS_PER_UPDATE = 3;
WiFiUDP m_udpServer;
Fader *m_fader;
};