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

esp8266: Added wifi_mode() to read and set WiFi operating mode.

parent a160b70c
......@@ -509,6 +509,16 @@ void error_check(bool status, const char *msg) {
}
}
STATIC mp_obj_t esp_wifi_mode(mp_uint_t n_args, const mp_obj_t *args) {
if (n_args == 0) {
return mp_obj_new_int(wifi_get_opmode());
} else {
wifi_set_opmode(mp_obj_get_int(args[0]));
return mp_const_none;
}
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_wifi_mode_obj, 0, 1, esp_wifi_mode);
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());
......@@ -565,6 +575,7 @@ STATIC const mp_map_elem_t esp_module_globals_table[] = {
{ 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_wifi_mode), (mp_obj_t)&esp_wifi_mode_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_phy_mode), (mp_obj_t)&esp_phy_mode_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_sleep_type), (mp_obj_t)&esp_sleep_type_obj },
{ MP_OBJ_NEW_QSTR(MP_QSTR_deepsleep), (mp_obj_t)&esp_deepsleep_obj },
......@@ -585,6 +596,13 @@ 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_STA_MODE),
MP_OBJ_NEW_SMALL_INT(STATION_MODE)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_AP_MODE),
MP_OBJ_NEW_SMALL_INT(SOFTAP_MODE)},
{ MP_OBJ_NEW_QSTR(MP_QSTR_STA_AP_MODE),
MP_OBJ_NEW_SMALL_INT(STATIONAP_MODE)},
#endif
};
......
......@@ -56,6 +56,7 @@ Q(esp)
Q(socket)
Q(connect)
Q(disconnect)
Q(wifi_mode)
Q(phy_mode)
Q(sleep_type)
Q(deepsleep)
......@@ -89,6 +90,9 @@ Q(MODE_11N)
Q(SLEEP_NONE)
Q(SLEEP_LIGHT)
Q(SLEEP_MODEM)
Q(STA_MODE)
Q(AP_MODE)
Q(STA_AP_MODE)
// network module
Q(network)
......
Supports Markdown
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