due to unsynchronized threads for connect and mqtt
the following changes resolved the issue for me:
I used the 'original' startup / wifi connect code from the esp-idf samples (here: 03-http)
and added a sync so the mqtt thread does not start before the network is set up properly:
void app_main()
{
nvs_flash_init();
system_init();
initialise_wifi();
//xTaskCreate(&http_get_task, "http_get_task", 2048, NULL, 5, NULL);
/* Wait for the callback to set the CONNECTED_BIT in the
event group.
*/
xEventGroupWaitBits(wifi_event_group, CONNECTED_BIT,
false, true, portMAX_DELAY);
ESP_LOGI(TAG, "Connected to AP");
// Notice that, all callback will called in mqtt_task
// All function publish, subscribe
mqtt_start(&settings);
}
The original code stops at:
[APP] Startup.. [APP] Free memory: 262052 bytes [APP] SDK version: 1.0.0(3e67f0f), Build time: 2016-Nov-04_10:46:54_EET [APP] Start, connect to Wifi network: Shirkan .. /work/esp32/esp-idf/components/freertos/./queue.c:716 (xQueueGenericSend)- assert failed! Guru Meditation Error: Core 0 panic'ed (Unhandled debug exception)
due to unsynchronized threads for connect and mqtt
the following changes resolved the issue for me: I used the 'original' startup / wifi connect code from the esp-idf samples (here: 03-http) and added a sync so the mqtt thread does not start before the network is set up properly: