Fix DDP implementation to comply with official specification

- Fix sequence number to use 4-bit nibble (0-15) instead of full byte per DDP spec
- Fix data type encoding to use proper RGB 8-bit format (0x0B) per spec
- Reduce maximum data size to 1440 bytes as recommended in official spec
- Add DDP_TYPE_RGB8 constant for better code clarity
- Improve compliance with http://www.3waylabs.com/ddp/ specification

These changes should improve compatibility with strict DDP implementations
and devices that follow the official protocol specification exactly.
This commit is contained in:
Wolfieee Wolf committed 2025-07-01 17:17:15 +10:00
1 parent 2a9cce70e1
commit a00563f945
2 files changed
+10 -5

No files matched your search

+4 -4
View File
@@ -176,7 +176,7 @@ void DDPController::UpdateLEDs(const std::vector<unsigned int>& colors)
device_data[pixel_offset + 2] = b;
}
unsigned int max_data_per_packet = DDP_MAX_PACKET_SIZE - DDP_HEADER_SIZE;
unsigned int max_data_per_packet = DDP_MAX_DATA_SIZE;
unsigned int bytes_sent = 0;
while(bytes_sent < total_bytes)
@@ -225,8 +225,8 @@ bool DDPController::SendDDPPacket(const DDPDevice& device, const unsigned char*
// CRITICAL FIX: Use 0x41 instead of 0x40 - WLED requires the Push bit to be set
header->flags = DDP_FLAG_VER_1 | DDP_FLAG_PUSH;
header->sequence = sequence_number;
header->data_type = 1; // RGB data type
header->sequence = sequence_number & 0x0F; // Only use 4-bit nibble (0-15) per DDP spec
header->data_type = DDP_TYPE_RGB8; // RGB 8-bit per DDP spec
header->dest_id = 1; // Default output device
header->data_offset = htonl(offset);
header->data_length = htons(length);
@@ -294,7 +294,7 @@ void DDPController::KeepaliveThreadFunction()
device_data[pixel_offset + 2] = b;
}
unsigned int max_data_per_packet = DDP_MAX_PACKET_SIZE - DDP_HEADER_SIZE;
unsigned int max_data_per_packet = DDP_MAX_DATA_SIZE;
unsigned int bytes_sent = 0;
while(bytes_sent < total_bytes)
+6 -1
View File
@@ -22,7 +22,8 @@
#define DDP_HEADER_SIZE 10
#define DDP_HEADER_SIZE_TC 14
#define DDP_VERSION 1
#define DDP_MAX_PACKET_SIZE 1480
#define DDP_MAX_PACKET_SIZE 1450
#define DDP_MAX_DATA_SIZE 1440
#define DDP_FLAG_VER_MASK 0xC0
#define DDP_FLAG_VER_1 0x40
@@ -32,6 +33,10 @@
#define DDP_FLAG_QUERY 0x02
#define DDP_FLAG_PUSH 0x01
// DDP Data Type definitions (bits: C R TTT SSS)
// C: 0=standard, 1=custom; R: reserved; TTT: data type; SSS: size
#define DDP_TYPE_RGB8 0x0B // TTT=001 (RGB), SSS=011 (8-bit)
#pragma pack(push, 1)
struct ddp_header
{