From main.c, I call the starting functions in both event_loop.c and spiffs.c. This is what my code for event_loop.c looks like:
Code: Select all
ESP_EVENT_DEFINE_BASE(CUSTOM_EVENT);
static void event_loop_event_handler(void* arg, esp_event_base_t event_base,
int32_t event_id, void* event_data)
{if (event_base == CUSTOM_EVENT){
switch (event_id) {
case SPIFFSDONE:
ESP_LOGI(TAG, "Done with spiffs.");
wifi_provision();
break;
case WIFIDONE:
ESP_LOGI(TAG, "Done with wifi_prov.");
break;
}
}
}
/* Initialize the event loop */
void event_loop_start(void){
ESP_ERROR_CHECK(esp_event_loop_create_default());
ESP_ERROR_CHECK(esp_event_handler_instance_register(CUSTOM_EVENT, ESP_EVENT_ANY_ID, event_handler1, NULL, NULL));
}
Code: Select all
ESP_ERROR_CHECK(esp_event_post(CUSTOM_EVENT, SPIFFSDONE, NULL, 0, 0));
and starts wifi_provision() from wifi_prov_mgr.c.Done with spiffs
However, when wifi_provision.c posts CUSTOM_EVENT/WIFIDONE to the default loop
Code: Select all
esp_event_post(CUSTOM_EVENT, WIFIDONE, NULL, 0, 0);
The odd part is that if I call wifi_provision() in wifi_prov_mgr.c directly from main.c, it's CUSTOM_EVENT (WIFIDONE) event is recognized by the event_loop_event_handler function in event_loop.c and the function printsDone with wifi_prov
.Done with wifi_prov
Can someone help me figure out why event_loop_event_handler() isn't able to recognize the CUSTOM_EVENT WIFIDONE event posted by wifi_prov_mgr.c when wifi_provision() is called directly from event_loop.c instead of main.c?