Skip to content

Commit

Permalink
Add number of UDP retries (#2830)
Browse files Browse the repository at this point in the history
* Release of WLED v0.13.3

* Fixed a type in the file name (#2781)

* Fixed the dependency (#2782)

* Usermod Wordclock update to use an alternatve wiring pattern (#2757)

* Update

* update readme file

* readme update

* Update readme.md

* Update readme.md

* Update readme.md

* Update readme.md

* Update platformio.ini

* Add number of UDP retries

Add a configurable number of retries to the UDP WLED sync function.

* Add migration from old eeprom settings

* Revert some accidental carry overs

* Correct issues found in pull request

Change default number of retries
Fix migration from old settings

* Make the minimum number of retries 0

* Import notify twice setting

Co-authored-by: cschwinne <dev.aircoookie@gmail.com>
Co-authored-by: Soren Singh Dary <67230851+sorensd@users.noreply.github.com>
Co-authored-by: Patrick <40436536+paeppi88@users.noreply.github.com>
  • Loading branch information
4 people authored Oct 18, 2022
1 parent c982e02 commit b3a2918
Show file tree
Hide file tree
Showing 12 changed files with 3,726 additions and 3,713 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## WLED changelog

### WLED release 0.13.3

- Version bump to v0.13.3 "Toki"
- Disable ESP watchdog by default (fixes flickering and boot issues on a fresh install)
- Added support for LPD6803

### WLED release 0.13.2

#### Build 2208140
Expand Down
5 changes: 3 additions & 2 deletions wled00/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,9 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
CJSON(notifyAlexa, if_sync_send["va"]);
CJSON(notifyHue, if_sync_send["hue"]);
CJSON(notifyMacro, if_sync_send["macro"]);
CJSON(notifyTwice, if_sync_send[F("twice")]);
CJSON(syncGroups, if_sync_send["grp"]);
if (if_sync_send[F("twice")]) udpNumRetries = 1; // import setting from 0.13 and earlier
CJSON(udpNumRetries, if_sync_send["ret"]);

JsonObject if_nodes = interfaces["nodes"];
CJSON(nodeListEnabled, if_nodes[F("list")]);
Expand Down Expand Up @@ -807,8 +808,8 @@ void serializeConfig() {
if_sync_send["va"] = notifyAlexa;
if_sync_send["hue"] = notifyHue;
if_sync_send["macro"] = notifyMacro;
if_sync_send[F("twice")] = notifyTwice;
if_sync_send["grp"] = syncGroups;
if_sync_send["ret"] = udpNumRetries;

JsonObject if_nodes = interfaces.createNestedObject("nodes");
if_nodes[F("list")] = nodeListEnabled;
Expand Down
2 changes: 1 addition & 1 deletion wled00/data/settings_sync.htm
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ <h3>WLED Broadcast</h3>
Send Alexa notifications: <input type="checkbox" name="SA"><br>
Send Philips Hue change notifications: <input type="checkbox" name="SH"><br>
Send Macro notifications: <input type="checkbox" name="SM"><br>
Send notifications twice: <input type="checkbox" name="S2"><br>
UDP packet retransmissions: <input name="UR" type="number" min="0" max="30" class="d5" required><br><br>
<i>Reboot required to apply changes. </i>
<h3>Instance List</h3>
Enable instance list: <input type="checkbox" name="NL"><br>
Expand Down
1,532 changes: 766 additions & 766 deletions wled00/html_other.h

Large diffs are not rendered by default.

715 changes: 358 additions & 357 deletions wled00/html_settings.h

Large diffs are not rendered by default.

2,241 changes: 1,121 additions & 1,120 deletions wled00/html_simple.h

Large diffs are not rendered by default.

2,921 changes: 1,461 additions & 1,460 deletions wled00/html_ui.h

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion wled00/set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,10 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
notifyAlexa = request->hasArg(F("SA"));
notifyHue = request->hasArg(F("SH"));
notifyMacro = request->hasArg(F("SM"));
notifyTwice = request->hasArg(F("S2"));

t = request->arg(F("UR")).toInt();
if ((t>=0) && (t<30)) udpNumRetries = t;


nodeListEnabled = request->hasArg(F("NL"));
if (!nodeListEnabled) Nodes.clear();
Expand Down
4 changes: 2 additions & 2 deletions wled00/udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void notify(byte callMode, bool followUp)
notifierUdp.endPacket();
notificationSentCallMode = callMode;
notificationSentTime = millis();
notificationTwoRequired = (followUp)? false:notifyTwice;
notificationCount = followUp ? notificationCount + 1 : 0;
}

void realtimeLock(uint32_t timeoutMs, byte md)
Expand Down Expand Up @@ -207,7 +207,7 @@ void handleNotifications()
IPAddress localIP;

//send second notification if enabled
if(udpConnected && notificationTwoRequired && millis()-notificationSentTime > 250){
if(udpConnected && (notificationCount < udpNumRetries) && ((millis()-notificationSentTime) > 250)){
notify(notificationSentCallMode,true);
}

Expand Down
4 changes: 2 additions & 2 deletions wled00/wled.h
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ WLED_GLOBAL bool notifyButton _INIT(false); // send if upd
WLED_GLOBAL bool notifyAlexa _INIT(false); // send notification if updated via Alexa
WLED_GLOBAL bool notifyMacro _INIT(false); // send notification for macro
WLED_GLOBAL bool notifyHue _INIT(true); // send notification if Hue light changes
WLED_GLOBAL bool notifyTwice _INIT(false); // notifications use UDP: enable if devices don't sync reliably
WLED_GLOBAL uint8_t udpNumRetries _INIT(0); // Number of times a UDP sync message is retransmitted. Increase to increase reliability

WLED_GLOBAL bool alexaEnabled _INIT(false); // enable device discovery by Amazon Echo
WLED_GLOBAL char alexaInvocationName[33] _INIT("Light"); // speech control name of device. Choose something voice-to-text can understand
Expand Down Expand Up @@ -505,7 +505,7 @@ WLED_GLOBAL bool notifyDirectDefault _INIT(notifyDirect);
WLED_GLOBAL bool receiveNotifications _INIT(true);
WLED_GLOBAL unsigned long notificationSentTime _INIT(0);
WLED_GLOBAL byte notificationSentCallMode _INIT(CALL_MODE_INIT);
WLED_GLOBAL bool notificationTwoRequired _INIT(false);
WLED_GLOBAL uint8_t notificationCount _INIT(0);

// effects
WLED_GLOBAL byte effectCurrent _INIT(0);
Expand Down
2 changes: 1 addition & 1 deletion wled00/wled_eeprom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void loadSettingsFromEEPROM()
busses.add(bc);

notifyButton = EEPROM.read(230);
notifyTwice = EEPROM.read(231);
if (EEPROM.read(231)) udpNumRetries = 1;
buttonType[0] = EEPROM.read(232) ? BTN_TYPE_PUSH : BTN_TYPE_NONE;

staticIP[0] = EEPROM.read(234);
Expand Down
2 changes: 1 addition & 1 deletion wled00/xml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ void getSettingsJS(byte subPage, char* dest)
sappend('c',SET_F("SB"),notifyButton);
sappend('c',SET_F("SH"),notifyHue);
sappend('c',SET_F("SM"),notifyMacro);
sappend('c',SET_F("S2"),notifyTwice);
sappend('v',SET_F("UR"),udpNumRetries);

sappend('c',SET_F("NL"),nodeListEnabled);
sappend('c',SET_F("NB"),nodeBroadcastEnabled);
Expand Down

0 comments on commit b3a2918

Please sign in to comment.