I have added the following to port/esp8266/modnetwork.c
Code: Select all
// XXX-START
STATIC mp_obj_t esp_force_modem_sleep() {
wifi_station_disconnect();
wifi_set_opmode(NULL_MODE); //set wifi mode to null mode.
wifi_fpm_set_sleep_type(MODEM_SLEEP_T); //set force sleep type
wifi_fpm_open(); //enable force sleep function
return mp_obj_new_int(wifi_fpm_do_sleep(0xFFFFFFF)); //sleep until manual wakeup
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_force_modem_sleep_obj,esp_force_modem_sleep);
// XXX-END
And built and flashed the firmware, however I don't see the function listed in the network module ?
Code: Select all
>>> dir(network)
['__class__', '__name__', 'AP_IF', 'AUTH_OPEN', 'AUTH_WEP', 'AUTH_WPA2_PSK', 'AUTH_WPA_PSK', 'AUTH_WPA_WPA2_PSK', 'MODE_11B', 'MODE_11G', 'MODE_11N', 'STAT_CONNECTING', 'STAT_CONNECT_FAIL', 'STAT_GOT_IP', 'STAT_IDLE', 'STAT_NO_AP_FOUND', 'STAT_WRONG_PASSWORD', 'STA_IF', 'WLAN', 'phy_mode']
>>> dir(network.WLAN())
['__class__', 'active', 'config', 'connect', 'disconnect', 'ifconfig', 'isconnected', 'scan', 'status']
>>>
I guess that I am missing something ?
UPDATE
Yes, I needed to add this:
Code: Select all
{ MP_ROM_QSTR(MP_QSTR_force_modem_sleep), MP_ROM_PTR(&esp_force_modem_sleep_obj) },