37#if ESP_ARDUINO_VERSION_MAJOR >= 3
39 wifi_got_ip_handle_ = Network.onEvent(
40 [
this](arduino_event_id_t, arduino_event_info_t) {
41 ESP_LOGI(
"net_state",
"WiFi station got IP %s",
42 WiFi.localIP().toString().c_str());
45 ARDUINO_EVENT_WIFI_STA_GOT_IP);
47 wifi_disconnected_handle_ = Network.onEvent(
48 [
this](arduino_event_id_t, arduino_event_info_t) {
49 ESP_LOGI(
"net_state",
"WiFi station disconnected");
52 ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
54 wifi_ap_start_handle_ = Network.onEvent(
55 [
this](arduino_event_id_t, arduino_event_info_t) {
56 ESP_LOGI(
"net_state",
"WiFi soft-AP started, IP %s",
57 WiFi.softAPIP().toString().c_str());
60 ARDUINO_EVENT_WIFI_AP_START);
62 wifi_ap_stop_handle_ = Network.onEvent(
63 [
this](arduino_event_id_t, arduino_event_info_t) {
64 ESP_LOGI(
"net_state",
"WiFi soft-AP stopped");
66 if (!WiFi.isConnected()) {
70 ARDUINO_EVENT_WIFI_AP_STOP);
73 eth_got_ip_handle_ = Network.onEvent(
74 [
this](arduino_event_id_t, arduino_event_info_t) {
75 ESP_LOGI(
"net_state",
"Ethernet got IP");
78 ARDUINO_EVENT_ETH_GOT_IP);
80 eth_lost_ip_handle_ = Network.onEvent(
81 [
this](arduino_event_id_t, arduino_event_info_t) {
82 ESP_LOGI(
"net_state",
"Ethernet lost IP");
85 ARDUINO_EVENT_ETH_LOST_IP);
87 eth_disconnected_handle_ = Network.onEvent(
88 [
this](arduino_event_id_t, arduino_event_info_t) {
89 ESP_LOGI(
"net_state",
"Ethernet PHY disconnected");
92 ARDUINO_EVENT_ETH_DISCONNECTED);
96 wifi_got_ip_handle_ = WiFi.onEvent(
97 [
this](WiFiEvent_t, WiFiEventInfo_t) {
98 ESP_LOGI(
"net_state",
"WiFi station got IP %s",
99 WiFi.localIP().toString().c_str());
102 WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP);
104 wifi_disconnected_handle_ = WiFi.onEvent(
105 [
this](WiFiEvent_t, WiFiEventInfo_t) {
106 ESP_LOGI(
"net_state",
"WiFi station disconnected");
109 WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);
111 wifi_ap_start_handle_ = WiFi.onEvent(
112 [
this](WiFiEvent_t, WiFiEventInfo_t) {
113 ESP_LOGI(
"net_state",
"WiFi soft-AP started, IP %s",
114 WiFi.softAPIP().toString().c_str());
117 WiFiEvent_t::ARDUINO_EVENT_WIFI_AP_START);
119 wifi_ap_stop_handle_ = WiFi.onEvent(
120 [
this](WiFiEvent_t, WiFiEventInfo_t) {
121 ESP_LOGI(
"net_state",
"WiFi soft-AP stopped");
123 if (!WiFi.isConnected()) {
127 WiFiEvent_t::ARDUINO_EVENT_WIFI_AP_STOP);
139#if ESP_ARDUINO_VERSION_MAJOR >= 3
140 Network.removeEvent(wifi_got_ip_handle_);
141 Network.removeEvent(wifi_disconnected_handle_);
142 Network.removeEvent(wifi_ap_start_handle_);
143 Network.removeEvent(wifi_ap_stop_handle_);
144 Network.removeEvent(eth_got_ip_handle_);
145 Network.removeEvent(eth_lost_ip_handle_);
146 Network.removeEvent(eth_disconnected_handle_);
148 WiFi.removeEvent(wifi_got_ip_handle_);
149 WiFi.removeEvent(wifi_disconnected_handle_);
150 WiFi.removeEvent(wifi_ap_start_handle_);
151 WiFi.removeEvent(wifi_ap_stop_handle_);