Skip to content
This repository was archived by the owner on Aug 23, 2024. It is now read-only.

Commit 01ee38d

Browse files
committed
Merge branch 'm5stack-dev' into m5stack
2 parents d6023df + 1e7773c commit 01ee38d

17 files changed

Lines changed: 60 additions & 20 deletions

MicroPython_BUILD/components/micropython/esp32/modnetwork.c

Lines changed: 55 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,25 @@ static const char* const wifi_events[] = {
147147
"Ethernet got IP from connected AP",
148148
};
149149

150+
static const char* const wifi_cyphers[] = {
151+
"NONE",
152+
"WEP40",
153+
"WEP104",
154+
"TKIP",
155+
"CCMP",
156+
"TKIP_CCMP",
157+
"UNKNOWN",
158+
};
159+
160+
static const char* const wifi_auth_modes[] = {
161+
"OPEN",
162+
"WEP",
163+
"WPA_PSK",
164+
"WPA2_PSK",
165+
"WPA_WPA2_PSK",
166+
"WPA2_ENTERPRISE",
167+
};
168+
150169
static inline void esp_exceptions(esp_err_t e) {
151170
if (e != ESP_OK) _esp_exceptions(e);
152171
}
@@ -646,8 +665,8 @@ STATIC mp_obj_t esp_status(size_t n_args, const mp_obj_t *args) {
646665
}
647666
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_status_obj, 1, 2, esp_status);
648667

649-
//------------------------------------------
650-
STATIC mp_obj_t esp_scan(mp_obj_t self_in) {
668+
//-------------------------------------------------------------
669+
STATIC mp_obj_t esp_scan(size_t n_args, const mp_obj_t *args) {
651670
if (wifi_network_state < 2) {
652671
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "WiFi not started"));
653672
}
@@ -664,6 +683,7 @@ STATIC mp_obj_t esp_scan(mp_obj_t self_in) {
664683
mp_obj_t list = mp_obj_new_list(0, NULL);
665684
wifi_scan_config_t config = { 0 };
666685
// XXX how do we scan hidden APs (and if we can scan them, are they really hidden?)
686+
if (n_args > 1) config.show_hidden = mp_obj_is_true(args[1]);
667687
MP_THREAD_GIL_EXIT();
668688
esp_err_t status = esp_wifi_scan_start(&config, 1);
669689
MP_THREAD_GIL_ENTER();
@@ -673,22 +693,23 @@ STATIC mp_obj_t esp_scan(mp_obj_t self_in) {
673693
wifi_ap_record_t *wifi_ap_records = calloc(count, sizeof(wifi_ap_record_t));
674694
ESP_EXCEPTIONS( esp_wifi_scan_get_ap_records(&count, wifi_ap_records) );
675695
for (uint16_t i = 0; i < count; i++) {
676-
mp_obj_tuple_t *t = mp_obj_new_tuple(6, NULL);
696+
mp_obj_tuple_t *t = mp_obj_new_tuple(7, NULL);
677697
uint8_t *x = memchr(wifi_ap_records[i].ssid, 0, sizeof(wifi_ap_records[i].ssid));
678698
int ssid_len = x ? x - wifi_ap_records[i].ssid : sizeof(wifi_ap_records[i].ssid);
679699
t->items[0] = mp_obj_new_bytes(wifi_ap_records[i].ssid, ssid_len);
680700
t->items[1] = mp_obj_new_bytes(wifi_ap_records[i].bssid, sizeof(wifi_ap_records[i].bssid));
681701
t->items[2] = MP_OBJ_NEW_SMALL_INT(wifi_ap_records[i].primary);
682702
t->items[3] = MP_OBJ_NEW_SMALL_INT(wifi_ap_records[i].rssi);
683703
t->items[4] = MP_OBJ_NEW_SMALL_INT(wifi_ap_records[i].authmode);
684-
t->items[5] = mp_const_false; // XXX hidden?
704+
t->items[5] = mp_obj_new_str(wifi_auth_modes[wifi_ap_records[i].authmode], strlen(wifi_auth_modes[wifi_ap_records[i].authmode]));
705+
t->items[6] = (ssid_len == 0) ? mp_const_true : mp_const_false;
685706
mp_obj_list_append(list, MP_OBJ_FROM_PTR(t));
686707
}
687708
free(wifi_ap_records);
688709
}
689710
return list;
690711
}
691-
STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_scan_obj, esp_scan);
712+
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_scan_obj, 1, 2, esp_scan);
692713

693714
//-------------------------------------------------
694715
STATIC mp_obj_t esp_isconnected(mp_obj_t self_in) {
@@ -697,20 +718,25 @@ STATIC mp_obj_t esp_isconnected(mp_obj_t self_in) {
697718
}
698719
wlan_if_obj_t *self = MP_OBJ_TO_PTR(self_in);
699720
if (self->if_id == WIFI_IF_STA) {
700-
//tcpip_adapter_ip_info_t info;
701-
//tcpip_adapter_get_ip_info(WIFI_IF_STA, &info);
702-
//return mp_obj_new_bool(info.ip.addr != 0);
703-
return mp_obj_new_bool(_isConnected);
704-
} else {
705-
wifi_sta_list_t sta;
706-
esp_wifi_ap_get_sta_list(&sta);
707-
return mp_obj_new_bool(sta.num != 0);
721+
return mp_obj_new_bool(((wifi_sta_isconnected) && (wifi_sta_has_ipaddress)));
722+
}
723+
else {
724+
bool res = false;
725+
if (wifi_ap_isconnected) {
726+
wifi_sta_list_t sta;
727+
esp_wifi_ap_get_sta_list(&sta);
728+
res = (sta.num != 0);
729+
}
730+
return mp_obj_new_bool(res);
708731
}
709732
}
710733
STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_isconnected_obj, esp_isconnected);
711734

712735
//-----------------------------------------------------------------
713736
STATIC mp_obj_t esp_ifconfig(size_t n_args, const mp_obj_t *args) {
737+
if (wifi_network_state < 2) {
738+
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "WiFi not started"));
739+
}
714740
wlan_if_obj_t *self = MP_OBJ_TO_PTR(args[0]);
715741
tcpip_adapter_ip_info_t info;
716742
tcpip_adapter_dns_info_t dns_info;
@@ -764,6 +790,9 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_ifconfig_obj, 1, 2, esp_ifconfig);
764790

765791
//---------------------------------------------------------------------------------
766792
STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
793+
if (wifi_network_state < 2) {
794+
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "WiFi not started"));
795+
}
767796
if (n_args != 1 && kwargs->used != 0) {
768797
mp_raise_TypeError("either pos or kw args are allowed");
769798
}
@@ -855,6 +884,7 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
855884
mp_obj_t val;
856885

857886
#define QS(x) (uintptr_t)MP_OBJ_NEW_QSTR(x)
887+
mp_obj_tuple_t *t;
858888
switch ((uintptr_t)args[1]) {
859889
case QS(MP_QSTR_mac): {
860890
uint8_t mac[6];
@@ -871,7 +901,18 @@ STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs
871901
break;
872902
case QS(MP_QSTR_authmode):
873903
req_if = WIFI_IF_AP;
874-
val = MP_OBJ_NEW_SMALL_INT(cfg.ap.authmode);
904+
t = mp_obj_new_tuple(2, NULL);
905+
t->items[0] = MP_OBJ_NEW_SMALL_INT(cfg.ap.authmode);
906+
t->items[1] = mp_obj_new_str(wifi_auth_modes[cfg.ap.authmode], strlen(wifi_auth_modes[cfg.ap.authmode]));
907+
val = MP_OBJ_FROM_PTR(t);
908+
break;
909+
case QS(MP_QSTR_wifimode):
910+
t = mp_obj_new_tuple(2, NULL);
911+
t->items[0] = MP_OBJ_NEW_SMALL_INT(self->if_id);
912+
if (self->if_id == WIFI_IF_STA)
913+
t->items[1] = mp_obj_new_str("STA_IF", 6);
914+
else t->items[1] = mp_obj_new_str("AP_IF", 5);
915+
val = MP_OBJ_FROM_PTR(t);
875916
break;
876917
case QS(MP_QSTR_channel):
877918
req_if = WIFI_IF_AP;
@@ -1289,7 +1330,6 @@ STATIC const mp_map_elem_t mp_module_network_globals_table[] = {
12891330
{ MP_OBJ_NEW_QSTR(MP_QSTR_AUTH_WPA_PSK), MP_OBJ_NEW_SMALL_INT(WIFI_AUTH_WPA_PSK) },
12901331
{ MP_OBJ_NEW_QSTR(MP_QSTR_AUTH_WPA2_PSK), MP_OBJ_NEW_SMALL_INT(WIFI_AUTH_WPA2_PSK) },
12911332
{ MP_OBJ_NEW_QSTR(MP_QSTR_AUTH_WPA_WPA2_PSK), MP_OBJ_NEW_SMALL_INT(WIFI_AUTH_WPA_WPA2_PSK) },
1292-
{ MP_OBJ_NEW_QSTR(MP_QSTR_AUTH_MAX), MP_OBJ_NEW_SMALL_INT(WIFI_AUTH_MAX) },
12931333

12941334
#ifdef CONFIG_MICROPY_USE_ETHERNET
12951335
{ MP_OBJ_NEW_QSTR(MP_QSTR_PHY_LAN8720), MP_OBJ_NEW_SMALL_INT(PHY_LAN8720) },

MicroPython_BUILD/components/micropython/esp32/mpthreadport.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ static int _check_wifi()
727727
if (info.ip.addr == 0) return 0;
728728

729729
if ((wifi_mode == WIFI_MODE_STA) && ((!wifi_sta_isconnected) || (!wifi_sta_has_ipaddress))) return 0;
730-
else if ((wifi_mode == WIFI_MODE_AP) && ((!wifi_ap_isconnected) || (!wifi_ap_sta_isconnected))) return 0;
730+
else if ((wifi_mode == WIFI_MODE_AP) && (!wifi_ap_isconnected)) return 0;
731731

732732
return 1;
733733
}

MicroPython_BUILD/components/micropython/esp32/mpversion.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
#define MICROPY_GIT_TAG "ESP32_LoBo_v3.2.5"
27+
#define MICROPY_GIT_TAG "ESP32_LoBo_v3.2.6"
2828
#define MICROPY_GIT_HASH "gf586f5e6"
29-
#define MICROPY_BUILD_DATE "2018-04-08"
29+
#define MICROPY_BUILD_DATE "2018-04-09"
3030
#define MICROPY_VERSION_MAJOR (3)
3131
#define MICROPY_VERSION_MINOR (2)
32-
#define MICROPY_VERSION_MICRO (5)
33-
#define MICROPY_VERSION_STRING "3.2.5"
32+
#define MICROPY_VERSION_MICRO (6)
33+
#define MICROPY_VERSION_STRING "3.2.6"
3434
#define MICROPY_CORE_VERSION "bcfff4f"
3535
#define MICROPY_CORE_DATE "2018-03-30"
345 Bytes
Binary file not shown.
217 Bytes
Binary file not shown.
287 Bytes
Binary file not shown.
187 Bytes
Binary file not shown.
179 Bytes
Binary file not shown.
311 Bytes
Binary file not shown.
272 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)