Using an event group static EventGroupHandle_t tcpserver_event_group; //Create it tcpserver_event_group = xEventGroupCreate(); //Set the state when say a connection happens or is lost xEventGroupSetBits(tcpserver_event_group, CONNECTED_BIT); xEventGroupClearBits(tcpserver_event_group, CONNECTED_BIT); //Wait for connected xEventGroupWaitBits(tcpserver_event_group, CONNECTED_BIT, false, true, portMAX_DELAY); //Stalls (with timeout)
Category: Events
Event handler
You can subscribe to be notified of ESP events using this In your initialise ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) ); Event handler fucntion //*************************************** //*************************************** //********** ESP EVENT HANDLER ********** //*************************************** //*************************************** //Call this at startup: //ESP_ERROR_CHECK( esp_event_loop_init(event_handler, NULL) ); static esp_err_t event_handler(void *ctx, system_event_t *event) { switch(event->event_id) { case SYSTEM_EVENT_STA_START: //WiFi connected break; case SYSTEM_EVENT_STA_GOT_IP: //WiFi […]