Search found 10 matches

by alexandre
Thu Jan 11, 2024 2:51 pm
Forum: ESP-IDF
Topic: Failed to check if wifi was connected
Replies: 4
Views: 40829

Re: Failed to check if wifi was connected

I created a function in wifi.c that receives a pointer. The pointer would work like a traffic light and, if there was a WiFi connection, its value would change to 1. The function was called in the main function app_main(), which passes the address of the pointer. But for some reason the function is ...
by alexandre
Wed Jan 10, 2024 1:37 pm
Forum: ESP-IDF
Topic: Failed to check if wifi was connected
Replies: 4
Views: 40829

Re: Failed to check if wifi was connected

I need to ensure that the code only progresses if the Wi-Fi is connected https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/wifi.html#wifi-programming-model The WiFi stack uses the default event loop to publish events like DISCONNECT or GOT_IP to the application. If you want to ...
by alexandre
Tue Jan 09, 2024 10:09 pm
Forum: ESP-IDF
Topic: Failed to check if wifi was connected
Replies: 4
Views: 40829

Failed to check if wifi was connected

Hello friends, how are you? I can't check if the wifi is connected, even though it is connected. My main routine is basically: void app_main(void) { // initialization SPIFFS // initialization NVS wifi_event_group = xEventGroupCreate(); ESP_LOGI(TAG, "ESP_WIFI_MODE_STA"); wifi_init_sta(wifi_ssid, wif...
by alexandre
Wed Aug 23, 2023 12:30 am
Forum: ESP-IDF
Topic: Code not go forward after "xEventGroupWaitBits"
Replies: 9
Views: 5141

Re: Code not go forward after "xEventGroupWaitBits"

Hello friends! My problem remains unresolved, so I decided to post it on espressif's github. To follow just follow the link: https://github.com/espressif/esp-idf/issues/12121
by alexandre
Sat Aug 19, 2023 2:41 pm
Forum: ESP-IDF
Topic: Code not go forward after "xEventGroupWaitBits"
Replies: 9
Views: 5141

Re: Code not go forward after "xEventGroupWaitBits"

1. If your code doesn't progress to after xEventGroupWaitBits you need to double check that a) xEventGroupSetBits is actually called on the event group you're waiting on and b) xEventGroupSetBits actually sets at least one of the bits you give to xEventGroupWaitBits. In your case, the press of a bu...
by alexandre
Sat Aug 19, 2023 1:50 am
Forum: ESP-IDF
Topic: Code not go forward after "xEventGroupWaitBits"
Replies: 9
Views: 5141

Re: Code not go forward after "xEventGroupWaitBits"

But for some reason, the condition... is not satisfied. The reason is that xTicksToWait = 1000 / portTICK_PERIOD_MS causes txEventGroupWaitBits to time out and return after 1 second when no even bits are set. And you want to pass xClearOnExit as pdTRUE to the function, else the bits never get clear...
by alexandre
Thu Aug 17, 2023 8:14 pm
Forum: ESP-IDF
Topic: Code not go forward after "xEventGroupWaitBits"
Replies: 9
Views: 5141

Re: Code not go forward after "xEventGroupWaitBits"

Since the issue was not resolved, I made another change. The code needs to go to the switch and wait for the user to press the button. So I changed portMAX_DELAY by xTickToWait const TickType_t xTicksToWait = 1000 / portTICK_PERIOD_MS; EventBits_t uxBits = xEventGroupWaitBits(s_wifi_event_group, WIF...
by alexandre
Thu Aug 17, 2023 7:52 pm
Forum: ESP-IDF
Topic: Code not go forward after "xEventGroupWaitBits"
Replies: 9
Views: 5141

Re: Code not go forward after "xEventGroupWaitBits"

Hello ESP_Sprite! Thanks for the answer! Yes, the bits are set in the function: static void event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, void* event_data) { if (event_base == WIFI_EVENT && event_id == WIFI_EVENT_STA_START) { esp_wifi_connect(); } else if (event_base == WI...
by alexandre
Thu Aug 17, 2023 4:18 pm
Forum: ESP-IDF
Topic: Code not go forward after "xEventGroupWaitBits"
Replies: 9
Views: 5141

Re: Code not go forward after "xEventGroupWaitBits"

Well, to start with, do you have any function that sets those event group bits? If you don't, the task will never proceed past that. Hello ESP_Sprite! Thanks for the answer! Yes, the bits are set in the function: static void event_handler(void* arg, esp_event_base_t event_base, int32_t event_id, vo...
by alexandre
Wed Aug 16, 2023 5:51 pm
Forum: ESP-IDF
Topic: Code not go forward after "xEventGroupWaitBits"
Replies: 9
Views: 5141

Code not go forward after "xEventGroupWaitBits"

Hello makers! My code does not go forward after function EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group, WIFI_CONNECTED_BIT | WIFI_FAIL_BIT, pdFALSE, pdFALSE, portMAX_DELAY); Everything seems to be going well, the device receives an IP and is connected to WI-FI. The function runs, returns...