Skip to content

Commit ac19ecf

Browse files
authored
On app cpu (#1)
* move loop task to APP CPU * Rework WiFi boot so it works when loop is on APP CPU
1 parent b89cf41 commit ac19ecf

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

cores/esp32/main.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@ void initVariant() {}
77
void init() __attribute__((weak));
88
void init() {}
99

10-
void bootWiFi() __attribute__((weak));
11-
void bootWiFi() {}
10+
void startWiFi() __attribute__((weak));
11+
void startWiFi() {}
12+
13+
void initWiFi() __attribute__((weak));
14+
void initWiFi() {}
1215

1316
extern void loop();
1417
extern void setup();
@@ -18,7 +21,7 @@ void loopTask(void *pvParameters)
1821
bool setup_done = false;
1922
for(;;) {
2023
if(!setup_done) {
21-
bootWiFi();
24+
startWiFi();
2225
setup();
2326
setup_done = true;
2427
}
@@ -30,6 +33,7 @@ extern "C" void app_main()
3033
{
3134
init();
3235
initVariant();
33-
xTaskCreatePinnedToCore(loopTask, "loopTask", 4096, NULL, 1, NULL, 0);
36+
initWiFi();
37+
xTaskCreatePinnedToCore(loopTask, "loopTask", 4096, NULL, 1, NULL, 1);
3438
}
3539

libraries/WiFi/src/WiFiGeneric.cpp

+10-18
Original file line numberDiff line numberDiff line change
@@ -286,29 +286,21 @@ void wifi_dns_found_callback(const char *name, const ip_addr_t *ipaddr, void *ca
286286
* */
287287
#include "nvs_flash.h"
288288

289-
void bootWiFi()
289+
void initWiFi()
290290
{
291-
esp_err_t err;
292-
wifi_init_config_t cfg;
293-
wifi_mode_t mode = WIFI_MODE_NULL;
294-
bool auto_connect = false;
295-
296-
err = nvs_flash_init();
297-
if (err != ESP_OK) {
298-
log_e("nvs_flash_init fail %d", err);
299-
return;
300-
}
301-
291+
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
292+
nvs_flash_init();
302293
system_init();
303294
tcpip_adapter_init();
304295
esp_event_loop_init(WiFiGenericClass::_eventCallback, NULL);
296+
esp_wifi_init(&cfg);
297+
}
305298

306-
cfg.event_handler = &esp_event_send;
307-
err = esp_wifi_init(&cfg);
308-
if (err != ESP_OK) {
309-
log_e("esp_wifi_init fail %d\n", err);
310-
return;
311-
}
299+
void startWiFi()
300+
{
301+
esp_err_t err;
302+
wifi_mode_t mode = WIFI_MODE_NULL;
303+
bool auto_connect = false;
312304

313305
err = esp_wifi_start();
314306
if (err != ESP_OK) {

0 commit comments

Comments
 (0)