esp32/modnetwork: Implement wlan.isconnected() method.
@@ -295,9 +295,12 @@ STATIC mp_obj_t esp_scan(mp_obj_t self_in) {
STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_scan_obj, esp_scan);
STATIC mp_obj_t esp_isconnected(mp_obj_t self_in) {
- return mp_const_none;
+ wlan_if_obj_t *self = MP_OBJ_TO_PTR(self_in);
+ require_if(self_in, WIFI_IF_STA);
+ tcpip_adapter_ip_info_t info;
+ tcpip_adapter_get_ip_info(self->if_id, &info);
+ return mp_obj_new_bool(info.ip.addr != 0);
}
-
STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_isconnected_obj, esp_isconnected);
STATIC mp_obj_t esp_ifconfig(size_t n_args, const mp_obj_t *args) {
