Skip to content

Commit 7378c50

Browse files
committed
esp8266: Move wifi_mode() and phy_mode() to network module.
1 parent 9e8396a commit 7378c50

2 files changed

Lines changed: 22 additions & 22 deletions

File tree

esp8266/modesp.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -512,26 +512,6 @@ void error_check(bool status, const char *msg) {
512512
}
513513
}
514514

515-
STATIC mp_obj_t esp_wifi_mode(mp_uint_t n_args, const mp_obj_t *args) {
516-
if (n_args == 0) {
517-
return mp_obj_new_int(wifi_get_opmode());
518-
} else {
519-
wifi_set_opmode(mp_obj_get_int(args[0]));
520-
return mp_const_none;
521-
}
522-
}
523-
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_wifi_mode_obj, 0, 1, esp_wifi_mode);
524-
525-
STATIC mp_obj_t esp_phy_mode(mp_uint_t n_args, const mp_obj_t *args) {
526-
if (n_args == 0) {
527-
return mp_obj_new_int(wifi_get_phy_mode());
528-
} else {
529-
wifi_set_phy_mode(mp_obj_get_int(args[0]));
530-
return mp_const_none;
531-
}
532-
}
533-
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_phy_mode_obj, 0, 1, esp_phy_mode);
534-
535515
STATIC mp_obj_t esp_sleep_type(mp_uint_t n_args, const mp_obj_t *args) {
536516
if (n_args == 0) {
537517
return mp_obj_new_int(wifi_get_sleep_type());
@@ -596,8 +576,6 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_flash_erase_obj, esp_flash_erase);
596576
STATIC const mp_map_elem_t esp_module_globals_table[] = {
597577
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_esp) },
598578

599-
{ MP_OBJ_NEW_QSTR(MP_QSTR_wifi_mode), (mp_obj_t)&esp_wifi_mode_obj },
600-
{ MP_OBJ_NEW_QSTR(MP_QSTR_phy_mode), (mp_obj_t)&esp_phy_mode_obj },
601579
{ MP_OBJ_NEW_QSTR(MP_QSTR_sleep_type), (mp_obj_t)&esp_sleep_type_obj },
602580
{ MP_OBJ_NEW_QSTR(MP_QSTR_deepsleep), (mp_obj_t)&esp_deepsleep_obj },
603581
{ MP_OBJ_NEW_QSTR(MP_QSTR_flash_id), (mp_obj_t)&esp_flash_id_obj },

esp8266/modnetwork.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,31 @@ const mp_obj_type_t wlan_if_type = {
203203
.locals_dict = (mp_obj_t)&wlan_if_locals_dict,
204204
};
205205

206+
STATIC mp_obj_t esp_wifi_mode(mp_uint_t n_args, const mp_obj_t *args) {
207+
if (n_args == 0) {
208+
return mp_obj_new_int(wifi_get_opmode());
209+
} else {
210+
wifi_set_opmode(mp_obj_get_int(args[0]));
211+
return mp_const_none;
212+
}
213+
}
214+
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_wifi_mode_obj, 0, 1, esp_wifi_mode);
215+
216+
STATIC mp_obj_t esp_phy_mode(mp_uint_t n_args, const mp_obj_t *args) {
217+
if (n_args == 0) {
218+
return mp_obj_new_int(wifi_get_phy_mode());
219+
} else {
220+
wifi_set_phy_mode(mp_obj_get_int(args[0]));
221+
return mp_const_none;
222+
}
223+
}
224+
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_phy_mode_obj, 0, 1, esp_phy_mode);
225+
206226
STATIC const mp_map_elem_t mp_module_network_globals_table[] = {
207227
{ MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_network) },
208228
{ MP_OBJ_NEW_QSTR(MP_QSTR_WLAN), (mp_obj_t)&get_wlan_obj },
229+
{ MP_OBJ_NEW_QSTR(MP_QSTR_wifi_mode), (mp_obj_t)&esp_wifi_mode_obj },
230+
{ MP_OBJ_NEW_QSTR(MP_QSTR_phy_mode), (mp_obj_t)&esp_phy_mode_obj },
209231

210232
#if MODNETWORK_INCLUDE_CONSTANTS
211233
{ MP_OBJ_NEW_QSTR(MP_QSTR_STAT_IDLE),

0 commit comments

Comments
 (0)