Skip to content

Commit 7895a03

Browse files
committed
esp32/modnetwork: Implement AP version of network.isconnected().
Returns "True" if any stations are connected to the ESP32's access point.
1 parent a6cc636 commit 7895a03

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

esp32/modnetwork.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,15 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_scan_obj, esp_scan);
305305

306306
STATIC mp_obj_t esp_isconnected(mp_obj_t self_in) {
307307
wlan_if_obj_t *self = MP_OBJ_TO_PTR(self_in);
308-
require_if(self_in, WIFI_IF_STA);
309-
tcpip_adapter_ip_info_t info;
310-
tcpip_adapter_get_ip_info(self->if_id, &info);
311-
return mp_obj_new_bool(info.ip.addr != 0);
308+
if (self->if_id == WIFI_IF_STA) {
309+
tcpip_adapter_ip_info_t info;
310+
tcpip_adapter_get_ip_info(WIFI_IF_STA, &info);
311+
return mp_obj_new_bool(info.ip.addr != 0);
312+
} else {
313+
wifi_sta_list_t sta;
314+
esp_wifi_ap_get_sta_list(&sta);
315+
return mp_obj_new_bool(sta.num != 0);
316+
}
312317
}
313318
STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_isconnected_obj, esp_isconnected);
314319

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy