Avoid redundant localIP calls, each call takes 0.700 us on ESP32 240Mhz (#2206)
* Avoid redundant localIP calls, each call takes 0.700 us on ESP32 240Mhz * Fall through to check Wifi local ip if not connected to ETH * Changed local var from ipAddress to localIP to better reflect content
This commit is contained in:
parent
b8e8028eb9
commit
3577da05ac
@ -2,14 +2,18 @@
|
|||||||
|
|
||||||
IPAddress NetworkClass::localIP()
|
IPAddress NetworkClass::localIP()
|
||||||
{
|
{
|
||||||
|
IPAddress localIP;
|
||||||
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET)
|
#if defined(ARDUINO_ARCH_ESP32) && defined(WLED_USE_ETHERNET)
|
||||||
if (ETH.localIP()[0] != 0) {
|
localIP = ETH.localIP();
|
||||||
return ETH.localIP();
|
if (localIP[0] != 0) {
|
||||||
|
return localIP;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (WiFi.localIP()[0] != 0) {
|
localIP = WiFi.localIP();
|
||||||
return WiFi.localIP();
|
if (localIP[0] != 0) {
|
||||||
|
return localIP;
|
||||||
}
|
}
|
||||||
|
|
||||||
return INADDR_NONE;
|
return INADDR_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +120,8 @@ void sendTPM2Ack() {
|
|||||||
|
|
||||||
void handleNotifications()
|
void handleNotifications()
|
||||||
{
|
{
|
||||||
|
IPAddress localIP;
|
||||||
|
|
||||||
//send second notification if enabled
|
//send second notification if enabled
|
||||||
if(udpConnected && notificationTwoRequired && millis()-notificationSentTime > 250){
|
if(udpConnected && notificationTwoRequired && millis()-notificationSentTime > 250){
|
||||||
notify(notificationSentCallMode,true);
|
notify(notificationSentCallMode,true);
|
||||||
@ -175,9 +177,10 @@ void handleNotifications()
|
|||||||
|
|
||||||
if (!(receiveNotifications || receiveDirect)) return;
|
if (!(receiveNotifications || receiveDirect)) return;
|
||||||
|
|
||||||
|
localIP = Network.localIP();
|
||||||
//notifier and UDP realtime
|
//notifier and UDP realtime
|
||||||
if (!packetSize || packetSize > UDP_IN_MAXSIZE) return;
|
if (!packetSize || packetSize > UDP_IN_MAXSIZE) return;
|
||||||
if (!isSupp && notifierUdp.remoteIP() == Network.localIP()) return; //don't process broadcasts we send ourselves
|
if (!isSupp && notifierUdp.remoteIP() == localIP) return; //don't process broadcasts we send ourselves
|
||||||
|
|
||||||
uint8_t udpIn[packetSize +1];
|
uint8_t udpIn[packetSize +1];
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
@ -186,7 +189,7 @@ void handleNotifications()
|
|||||||
|
|
||||||
// WLED nodes info notifications
|
// WLED nodes info notifications
|
||||||
if (isSupp && udpIn[0] == 255 && udpIn[1] == 1 && len >= 40) {
|
if (isSupp && udpIn[0] == 255 && udpIn[1] == 1 && len >= 40) {
|
||||||
if (!nodeListEnabled || notifier2Udp.remoteIP() == Network.localIP()) return;
|
if (!nodeListEnabled || notifier2Udp.remoteIP() == localIP) return;
|
||||||
|
|
||||||
uint8_t unit = udpIn[39];
|
uint8_t unit = udpIn[39];
|
||||||
NodesMap::iterator it = Nodes.find(unit);
|
NodesMap::iterator it = Nodes.find(unit);
|
||||||
|
@ -591,13 +591,14 @@ void WLED::initConnection()
|
|||||||
|
|
||||||
void WLED::initInterfaces()
|
void WLED::initInterfaces()
|
||||||
{
|
{
|
||||||
|
IPAddress ipAddress = Network.localIP();
|
||||||
DEBUG_PRINTLN(F("Init STA interfaces"));
|
DEBUG_PRINTLN(F("Init STA interfaces"));
|
||||||
|
|
||||||
#ifndef WLED_DISABLE_HUESYNC
|
#ifndef WLED_DISABLE_HUESYNC
|
||||||
if (hueIP[0] == 0) {
|
if (hueIP[0] == 0) {
|
||||||
hueIP[0] = Network.localIP()[0];
|
hueIP[0] = ipAddress[0];
|
||||||
hueIP[1] = Network.localIP()[1];
|
hueIP[1] = ipAddress[1];
|
||||||
hueIP[2] = Network.localIP()[2];
|
hueIP[2] = ipAddress[2];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user