fix: Increase WledClient DDP timeout to 5 seconds

This commit is contained in:
Tobias J. Endres 2025-08-16 06:35:59 +02:00
parent da1890f237
commit cfc205db7a

View File

@ -41,14 +41,16 @@ void WledClient::sendImage(const QImage &image)
int totalLeds = rgbImage.width() * rgbImage.height();
int ledsPerPacket = MAX_LED_DATA_PER_PACKET / 3; // 3 bytes per LED (RGB)
qDebug() << "WledClient: sendImage - totalLeds:" << totalLeds << "ledsPerPacket:" << ledsPerPacket;
for (int i = 0; i < totalLeds; i += ledsPerPacket) {
QByteArray datagram;
datagram.reserve(4 + (ledsPerPacket * 3)); // Header + max LED data
// Byte 0: Protocol type (DNRGB)
datagram.append(DDP_PROTOCOL_DNRGB);
// Byte 1: Timeout (1 second)
datagram.append(1);
// Byte 1: Timeout (5 seconds)
datagram.append(5);
// Bytes 2 & 3: Starting LED index (low byte, then high byte)
quint16 startIndex = i;
@ -57,6 +59,8 @@ void WledClient::sendImage(const QImage &image)
int currentLedsInPacket = qMin(ledsPerPacket, totalLeds - i);
qDebug() << "WledClient: Sending packet (sendImage) - i:" << i << "startIndex:" << startIndex << "currentLedsInPacket:" << currentLedsInPacket;
for (int j = 0; j < currentLedsInPacket; ++j) {
int pixelIndex = i + j;
int x = pixelIndex % rgbImage.width();
@ -88,6 +92,8 @@ void WledClient::setLedsColor(const QVector<QColor> &colors, int timeout)
int totalLeds = colors.size();
int ledsPerPacket = MAX_LED_DATA_PER_PACKET / 3; // 3 bytes per LED (RGB)
qDebug() << "WledClient: setLedsColor - totalLeds:" << totalLeds << "ledsPerPacket:" << ledsPerPacket;
for (int i = 0; i < totalLeds; i += ledsPerPacket) {
QByteArray datagram;
datagram.reserve(4 + (ledsPerPacket * 3)); // Header + max LED data
@ -104,6 +110,8 @@ void WledClient::setLedsColor(const QVector<QColor> &colors, int timeout)
int currentLedsInPacket = qMin(ledsPerPacket, totalLeds - i);
qDebug() << "WledClient: Sending packet (setLedsColor) - i:" << i << "startIndex:" << startIndex << "currentLedsInPacket:" << currentLedsInPacket;
for (int j = 0; j < currentLedsInPacket; ++j) {
const QColor &color = colors.at(i + j);
// Swap R and G for GRB order
@ -140,8 +148,8 @@ void WledClient::flashLeds(int startIndex, int count, QColor color)
// Byte 0: Protocol type (DNRGB)
datagram.append(DDP_PROTOCOL_DNRGB);
// Byte 1: Timeout (1 second)
datagram.append(1);
// Byte 1: Timeout (5 seconds)
datagram.append(5);
// Bytes 2 & 3: Starting LED index (low byte, then high byte)
quint16 currentStartIndex = startIndex + i;