Commit 60ccb41f authored by Bill Owens's avatar Bill Owens Committed by Paul Sokolovsky
Browse files

esp8266: Move status() from esp module to network

parent 06593fb0
......@@ -509,11 +509,6 @@ void error_check(bool status, const char *msg) {
}
}
STATIC mp_obj_t esp_status() {
return MP_OBJ_NEW_SMALL_INT(wifi_station_get_connect_status());
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_status_obj, esp_status);
STATIC mp_obj_t esp_phy_mode(mp_uint_t n_args, const mp_obj_t *args) {
if (n_args == 0) {
return mp_obj_new_int(wifi_get_phy_mode());
......@@ -568,7 +563,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_flash_id_obj, esp_flash_id);
STATIC const mp_map_elem_t esp_module_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_esp) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_status), (mp_obj_t)&esp_status_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_mac), (mp_obj_t)&esp_mac_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_getaddrinfo), (mp_obj_t)&esp_getaddrinfo_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_phy_mode), (mp_obj_t)&esp_phy_mode_obj },
......@@ -591,19 +585,6 @@ STATIC const mp_map_elem_t esp_module_globals_table[] = {
MP_OBJ_NEW_SMALL_INT(LIGHT_SLEEP_T) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_SLEEP_MODEM),
MP_OBJ_NEW_SMALL_INT(MODEM_SLEEP_T) },
{ MP_OBJ_NEW_QSTR(MP_QSTR_STAT_IDLE),
MP_OBJ_NEW_SMALL_INT(STATION_IDLE)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_STAT_CONNECTING),
MP_OBJ_NEW_SMALL_INT(STATION_CONNECTING)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_STAT_WRONG_PASSWORD),
MP_OBJ_NEW_SMALL_INT(STATION_WRONG_PASSWORD)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_STAT_NO_AP_FOUND),
MP_OBJ_NEW_SMALL_INT(STATION_NO_AP_FOUND)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_STAT_CONNECT_FAIL),
MP_OBJ_NEW_SMALL_INT(STATION_CONNECT_FAIL)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_STAT_GOT_IP),
MP_OBJ_NEW_SMALL_INT(STATION_GOT_IP)},
#endif
};
......
......@@ -71,6 +71,13 @@ STATIC mp_obj_t esp_disconnect() {
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_disconnect_obj, esp_disconnect);
#define MODNETWORK_INCLUDE_CONSTANTS (1)
STATIC mp_obj_t esp_status() {
return MP_OBJ_NEW_SMALL_INT(wifi_station_get_connect_status());
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(esp_status_obj, esp_status);
STATIC void esp_scan_cb(scaninfo *si, STATUS status) {
struct bss_info *bs;
if (si->pbss) {
......@@ -107,7 +114,23 @@ STATIC const mp_map_elem_t mp_module_network_globals_table[] = {
{ MP_OBJ_NEW_QSTR(MP_QSTR_WLAN), (mp_obj_t)&get_module_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_connect), (mp_obj_t)&esp_connect_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_disconnect), (mp_obj_t)&esp_disconnect_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_status), (mp_obj_t)&esp_status_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_scan), (mp_obj_t)&esp_scan_obj },
#if MODNETWORK_INCLUDE_CONSTANTS
{ MP_OBJ_NEW_QSTR(MP_QSTR_STAT_IDLE),
MP_OBJ_NEW_SMALL_INT(STATION_IDLE)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_STAT_CONNECTING),
MP_OBJ_NEW_SMALL_INT(STATION_CONNECTING)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_STAT_WRONG_PASSWORD),
MP_OBJ_NEW_SMALL_INT(STATION_WRONG_PASSWORD)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_STAT_NO_AP_FOUND),
MP_OBJ_NEW_SMALL_INT(STATION_NO_AP_FOUND)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_STAT_CONNECT_FAIL),
MP_OBJ_NEW_SMALL_INT(STATION_CONNECT_FAIL)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_STAT_GOT_IP),
MP_OBJ_NEW_SMALL_INT(STATION_GOT_IP)},
#endif
};
STATIC MP_DEFINE_CONST_DICT(mp_module_network_globals, mp_module_network_globals_table);
......
......@@ -56,8 +56,6 @@ Q(esp)
Q(socket)
Q(connect)
Q(disconnect)
Q(scan)
Q(status)
Q(phy_mode)
Q(sleep_type)
Q(deepsleep)
......@@ -85,12 +83,6 @@ Q(onconnect)
Q(onrecv)
Q(onsent)
Q(ondisconnect)
Q(STAT_IDLE)
Q(STAT_CONNECTING)
Q(STAT_WRONG_PASSWORD)
Q(STAT_NO_AP_FOUND)
Q(STAT_CONNECT_FAIL)
Q(STAT_GOT_IP)
Q(MODE_11B)
Q(MODE_11G)
Q(MODE_11N)
......@@ -101,6 +93,14 @@ Q(SLEEP_MODEM)
// network module
Q(network)
Q(WLAN)
Q(scan)
Q(status)
Q(STAT_IDLE)
Q(STAT_CONNECTING)
Q(STAT_WRONG_PASSWORD)
Q(STAT_NO_AP_FOUND)
Q(STAT_CONNECT_FAIL)
Q(STAT_GOT_IP)
// Pin class
Q(Pin)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment