SYSTEM_EVENT.. to ARDUINO_EVENT_...

This commit is contained in:
MichaelDvP
2022-04-25 17:07:52 +02:00
parent 986b4df997
commit fa166483bb
7 changed files with 87 additions and 83 deletions

View File

@@ -47,7 +47,7 @@ void APSettingsService::manageAP() {
void APSettingsService::startAP() { void APSettingsService::startAP() {
WiFi.softAPConfig(_state.localIP, _state.gatewayIP, _state.subnetMask); WiFi.softAPConfig(_state.localIP, _state.gatewayIP, _state.subnetMask);
esp_wifi_set_bandwidth(ESP_IF_WIFI_AP, WIFI_BW_HT20); esp_wifi_set_bandwidth((wifi_interface_t)ESP_IF_WIFI_AP, WIFI_BW_HT20);
WiFi.softAP(_state.ssid.c_str(), _state.password.c_str(), _state.channel, _state.ssidHidden, _state.maxClients); WiFi.softAP(_state.ssid.c_str(), _state.password.c_str(), _state.channel, _state.ssidHidden, _state.maxClients);
if (!_dnsServer) { if (!_dnsServer) {
IPAddress apIp = WiFi.softAPIP(); IPAddress apIp = WiFi.softAPIP();

View File

@@ -99,8 +99,8 @@ void MqttSettingsService::onConfigUpdated() {
void MqttSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) { void MqttSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
switch (event) { switch (event) {
case SYSTEM_EVENT_STA_GOT_IP: case ARDUINO_EVENT_WIFI_STA_GOT_IP:
case SYSTEM_EVENT_ETH_GOT_IP: case ARDUINO_EVENT_ETH_GOT_IP:
emsesp::EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) { emsesp::EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
if (!networkSettings.enableIPv6 && _state.enabled) { if (!networkSettings.enableIPv6 && _state.enabled) {
// emsesp::EMSESP::logger().info(F("IPv4 Network connection found, starting MQTT client")); // emsesp::EMSESP::logger().info(F("IPv4 Network connection found, starting MQTT client"));
@@ -108,14 +108,15 @@ void MqttSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
} }
}); });
break; break;
case SYSTEM_EVENT_GOT_IP6: case ARDUINO_EVENT_ETH_GOT_IP6:
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
if (_state.enabled) { if (_state.enabled) {
// emsesp::EMSESP::logger().info(F("IPv6 Network connection found, starting MQTT client")); // emsesp::EMSESP::logger().info(F("IPv6 Network connection found, starting MQTT client"));
onConfigUpdated(); onConfigUpdated();
} }
break; break;
case SYSTEM_EVENT_STA_DISCONNECTED: case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
case SYSTEM_EVENT_ETH_DISCONNECTED: case ARDUINO_EVENT_ETH_DISCONNECTED:
if (_state.enabled) { if (_state.enabled) {
// emsesp::EMSESP::logger().info(F("Network connection dropped, stopping MQTT client")); // emsesp::EMSESP::logger().info(F("Network connection dropped, stopping MQTT client"));
_mqttClient.disconnect(); _mqttClient.disconnect();

View File

@@ -25,15 +25,15 @@ void NTPSettingsService::begin() {
// handles both WiFI and Ethernet // handles both WiFI and Ethernet
void NTPSettingsService::WiFiEvent(WiFiEvent_t event) { void NTPSettingsService::WiFiEvent(WiFiEvent_t event) {
switch (event) { switch (event) {
case SYSTEM_EVENT_STA_DISCONNECTED: case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
case SYSTEM_EVENT_ETH_DISCONNECTED: case ARDUINO_EVENT_ETH_DISCONNECTED:
emsesp::EMSESP::logger().info(F("WiFi connection dropped, stopping NTP")); emsesp::EMSESP::logger().info(F("WiFi connection dropped, stopping NTP"));
connected_ = false; connected_ = false;
configureNTP(); configureNTP();
break; break;
case SYSTEM_EVENT_STA_GOT_IP: case ARDUINO_EVENT_WIFI_STA_GOT_IP:
case SYSTEM_EVENT_ETH_GOT_IP: case ARDUINO_EVENT_ETH_GOT_IP:
// emsesp::EMSESP::logger().info(F("Got IP address, starting NTP synchronization")); // emsesp::EMSESP::logger().info(F("Got IP address, starting NTP synchronization"));
connected_ = true; connected_ = true;
configureNTP(); configureNTP();

View File

@@ -58,7 +58,7 @@ void NetworkSettingsService::manageSTA() {
if (_state.staticIPConfig) { if (_state.staticIPConfig) {
WiFi.config(_state.localIP, _state.gatewayIP, _state.subnetMask, _state.dnsIP1, _state.dnsIP2); // configure for static IP WiFi.config(_state.localIP, _state.gatewayIP, _state.subnetMask, _state.dnsIP1, _state.dnsIP2); // configure for static IP
} else { } else {
WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE); // configure for DHCP WiFi.config(IPADDR_NONE, IPADDR_NONE, IPADDR_NONE); // configure for DHCP
} }
WiFi.setHostname(_state.hostname.c_str()); // set hostname WiFi.setHostname(_state.hostname.c_str()); // set hostname
@@ -66,9 +66,9 @@ void NetworkSettingsService::manageSTA() {
// www.esp32.com/viewtopic.php?t=12055 // www.esp32.com/viewtopic.php?t=12055
read([&](NetworkSettings & networkSettings) { read([&](NetworkSettings & networkSettings) {
if (networkSettings.bandwidth20) { if (networkSettings.bandwidth20) {
esp_wifi_set_bandwidth(ESP_IF_WIFI_STA, WIFI_BW_HT20); esp_wifi_set_bandwidth((wifi_interface_t)ESP_IF_WIFI_STA, WIFI_BW_HT20);
} else { } else {
esp_wifi_set_bandwidth(ESP_IF_WIFI_STA, WIFI_BW_HT40); esp_wifi_set_bandwidth((wifi_interface_t)ESP_IF_WIFI_STA, WIFI_BW_HT40);
} }
esp_wifi_set_max_tx_power(networkSettings.tx_power * 4); esp_wifi_set_max_tx_power(networkSettings.tx_power * 4);
if (networkSettings.nosleep) { if (networkSettings.nosleep) {
@@ -82,7 +82,7 @@ void NetworkSettingsService::manageSTA() {
// handles if wifi stopped // handles if wifi stopped
void NetworkSettingsService::WiFiEvent(WiFiEvent_t event) { void NetworkSettingsService::WiFiEvent(WiFiEvent_t event) {
if (event == SYSTEM_EVENT_STA_STOP) { if (event == ARDUINO_EVENT_WIFI_STA_STOP) {
if (_stopping) { if (_stopping) {
_lastConnectionAttempt = 0; _lastConnectionAttempt = 0;
_stopping = false; _stopping = false;

View File

@@ -66,8 +66,8 @@ void OTASettingsService::configureArduinoOTA() {
void OTASettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) { void OTASettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
switch (event) { switch (event) {
case SYSTEM_EVENT_STA_GOT_IP: case ARDUINO_EVENT_WIFI_STA_GOT_IP:
case SYSTEM_EVENT_ETH_GOT_IP: case ARDUINO_EVENT_ETH_GOT_IP:
configureArduinoOTA(); configureArduinoOTA();
break; break;
default: default:

View File

@@ -20,34 +20,35 @@ typedef enum {
typedef enum { ETH_PHY_LAN8720, ETH_PHY_TLK110, ETH_PHY_MAX } eth_phy_type_t; typedef enum { ETH_PHY_LAN8720, ETH_PHY_TLK110, ETH_PHY_MAX } eth_phy_type_t;
typedef enum { typedef enum {
SYSTEM_EVENT_WIFI_READY = 0, /**< ESP32 WiFi ready */ ARDUINO_EVENT_WIFI_READY = 0, /**< ESP32 WiFi ready */
SYSTEM_EVENT_SCAN_DONE, /**< ESP32 finish scanning AP */ ARDUINO_EVENT_SCAN_DONE, /**< ESP32 finish scanning AP */
SYSTEM_EVENT_STA_START, /**< ESP32 station start */ ARDUINO_EVENT_WIFI_STA_START, /**< ESP32 station start */
SYSTEM_EVENT_STA_STOP, /**< ESP32 station stop */ ARDUINO_EVENT_WIFI_STA_STOP, /**< ESP32 station stop */
SYSTEM_EVENT_STA_CONNECTED, /**< ESP32 station connected to AP */ ARDUINO_EVENT_WIFI_STA_CONNECTED, /**< ESP32 station connected to AP */
SYSTEM_EVENT_STA_DISCONNECTED, /**< ESP32 station disconnected from AP */ ARDUINO_EVENT_WIFI_STA_DISCONNECTED, /**< ESP32 station disconnected from AP */
SYSTEM_EVENT_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by ESP32 station changed */ ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE, /**< the auth mode of AP connected by ESP32 station changed */
SYSTEM_EVENT_STA_GOT_IP, /**< ESP32 station got IP from connected AP */ ARDUINO_EVENT_WIFI_STA_GOT_IP, /**< ESP32 station got IP from connected AP */
SYSTEM_EVENT_STA_LOST_IP, /**< ESP32 station lost IP and the IP is reset to 0 */ ARDUINO_EVENT_WIFI_STA_LOST_IP, /**< ESP32 station lost IP and the IP is reset to 0 */
SYSTEM_EVENT_STA_WPS_ER_SUCCESS, /**< ESP32 station wps succeeds in enrollee mode */ ARDUINO_EVENT_WIFI_STA_WPS_ER_SUCCESS, /**< ESP32 station wps succeeds in enrollee mode */
SYSTEM_EVENT_STA_WPS_ER_FAILED, /**< ESP32 station wps fails in enrollee mode */ ARDUINO_EVENT_WIFI_STA_WPS_ER_FAILED, /**< ESP32 station wps fails in enrollee mode */
SYSTEM_EVENT_STA_WPS_ER_TIMEOUT, /**< ESP32 station wps timeout in enrollee mode */ ARDUINO_EVENT_WIFI_STA_WPS_ER_TIMEOUT, /**< ESP32 station wps timeout in enrollee mode */
SYSTEM_EVENT_STA_WPS_ER_PIN, /**< ESP32 station wps pin code in enrollee mode */ ARDUINO_EVENT_WIFI_STA_WPS_ER_PIN, /**< ESP32 station wps pin code in enrollee mode */
SYSTEM_EVENT_STA_WPS_ER_PBC_OVERLAP, /*!< ESP32 station wps overlap in enrollee mode */ ARDUINO_EVENT_WIFI_STA_WPS_ER_PBC_OVERLAP, /*!< ESP32 station wps overlap in enrollee mode */
SYSTEM_EVENT_AP_START, /**< ESP32 soft-AP start */ ARDUINO_EVENT_WIFI_AP_START, /**< ESP32 soft-AP start */
SYSTEM_EVENT_AP_STOP, /**< ESP32 soft-AP stop */ ARDUINO_EVENT_WIFI_AP_STOP, /**< ESP32 soft-AP stop */
SYSTEM_EVENT_AP_STACONNECTED, /**< a station connected to ESP32 soft-AP */ ARDUINO_EVENT_WIFI_AP_STACONNECTED, /**< a station connected to ESP32 soft-AP */
SYSTEM_EVENT_AP_STADISCONNECTED, /**< a station disconnected from ESP32 soft-AP */ ARDUINO_EVENT_WIFI_AP_STADISCONNECTED, /**< a station disconnected from ESP32 soft-AP */
SYSTEM_EVENT_AP_STAIPASSIGNED, /**< ESP32 soft-AP assign an IP to a connected station */ ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED, /**< ESP32 soft-AP assign an IP to a connected station */
SYSTEM_EVENT_AP_PROBEREQRECVED, /**< Receive probe request packet in soft-AP interface */ ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED, /**< Receive probe request packet in soft-AP interface */
SYSTEM_EVENT_GOT_IP6, /**< ESP32 station or ap or ethernet interface v6IP addr is preferred */ ARDUINO_EVENT_WIFI_STA_GOT_IP6, /**< ESP32 station or ap or ethernet interface v6IP addr is preferred */
SYSTEM_EVENT_ETH_START, /**< ESP32 ethernet start */ ARDUINO_EVENT_ETH_GOT_IP6, /**< ESP32 station or ap or ethernet interface v6IP addr is preferred */
SYSTEM_EVENT_ETH_STOP, /**< ESP32 ethernet stop */ ARDUINO_EVENT_ETH_START, /**< ESP32 ethernet start */
SYSTEM_EVENT_ETH_CONNECTED, /**< ESP32 ethernet phy link up */ ARDUINO_EVENT_ETH_STOP, /**< ESP32 ethernet stop */
SYSTEM_EVENT_ETH_DISCONNECTED, /**< ESP32 ethernet phy link down */ ARDUINO_EVENT_ETH_CONNECTED, /**< ESP32 ethernet phy link up */
SYSTEM_EVENT_ETH_GOT_IP, /**< ESP32 ethernet got IP from connected AP */ ARDUINO_EVENT_ETH_DISCONNECTED, /**< ESP32 ethernet phy link down */
SYSTEM_EVENT_MAX ARDUINO_EVENT_ETH_GOT_IP, /**< ESP32 ethernet got IP from connected AP */
} system_event_id_t; ARDUINO_EVENT_MAX
} arduino_event_id_t;
typedef enum { typedef enum {
WIFI_AUTH_OPEN = 0, /**< authenticate mode : open */ WIFI_AUTH_OPEN = 0, /**< authenticate mode : open */
@@ -63,7 +64,7 @@ typedef struct {
uint32_t status; /**< status of scanning APs */ uint32_t status; /**< status of scanning APs */
uint8_t number; uint8_t number;
uint8_t scan_id; uint8_t scan_id;
} system_event_sta_scan_done_t; } arduino_event_wifi_sta_scan_done_t;
typedef struct { typedef struct {
uint8_t ssid[32]; /**< SSID of connected AP */ uint8_t ssid[32]; /**< SSID of connected AP */
@@ -71,63 +72,63 @@ typedef struct {
uint8_t bssid[6]; /**< BSSID of connected AP*/ uint8_t bssid[6]; /**< BSSID of connected AP*/
uint8_t channel; /**< channel of connected AP*/ uint8_t channel; /**< channel of connected AP*/
wifi_auth_mode_t authmode; wifi_auth_mode_t authmode;
} system_event_sta_connected_t; } arduino_event_wifi_sta_connected_t;
typedef struct { typedef struct {
uint8_t ssid[32]; /**< SSID of disconnected AP */ uint8_t ssid[32]; /**< SSID of disconnected AP */
uint8_t ssid_len; /**< SSID length of disconnected AP */ uint8_t ssid_len; /**< SSID length of disconnected AP */
uint8_t bssid[6]; /**< BSSID of disconnected AP */ uint8_t bssid[6]; /**< BSSID of disconnected AP */
uint8_t reason; /**< reason of disconnection */ uint8_t reason; /**< reason of disconnection */
} system_event_sta_disconnected_t; } arduino_event_wifi_sta_disconnected_t;
typedef struct { typedef struct {
wifi_auth_mode_t old_mode; /**< the old auth mode of AP */ wifi_auth_mode_t old_mode; /**< the old auth mode of AP */
wifi_auth_mode_t new_mode; /**< the new auth mode of AP */ wifi_auth_mode_t new_mode; /**< the new auth mode of AP */
} system_event_sta_authmode_change_t; } arduino_event_wifi_sta_authmode_change_t;
typedef struct { typedef struct {
uint8_t pin_code[8]; /**< PIN code of station in enrollee mode */ uint8_t pin_code[8]; /**< PIN code of station in enrollee mode */
} system_event_sta_wps_er_pin_t; } arduino_event_wifi_sta_wps_er_pin_t;
typedef struct { typedef struct {
uint8_t mac[6]; /**< MAC address of the station connected to ESP32 soft-AP */ uint8_t mac[6]; /**< MAC address of the station connected to ESP32 soft-AP */
uint8_t aid; /**< the aid that ESP32 soft-AP gives to the station connected to */ uint8_t aid; /**< the aid that ESP32 soft-AP gives to the station connected to */
} system_event_ap_staconnected_t; } arduino_event_wifi_ap_staconnected_t;
typedef struct { typedef struct {
uint8_t mac[6]; /**< MAC address of the station disconnects to ESP32 soft-AP */ uint8_t mac[6]; /**< MAC address of the station disconnects to ESP32 soft-AP */
uint8_t aid; /**< the aid that ESP32 soft-AP gave to the station disconnects to */ uint8_t aid; /**< the aid that ESP32 soft-AP gave to the station disconnects to */
} system_event_ap_stadisconnected_t; } arduino_event_wifi_ap_stadisconnected_t;
typedef struct { typedef struct {
int rssi; /**< Received probe request signal strength */ int rssi; /**< Received probe request signal strength */
uint8_t mac[6]; /**< MAC address of the station which send probe request */ uint8_t mac[6]; /**< MAC address of the station which send probe request */
} system_event_ap_probe_req_rx_t; } arduino_event_wifi_ap_probe_req_rx_t;
typedef enum { typedef enum {
WPS_FAIL_REASON_NORMAL = 0, /**< ESP32 WPS normal fail reason */ WPS_FAIL_REASON_NORMAL = 0, /**< ESP32 WPS normal fail reason */
WPS_FAIL_REASON_RECV_M2D, /**< ESP32 WPS receive M2D frame */ WPS_FAIL_REASON_RECV_M2D, /**< ESP32 WPS receive M2D frame */
WPS_FAIL_REASON_MAX WPS_FAIL_REASON_MAX
} system_event_sta_wps_fail_reason_t; } arduino_event_wifi_sta_wps_fail_reason_t;
typedef union { typedef union {
system_event_sta_connected_t connected; /**< ESP32 station connected to AP */ arduino_event_wifi_sta_connected_t connected; /**< ESP32 station connected to AP */
system_event_sta_disconnected_t disconnected; /**< ESP32 station disconnected to AP */ arduino_event_wifi_sta_disconnected_t disconnected; /**< ESP32 station disconnected to AP */
system_event_sta_scan_done_t scan_done; /**< ESP32 station scan (APs) done */ arduino_event_wifi_sta_scan_done_t scan_done; /**< ESP32 station scan (APs) done */
system_event_sta_authmode_change_t auth_change; /**< the auth mode of AP ESP32 station connected to changed */ arduino_event_wifi_sta_authmode_change_t auth_change; /**< the auth mode of AP ESP32 station connected to changed */
system_event_sta_wps_fail_reason_t sta_er_fail_reason; /**< ESP32 station WPS enrollee mode failed reason code received */ arduino_event_wifi_sta_wps_fail_reason_t sta_er_fail_reason; /**< ESP32 station WPS enrollee mode failed reason code received */
system_event_ap_staconnected_t sta_connected; /**< a station connected to ESP32 soft-AP */ arduino_event_wifi_sta_connected_t sta_connected; /**< a station connected to ESP32 soft-AP */
system_event_ap_stadisconnected_t sta_disconnected; /**< a station disconnected to ESP32 soft-AP */ arduino_event_wifi_sta_disconnected_t sta_disconnected; /**< a station disconnected to ESP32 soft-AP */
system_event_ap_probe_req_rx_t ap_probereqrecved; /**< ESP32 soft-AP receive probe request packet */ arduino_event_wifi_ap_probe_req_rx_t ap_probereqrecved; /**< ESP32 soft-AP receive probe request packet */
} system_event_info_t; } arduino_event_info_t;
typedef struct { typedef struct {
system_event_id_t event_id; /**< event ID */ arduino_event_id_t event_id; /**< event ID */
system_event_info_t event_info; /**< event information */ arduino_event_info_t event_info; /**< event information */
} system_event_t; } arduino_event_t;
#define WiFiEvent_t system_event_id_t #define WiFiEvent_t arduino_event_id_t
#define WiFiEventInfo_t system_event_info_t #define WiFiEventInfo_t arduino_event_info_t
#define WiFiEventId_t wifi_event_id_t #define WiFiEventId_t wifi_event_id_t
typedef enum { typedef enum {
@@ -141,20 +142,20 @@ typedef enum {
WL_DISCONNECTED = 6 WL_DISCONNECTED = 6
} wl_status_t; } wl_status_t;
typedef void (*WiFiEventCb)(system_event_id_t event); typedef void (*WiFiEventCb)(arduino_event_id_t event);
typedef std::function<void(system_event_id_t event, system_event_info_t info)> WiFiEventFuncCb; typedef std::function<void(arduino_event_id_t event, arduino_event_info_t info)> WiFiEventFuncCb;
typedef void (*WiFiEventSysCb)(system_event_t * event); typedef void (*WiFiEventSysCb)(arduino_event_t * event);
typedef size_t wifi_event_id_t; typedef size_t wifi_event_id_t;
class WiFiClass { class WiFiClass {
public: public:
wifi_event_id_t onEvent(WiFiEventCb cbEvent, system_event_id_t event = SYSTEM_EVENT_MAX) { wifi_event_id_t onEvent(WiFiEventCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX) {
return 0; return 0;
}; };
wifi_event_id_t onEvent(WiFiEventFuncCb cbEvent, system_event_id_t event = SYSTEM_EVENT_MAX) { wifi_event_id_t onEvent(WiFiEventFuncCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX) {
return 0; return 0;
}; };
wifi_event_id_t onEvent(WiFiEventSysCb cbEvent, system_event_id_t event = SYSTEM_EVENT_MAX) { wifi_event_id_t onEvent(WiFiEventSysCb cbEvent, arduino_event_id_t event = ARDUINO_EVENT_MAX) {
return 0; return 0;
}; };

View File

@@ -33,12 +33,13 @@ WebStatusService::WebStatusService(AsyncWebServer * server, SecurityManager * se
// handles both WiFI and Ethernet // handles both WiFI and Ethernet
void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) { void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
switch (event) { switch (event) {
case SYSTEM_EVENT_STA_DISCONNECTED: case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:
EMSESP::logger().info(F("WiFi disconnected. Reason code=%d"), info.disconnected.reason); EMSESP::logger().info(F("WiFi disconnected. Reason code=%d"), info.prov_fail_reason); // IDF 4.0
// EMSESP::logger().info(F("WiFi disconnected. Reason code=%d"), info.disconnected.reason);
WiFi.disconnect(true); WiFi.disconnect(true);
break; break;
case SYSTEM_EVENT_STA_GOT_IP: case ARDUINO_EVENT_WIFI_STA_GOT_IP:
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
EMSESP::logger().info(F("WiFi connected with IP=%s, hostname=%s"), WiFi.localIP().toString().c_str(), WiFi.getHostname()); EMSESP::logger().info(F("WiFi connected with IP=%s, hostname=%s"), WiFi.localIP().toString().c_str(), WiFi.getHostname());
#endif #endif
@@ -51,7 +52,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
mDNS_start(); mDNS_start();
break; break;
case SYSTEM_EVENT_ETH_START: case ARDUINO_EVENT_ETH_START:
// EMSESP::logger().info(F("Ethernet initialized")); // EMSESP::logger().info(F("Ethernet initialized"));
ETH.setHostname(EMSESP::system_.hostname().c_str()); ETH.setHostname(EMSESP::system_.hostname().c_str());
@@ -64,7 +65,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
break; break;
case SYSTEM_EVENT_ETH_GOT_IP: case ARDUINO_EVENT_ETH_GOT_IP:
// prevent double calls // prevent double calls
if (!EMSESP::system_.ethernet_connected()) { if (!EMSESP::system_.ethernet_connected()) {
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
@@ -81,18 +82,18 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
} }
break; break;
case SYSTEM_EVENT_ETH_DISCONNECTED: case ARDUINO_EVENT_ETH_DISCONNECTED:
EMSESP::logger().info(F("Ethernet disconnected")); EMSESP::logger().info(F("Ethernet disconnected"));
EMSESP::system_.ethernet_connected(false); EMSESP::system_.ethernet_connected(false);
break; break;
case SYSTEM_EVENT_ETH_STOP: case ARDUINO_EVENT_ETH_STOP:
EMSESP::logger().info(F("Ethernet stopped")); EMSESP::logger().info(F("Ethernet stopped"));
EMSESP::system_.ethernet_connected(false); EMSESP::system_.ethernet_connected(false);
break; break;
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
case SYSTEM_EVENT_STA_CONNECTED: case ARDUINO_EVENT_WIFI_STA_CONNECTED:
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) { EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
if (networkSettings.enableIPv6) { if (networkSettings.enableIPv6) {
WiFi.enableIpV6(); WiFi.enableIpV6();
@@ -100,7 +101,7 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
}); });
break; break;
case SYSTEM_EVENT_ETH_CONNECTED: case ARDUINO_EVENT_ETH_CONNECTED:
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) { EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
if (networkSettings.enableIPv6) { if (networkSettings.enableIPv6) {
ETH.enableIpV6(); ETH.enableIpV6();
@@ -108,7 +109,8 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
}); });
break; break;
case SYSTEM_EVENT_GOT_IP6: case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
case ARDUINO_EVENT_ETH_GOT_IP6:
if (EMSESP::system_.ethernet_connected()) { if (EMSESP::system_.ethernet_connected()) {
EMSESP::logger().info(F("Ethernet connected with IP=%s, speed %d Mbps"), ETH.localIPv6().toString().c_str(), ETH.linkSpeed()); EMSESP::logger().info(F("Ethernet connected with IP=%s, speed %d Mbps"), ETH.localIPv6().toString().c_str(), ETH.linkSpeed());
} else { } else {