Need API to turn off WiFi Radio which is in separate core

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Need API to turn off WiFi Radio which is in separate core

Postby Ritesh » Tue Dec 20, 2016 7:30 pm

Hi,

We have one requirement in which we need to either turn off WiFi Radio if it's working and on and turn on WiFi Radio if it's in OFF state but it should not create any impact or effect to running application core functionality. As I know that there are two separate cores into ESP32 chip in which one core is for Application core which is specific for tasks and application etc while another core is for WIFI/BLE core in which WiFi and BLE Radios are running.

So, does it possible to turn off WiFi Radio while module is running into AP mode or STA mode?

If yes then please provide me sample code or examples to do it something like that
Regards,
Ritesh Prajapati

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Need API to turn off WiFi Radio which is in separate core

Postby ESP_Angus » Tue Dec 20, 2016 9:34 pm

If you need to maintain the WiFi connection then the "modem sleep" mode is probably want you want. I just mentioned it in a reply to you on another post:
http://esp32.com/viewtopic.php?f=13&t=770

If you want to disable WiFi permanently, you can set the mode to NULL:

Code: Select all

esp_wifi_set_mode(WIFI_MODE_NULL);
You can call this from any task, it's managed by the RTOS and therefore thread-safe. However when you re-enable the WiFi it will need to reestablish the AP connection, get an IP address, etc. Modem sleep mode is much less disruptive.
Ritesh wrote:As I know that there are two separate cores into ESP32 chip in which one core is for Application core which is specific for tasks and application etc while another core is for WIFI/BLE core in which WiFi and BLE Radios are running.
esp-idf runs an SMP RTOS environment so the division of cores is more flexible than this. You can run application code on both cores, or you can pin tasks (like "threads" or in a full-size OS) to a particular core if necessary. RTOS primitives (queues, semaphores, etc.) allow communciation between tasks on different CPUs. The WiFi APIs are implemented like this.

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

Re: Need API to turn off WiFi Radio which is in separate core

Postby Ritesh » Wed Dec 21, 2016 5:42 pm

ESP_Angus wrote:If you need to maintain the WiFi connection then the "modem sleep" mode is probably want you want. I just mentioned it in a reply to you on another post:
http://esp32.com/viewtopic.php?f=13&t=770

If you want to disable WiFi permanently, you can set the mode to NULL:

Code: Select all

esp_wifi_set_mode(WIFI_MODE_NULL);
You can call this from any task, it's managed by the RTOS and therefore thread-safe. However when you re-enable the WiFi it will need to reestablish the AP connection, get an IP address, etc. Modem sleep mode is much less disruptive.
Ritesh wrote:As I know that there are two separate cores into ESP32 chip in which one core is for Application core which is specific for tasks and application etc while another core is for WIFI/BLE core in which WiFi and BLE Radios are running.
esp-idf runs an SMP RTOS environment so the division of cores is more flexible than this. You can run application code on both cores, or you can pin tasks (like "threads" or in a full-size OS) to a particular core if necessary. RTOS primitives (queues, semaphores, etc.) allow communciation between tasks on different CPUs. The WiFi APIs are implemented like this.
Hi, As I have checked into ESP32-IDF RTOS API and found that they have provided APIs to enter module into light sleep and deep sleep mode but not found any modem sleep enum to switch into that mode.

Do you have e any idea or any information for that?

My aim is to turn off WiFi Radio whenever required and turned it ON back whenever required from application core.

Let me know your feedback or suggestions for that..
Regards,
Ritesh Prajapati

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Need API to turn off WiFi Radio which is in separate core

Postby kolban » Wed Dec 21, 2016 9:43 pm

Might the API called esp_wifi_start() and esp_wifi_stop() be used in this case? I haven't seen any state diagrams but these sound like they will dynamically switch on and off WiFi. I have to guess that after a call to esp_wifi_stop(), there won't be any radio transmissions or receptions.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

ESP_Angus
Posts: 2344
Joined: Sun May 08, 2016 4:11 am

Re: Need API to turn off WiFi Radio which is in separate core

Postby ESP_Angus » Wed Dec 21, 2016 9:52 pm

Ritesh wrote:Hi, As I have checked into ESP32-IDF RTOS API and found that they have provided APIs to enter module into light sleep and deep sleep mode but not found any modem sleep enum to switch into that mode.
The call for modem sleep mode is esp_wifi_set_ps(), although (sorry I missed this yesterday) it's not yet supported in the esp-idf WiFi libraries (support will be added soon):

http://esp-idf.readthedocs.io/en/latest ... _ps_type_t
Ritesh wrote: My aim is to turn off WiFi Radio whenever required and turned it ON back whenever required from application core.
As mentioned in my previous reply, the critical difference is whether you want to maintain WiFi association (either from ESP32 STA to the AP, or from other STAs tothe ESP32 AP) while the WiFi radio is turned off.

If the answer is yes, the answer is modem sleep support once it becomes available.

If the answer is no, you can use the suggestions earlier in this thread (esp_wifi_start()/esp_wifi_stop() or esp_wifi_set_mode()) to disable/enable the entire WiFi stack. When you re-enable the radio it will need to reassociate with the access point.

Who is online

Users browsing this forum: Baidu [Spider] and 133 guests