disable wifi

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

disable wifi

Post by devnull » Fri Nov 09, 2018 5:59 am

https://github.com/micropython/micropyt ... -436992805

Damien confirms that it is possible to disable the wifi at runtime on the 8266.

But having no knowledge of C or C++, how would I go about implementing the code that he has suggested so that I can switch the radio off?

Code: Select all

void wifi_fpm_open(void);
void wifi_fpm_close(void);
void wifi_fpm_do_wakeup(void);
sint8 wifi_fpm_do_sleep(uint32 sleep_time_in_us);
void wifi_fpm_set_sleep_type(enum sleep_type type);
enum sleep_type wifi_fpm_get_sleep_type(void);
Last edited by devnull on Wed Nov 28, 2018 5:33 am, edited 1 time in total.

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: disable wifi using C functions

Post by devnull » Fri Nov 09, 2018 6:52 am

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) },

jickster
Posts: 629
Joined: Thu Sep 07, 2017 8:57 pm

Re: disable wifi using C functions

Post by jickster » Fri Nov 09, 2018 6:48 pm

So is the issue solved?


Sent from my iPhone using Tapatalk Pro

jomas
Posts: 59
Joined: Mon Dec 25, 2017 1:48 pm
Location: Netherlands

Re: disable wifi using C functions

Post by jomas » Wed Nov 14, 2018 11:20 pm

See my post in viewtopic.php?f=16&t=1927 how to disable the RF module.

User avatar
devnull
Posts: 473
Joined: Sat Jan 07, 2017 1:52 am
Location: Singapore / Cornwall
Contact:

Re: disable wifi

Post by devnull » Wed Nov 28, 2018 5:34 am

Thanks so much Damien, disabling the wifi radio is now possible:

https://github.com/micropython/micropyt ... -442277874

And it is persistent.

Post Reply