8266 hotfix: solving connectivity problems
* it seems that `WiFiUDP.flsuh()` does something completely different from 8266, and its actually causing WLED to stall on UI calls. So not usable on 8266. * fixing a few compiler warnings about "comparing signed and unsigned" NB: its a hotfix, we have to check if there are other problems on 8266. Also its definitely ugly, but it helps as a band aid.
This commit is contained in:
@@ -1472,7 +1472,9 @@ class AudioReactive : public Usermod {
|
|||||||
packetSize = fftUdp.parsePacket();
|
packetSize = fftUdp.parsePacket();
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
packetSize = 0; // low heap memory -> discard packet.
|
packetSize = 0; // low heap memory -> discard packet.
|
||||||
fftUdp.flush();
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
fftUdp.flush(); // this does not work on 8266
|
||||||
|
#endif
|
||||||
DEBUG_PRINTLN(F("receiveAudioData: parsePacket out of memory exception caught!"));
|
DEBUG_PRINTLN(F("receiveAudioData: parsePacket out of memory exception caught!"));
|
||||||
USER_FLUSH();
|
USER_FLUSH();
|
||||||
}
|
}
|
||||||
@@ -1828,7 +1830,9 @@ class AudioReactive : public Usermod {
|
|||||||
if (have_new_sample) last_UDPTime = millis();
|
if (have_new_sample) last_UDPTime = millis();
|
||||||
lastTime = millis();
|
lastTime = millis();
|
||||||
} else {
|
} else {
|
||||||
fftUdp.flush(); // WLEDMM: Flush this if we haven't read it.
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
|
fftUdp.flush(); // WLEDMM: Flush this if we haven't read it. Does not work on 8266.
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (have_new_sample) syncVolumeSmth = volumeSmth; // remember received sample
|
if (have_new_sample) syncVolumeSmth = volumeSmth; // remember received sample
|
||||||
else volumeSmth = syncVolumeSmth; // restore originally received sample for next run of dynamics limiter
|
else volumeSmth = syncVolumeSmth; // restore originally received sample for next run of dynamics limiter
|
||||||
|
|||||||
@@ -5102,7 +5102,7 @@ uint16_t mode_2DLissajous(void) { // By: Andrew Tuline
|
|||||||
uint_fast16_t phase = (strip.now * (1 + SEGENV.custom3)) /32; // allow user to control rotation speed
|
uint_fast16_t phase = (strip.now * (1 + SEGENV.custom3)) /32; // allow user to control rotation speed
|
||||||
|
|
||||||
if (SEGENV.check3) { // WLEDMM: this is the original "float" code featuring anti-aliasing
|
if (SEGENV.check3) { // WLEDMM: this is the original "float" code featuring anti-aliasing
|
||||||
unsigned maxLoops = max(192, 4*(cols+rows));
|
int maxLoops = max(192, 4*(cols+rows));
|
||||||
maxLoops = ((maxLoops / 128) +1) * 128; // make sure whe have half or full turns => multiples of 128
|
maxLoops = ((maxLoops / 128) +1) * 128; // make sure whe have half or full turns => multiples of 128
|
||||||
for (int i=0; i < maxLoops; i ++) {
|
for (int i=0; i < maxLoops; i ++) {
|
||||||
float xlocn = float(sin8(phase/2 + (i* SEGMENT.speed)/64)) / 255.0f; // WLEDMM align speed with original effect
|
float xlocn = float(sin8(phase/2 + (i* SEGMENT.speed)/64)) / 255.0f; // WLEDMM align speed with original effect
|
||||||
|
|||||||
@@ -226,9 +226,15 @@ void sendNTPPacket()
|
|||||||
|
|
||||||
bool checkNTPResponse()
|
bool checkNTPResponse()
|
||||||
{
|
{
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
ntpUdp.flush();
|
ntpUdp.flush();
|
||||||
|
#endif
|
||||||
int cb = ntpUdp.parsePacket();
|
int cb = ntpUdp.parsePacket();
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
if (!cb) {ntpUdp.flush(); return false;} // WLEDMM flush buffer
|
if (!cb) {ntpUdp.flush(); return false;} // WLEDMM flush buffer
|
||||||
|
#else
|
||||||
|
if (!cb) {return false;} // WLEDMM do not flush buffer
|
||||||
|
#endif
|
||||||
|
|
||||||
uint32_t ntpPacketReceivedTime = millis();
|
uint32_t ntpPacketReceivedTime = millis();
|
||||||
DEBUG_PRINT(F("NTP recv, l="));
|
DEBUG_PRINT(F("NTP recv, l="));
|
||||||
|
|||||||
@@ -240,10 +240,14 @@ void handleNotifications()
|
|||||||
if (!udpConnected) return;
|
if (!udpConnected) return;
|
||||||
|
|
||||||
bool isSupp = false;
|
bool isSupp = false;
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
notifierUdp.flush();
|
notifierUdp.flush();
|
||||||
|
#endif
|
||||||
int packetSize = notifierUdp.parsePacket(); // WLEDMM function returns int, not size_t
|
int packetSize = notifierUdp.parsePacket(); // WLEDMM function returns int, not size_t
|
||||||
if ((packetSize < 1) && udp2Connected) {
|
if ((packetSize < 1) && udp2Connected) {
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
notifier2Udp.flush();
|
notifier2Udp.flush();
|
||||||
|
#endif
|
||||||
packetSize = notifier2Udp.parsePacket();
|
packetSize = notifier2Udp.parsePacket();
|
||||||
isSupp = true;
|
isSupp = true;
|
||||||
}
|
}
|
||||||
@@ -251,11 +255,18 @@ void handleNotifications()
|
|||||||
|
|
||||||
//hyperion / raw RGB
|
//hyperion / raw RGB
|
||||||
if (!packetSize && udpRgbConnected) {
|
if (!packetSize && udpRgbConnected) {
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
rgbUdp.flush();
|
rgbUdp.flush();
|
||||||
|
#endif
|
||||||
packetSize = rgbUdp.parsePacket();
|
packetSize = rgbUdp.parsePacket();
|
||||||
if (packetSize) {
|
if (packetSize) {
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
if (!receiveDirect) {rgbUdp.flush(); notifierUdp.flush(); notifier2Udp.flush(); return;}
|
if (!receiveDirect) {rgbUdp.flush(); notifierUdp.flush(); notifier2Udp.flush(); return;}
|
||||||
if (packetSize > UDP_IN_MAXSIZE || packetSize < 3) {rgbUdp.flush(); notifierUdp.flush(); notifier2Udp.flush(); return;}
|
if (packetSize > UDP_IN_MAXSIZE || packetSize < 3) {rgbUdp.flush(); notifierUdp.flush(); notifier2Udp.flush(); return;}
|
||||||
|
#else
|
||||||
|
if (!receiveDirect) {return;}
|
||||||
|
if (packetSize > UDP_IN_MAXSIZE || packetSize < 3) {return;}
|
||||||
|
#endif
|
||||||
realtimeIP = rgbUdp.remoteIP();
|
realtimeIP = rgbUdp.remoteIP();
|
||||||
DEBUG_PRINTLN(rgbUdp.remoteIP());
|
DEBUG_PRINTLN(rgbUdp.remoteIP());
|
||||||
#ifndef ARDUINO_ARCH_ESP32
|
#ifndef ARDUINO_ARCH_ESP32
|
||||||
@@ -263,10 +274,14 @@ void handleNotifications()
|
|||||||
#endif
|
#endif
|
||||||
rgbUdp.read(lbuf, packetSize);
|
rgbUdp.read(lbuf, packetSize);
|
||||||
realtimeLock(realtimeTimeoutMs, REALTIME_MODE_HYPERION);
|
realtimeLock(realtimeTimeoutMs, REALTIME_MODE_HYPERION);
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
if (realtimeOverride && !(realtimeMode && useMainSegmentOnly)) {notifierUdp.flush(); notifier2Udp.flush(); return;}
|
if (realtimeOverride && !(realtimeMode && useMainSegmentOnly)) {notifierUdp.flush(); notifier2Udp.flush(); return;}
|
||||||
|
#else
|
||||||
|
if (realtimeOverride && !(realtimeMode && useMainSegmentOnly)) {return;}
|
||||||
|
#endif
|
||||||
uint16_t id = 0;
|
uint16_t id = 0;
|
||||||
uint16_t totalLen = strip.getLengthTotal();
|
uint16_t totalLen = strip.getLengthTotal();
|
||||||
for (size_t i = 0; i < packetSize -2; i += 3)
|
for (int i = 0; i < packetSize -2; i += 3)
|
||||||
{
|
{
|
||||||
setRealtimePixel(id, lbuf[i], lbuf[i+1], lbuf[i+2], 0);
|
setRealtimePixel(id, lbuf[i], lbuf[i+1], lbuf[i+2], 0);
|
||||||
id++; if (id >= totalLen) break;
|
id++; if (id >= totalLen) break;
|
||||||
@@ -276,12 +291,21 @@ void handleNotifications()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
if (!(receiveNotifications || receiveDirect)) {notifierUdp.flush(); notifier2Udp.flush(); return;}
|
if (!(receiveNotifications || receiveDirect)) {notifierUdp.flush(); notifier2Udp.flush(); return;}
|
||||||
|
#else
|
||||||
|
if (!(receiveNotifications || receiveDirect)) {return;}
|
||||||
|
#endif
|
||||||
|
|
||||||
localIP = Network.localIP();
|
localIP = Network.localIP();
|
||||||
//notifier and UDP realtime
|
//notifier and UDP realtime
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
if (!packetSize || packetSize > UDP_IN_MAXSIZE) {notifierUdp.flush(); notifier2Udp.flush(); return;}
|
if (!packetSize || packetSize > UDP_IN_MAXSIZE) {notifierUdp.flush(); notifier2Udp.flush(); return;}
|
||||||
if (!isSupp && notifierUdp.remoteIP() == localIP) {notifierUdp.flush(); notifier2Udp.flush(); return;} //don't process broadcasts we send ourselves
|
if (!isSupp && notifierUdp.remoteIP() == localIP) {notifierUdp.flush(); notifier2Udp.flush(); return;} //don't process broadcasts we send ourselves
|
||||||
|
#else
|
||||||
|
if (!packetSize || packetSize > UDP_IN_MAXSIZE) {return;}
|
||||||
|
if (!isSupp && notifierUdp.remoteIP() == localIP) {return;} //don't process broadcasts we send ourselves
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef ARDUINO_ARCH_ESP32
|
#ifndef ARDUINO_ARCH_ESP32
|
||||||
uint8_t udpIn[packetSize +1]; // WLEDMM: use global buffer on ESP32
|
uint8_t udpIn[packetSize +1]; // WLEDMM: use global buffer on ESP32
|
||||||
@@ -539,14 +563,14 @@ void handleNotifications()
|
|||||||
uint16_t totalLen = strip.getLengthTotal();
|
uint16_t totalLen = strip.getLengthTotal();
|
||||||
if (udpIn[0] == 1) //warls
|
if (udpIn[0] == 1) //warls
|
||||||
{
|
{
|
||||||
for (size_t i = 2; i < packetSize -3; i += 4)
|
for (int i = 2; i < packetSize -3; i += 4)
|
||||||
{
|
{
|
||||||
setRealtimePixel(udpIn[i], udpIn[i+1], udpIn[i+2], udpIn[i+3], 0);
|
setRealtimePixel(udpIn[i], udpIn[i+1], udpIn[i+2], udpIn[i+3], 0);
|
||||||
}
|
}
|
||||||
} else if (udpIn[0] == 2) //drgb
|
} else if (udpIn[0] == 2) //drgb
|
||||||
{
|
{
|
||||||
uint16_t id = 0;
|
uint16_t id = 0;
|
||||||
for (size_t i = 2; i < packetSize -2; i += 3)
|
for (int i = 2; i < packetSize -2; i += 3)
|
||||||
{
|
{
|
||||||
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], 0);
|
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], 0);
|
||||||
|
|
||||||
@@ -555,7 +579,7 @@ void handleNotifications()
|
|||||||
} else if (udpIn[0] == 3) //drgbw
|
} else if (udpIn[0] == 3) //drgbw
|
||||||
{
|
{
|
||||||
uint16_t id = 0;
|
uint16_t id = 0;
|
||||||
for (size_t i = 2; i < packetSize -3; i += 4)
|
for (int i = 2; i < packetSize -3; i += 4)
|
||||||
{
|
{
|
||||||
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], udpIn[i+3]);
|
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], udpIn[i+3]);
|
||||||
|
|
||||||
@@ -564,7 +588,7 @@ void handleNotifications()
|
|||||||
} else if (udpIn[0] == 4) //dnrgb
|
} else if (udpIn[0] == 4) //dnrgb
|
||||||
{
|
{
|
||||||
uint16_t id = ((udpIn[3] << 0) & 0xFF) + ((udpIn[2] << 8) & 0xFF00);
|
uint16_t id = ((udpIn[3] << 0) & 0xFF) + ((udpIn[2] << 8) & 0xFF00);
|
||||||
for (size_t i = 4; i < packetSize -2; i += 3)
|
for (int i = 4; i < packetSize -2; i += 3)
|
||||||
{
|
{
|
||||||
if (id >= totalLen) break;
|
if (id >= totalLen) break;
|
||||||
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], 0);
|
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], 0);
|
||||||
@@ -573,7 +597,7 @@ void handleNotifications()
|
|||||||
} else if (udpIn[0] == 5) //dnrgbw
|
} else if (udpIn[0] == 5) //dnrgbw
|
||||||
{
|
{
|
||||||
uint16_t id = ((udpIn[3] << 0) & 0xFF) + ((udpIn[2] << 8) & 0xFF00);
|
uint16_t id = ((udpIn[3] << 0) & 0xFF) + ((udpIn[2] << 8) & 0xFF00);
|
||||||
for (size_t i = 4; i < packetSize -2; i += 4)
|
for (int i = 4; i < packetSize -2; i += 4)
|
||||||
{
|
{
|
||||||
if (id >= totalLen) break;
|
if (id >= totalLen) break;
|
||||||
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], udpIn[i+3]);
|
setRealtimePixel(id, udpIn[i], udpIn[i+1], udpIn[i+2], udpIn[i+3]);
|
||||||
|
|||||||
@@ -63,6 +63,11 @@
|
|||||||
//This is generally a terrible idea, but improves boot success on boards with a 3.3v regulator + cap setup that can't provide 400mA peaks
|
//This is generally a terrible idea, but improves boot success on boards with a 3.3v regulator + cap setup that can't provide 400mA peaks
|
||||||
//#define WLED_DISABLE_BROWNOUT_DET
|
//#define WLED_DISABLE_BROWNOUT_DET
|
||||||
|
|
||||||
|
// WLED-MM MANDATORY flags
|
||||||
|
#ifdef ARDUINO_ARCH_ESP32 // this feature seems unstable on 8266
|
||||||
|
#define WLEDMM_PROTECT_SERVICE // prevents crashes when effects are drawing while asyncWebServer tries to modify segments at the same time
|
||||||
|
#endif
|
||||||
|
|
||||||
// Library inclusions.
|
// Library inclusions.
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ static bool sendLiveLedsWs(uint32_t wsClient) // WLEDMM added "static"
|
|||||||
|
|
||||||
void handleWs()
|
void handleWs()
|
||||||
{
|
{
|
||||||
if (millis() - wsLastLiveTime > max((strip.getLengthTotal()/20), WS_LIVE_INTERVAL)) //WLEDMM dynamic nr of peek frames per second
|
if ((millis() - wsLastLiveTime) > (unsigned long)(max((strip.getLengthTotal()/20), WS_LIVE_INTERVAL))) //WLEDMM dynamic nr of peek frames per second
|
||||||
{
|
{
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
ws.cleanupClients(3);
|
ws.cleanupClients(3);
|
||||||
|
|||||||
Reference in New Issue
Block a user