File tree Expand file tree Collapse file tree 3 files changed +17
-9
lines changed
Expand file tree Collapse file tree 3 files changed +17
-9
lines changed Original file line number Diff line number Diff line change 22
33IPAddress NetworkClass::localIP ()
44{
5+ IPAddress localIP;
56#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET)
6- if (ETH.localIP ()[0 ] != 0 ) {
7- return ETH.localIP ();
7+ localIP = ETH.localIP ();
8+ if (localIP[0 ] != 0 ) {
9+ return localIP;
810 }
911#endif
10- if (WiFi.localIP ()[0 ] != 0 ) {
11- return WiFi.localIP ();
12+ localIP = WiFi.localIP ();
13+ if (localIP[0 ] != 0 ) {
14+ return localIP;
1215 }
16+
1317 return INADDR_NONE;
1418}
1519
Original file line number Diff line number Diff line change @@ -120,6 +120,8 @@ void sendTPM2Ack() {
120120
121121void handleNotifications ()
122122{
123+ IPAddress localIP;
124+
123125 // send second notification if enabled
124126 if (udpConnected && notificationTwoRequired && millis ()-notificationSentTime > 250 ){
125127 notify (notificationSentCallMode,true );
@@ -175,9 +177,10 @@ void handleNotifications()
175177
176178 if (!(receiveNotifications || receiveDirect)) return ;
177179
180+ localIP = Network.localIP ();
178181 // notifier and UDP realtime
179182 if (!packetSize || packetSize > UDP_IN_MAXSIZE) return ;
180- if (!isSupp && notifierUdp.remoteIP () == Network. localIP () ) return ; // don't process broadcasts we send ourselves
183+ if (!isSupp && notifierUdp.remoteIP () == localIP) return ; // don't process broadcasts we send ourselves
181184
182185 uint8_t udpIn[packetSize +1 ];
183186 uint16_t len;
@@ -186,7 +189,7 @@ void handleNotifications()
186189
187190 // WLED nodes info notifications
188191 if (isSupp && udpIn[0 ] == 255 && udpIn[1 ] == 1 && len >= 40 ) {
189- if (!nodeListEnabled || notifier2Udp.remoteIP () == Network. localIP () ) return ;
192+ if (!nodeListEnabled || notifier2Udp.remoteIP () == localIP) return ;
190193
191194 uint8_t unit = udpIn[39 ];
192195 NodesMap::iterator it = Nodes.find (unit);
Original file line number Diff line number Diff line change @@ -591,13 +591,14 @@ void WLED::initConnection()
591591
592592void WLED::initInterfaces ()
593593{
594+ IPAddress ipAddress = Network.localIP ();
594595 DEBUG_PRINTLN (F (" Init STA interfaces" ));
595596
596597#ifndef WLED_DISABLE_HUESYNC
597598 if (hueIP[0 ] == 0 ) {
598- hueIP[0 ] = Network. localIP () [0 ];
599- hueIP[1 ] = Network. localIP () [1 ];
600- hueIP[2 ] = Network. localIP () [2 ];
599+ hueIP[0 ] = ipAddress [0 ];
600+ hueIP[1 ] = ipAddress [1 ];
601+ hueIP[2 ] = ipAddress [2 ];
601602 }
602603#endif
603604
You can’t perform that action at this time.
0 commit comments