mirror of
https://github.com/Laxilef/OTGateway.git
synced 2025-12-14 04:04:28 +05:00
refactoring: arp gratuitous for esp8266
This commit is contained in:
@@ -4,7 +4,11 @@
|
||||
#include <UnsignedShortParameter.h>
|
||||
#include <CheckboxParameter.h>
|
||||
#include <HeaderParameter.h>
|
||||
#include <netif/etharp.h>
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
extern "C" {
|
||||
#include "lwip/etharp.h"
|
||||
}
|
||||
#endif
|
||||
|
||||
WiFiManager wm;
|
||||
WiFiManagerParameter* wmHostname;
|
||||
@@ -210,7 +214,6 @@ protected:
|
||||
task->disable();
|
||||
}
|
||||
}
|
||||
//this->delay(10);
|
||||
});
|
||||
wm.setConfigPortalTimeout(wm.getWiFiIsSaved() ? 180 : 0);
|
||||
wm.setDisableConfigPortal(false);
|
||||
@@ -224,6 +227,10 @@ protected:
|
||||
|
||||
if (wm.getWebPortalActive()) {
|
||||
wm.stopWebPortal();
|
||||
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
::yield();
|
||||
#endif
|
||||
}
|
||||
|
||||
/*wm.setCaptivePortalEnable(true);
|
||||
@@ -234,6 +241,9 @@ protected:
|
||||
|
||||
#if USE_TELNET
|
||||
TelnetStream.stop();
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
::yield();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Log.sinfoln(FPSTR(S_WIFI), F("Disconnected"));
|
||||
@@ -254,27 +264,36 @@ protected:
|
||||
wm.setConfigPortalTimeout(180);
|
||||
if (wm.getConfigPortalActive()) {
|
||||
wm.stopConfigPortal();
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
::yield();
|
||||
#endif
|
||||
}
|
||||
|
||||
wm.setCaptivePortalEnable(false);
|
||||
if (!wm.getWebPortalActive()) {
|
||||
wm.startWebPortal();
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
::yield();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if USE_TELNET
|
||||
TelnetStream.begin(23, false);
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
::yield();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Log.sinfoln(FPSTR(S_WIFI), F("Connected. IP: %s, RSSI: %hhd"), WiFi.localIP().toString().c_str(), WiFi.RSSI());
|
||||
}
|
||||
|
||||
#if defined(ARDUINO_ARCH_ESP8266)
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
if (connected && millis() - lastArpGratuitous > 60000) {
|
||||
arpGratuitous();
|
||||
stationKeepAliveNow();
|
||||
lastArpGratuitous = millis();
|
||||
}
|
||||
|
||||
::yield();
|
||||
}
|
||||
#endif
|
||||
|
||||
wm.process();
|
||||
@@ -518,11 +537,23 @@ protected:
|
||||
eeSettings.update();
|
||||
}
|
||||
|
||||
static void arpGratuitous() {
|
||||
struct netif* netif = netif_list;
|
||||
while (netif) {
|
||||
etharp_gratuitous(netif);
|
||||
netif = netif->next;
|
||||
#ifdef ARDUINO_ARCH_ESP8266
|
||||
/**
|
||||
* @brief
|
||||
* https://github.com/arendst/Tasmota/blob/e6515883f0ee5451931b6280ff847b117de5a231/tasmota/tasmota_support/support_wifi.ino#L1196
|
||||
*/
|
||||
static void stationKeepAliveNow(void) {
|
||||
for (netif* interface = netif_list; interface != nullptr; interface = interface->next) {
|
||||
if (
|
||||
(interface->flags & NETIF_FLAG_LINK_UP)
|
||||
&& (interface->flags & NETIF_FLAG_UP)
|
||||
&& interface->num == STATION_IF
|
||||
&& (!ip4_addr_isany_val(*netif_ip4_addr(interface)))
|
||||
) {
|
||||
etharp_gratuitous(interface);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
};
|
||||
Reference in New Issue
Block a user