Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wifi connection loss is not recognised (IDFGH-13307) #14234

Open
3 tasks done
christian94M opened this issue Jul 23, 2024 · 1 comment
Open
3 tasks done

Wifi connection loss is not recognised (IDFGH-13307) #14234

christian94M opened this issue Jul 23, 2024 · 1 comment
Assignees
Labels
Status: Opened Issue is new Type: Bug bugs in IDF

Comments

@christian94M
Copy link

Answers checklist.

  • I have read the documentation ESP-IDF Programming Guide and the issue is not addressed there.
  • I have updated my IDF branch (master or release) to the latest version and checked that the issue is present there.
  • I have searched the issue tracker for a similar issue and not found a similar issue.

IDF version.

v5.2.2

Espressif SoC revision.

ESP32-D0WDQ6 (revision v1.1)

Operating System used.

Windows

How did you build your project?

VS Code IDE

If you are using Windows, please specify command line type.

PowerShell

Development Kit.

NMCU-ESP32 (berry base)

Power Supply used.

USB

What is the expected behavior?

This ESP-IDF program initializes the ESP32 to connect to a Wi-Fi network as a station (STA) and, if it fails to connect after a specified number of retries, it switches to SoftAP (Access Point) mode.

What is the actual behavior?

no event handle or message after connection loss

Steps to reproduce.

  1. Step ESP32 to connect to a Wi-Fi network as a station (STA)
  2. Step shutdown the Wifi (Router, etc)
  3. Step it is not recognised that the connection is lost and no AP is created

Debug Logs.

I (4184) main_task: Returned from app_main()
I (40784) wifi:state: run -> init (8a0)
I (40784) wifi:pm stop, total sleep time: 32368745 us / 37621739 us

I (40784) wifi:<ba-del>idx:0, tid:6
I (40794) wifi:new:<1,0>, old:<1,0>, ap:<255,255>, sta:<1,0>, prof:1

 *  Task wird ausgeführt: C:\Users\ok99m\.espressif\tools\cmake\3.24.0\bin\cmake.exe -G=Ninja -DPYTHON_DEPS_CHECKED=1 -DESP_PLATFORM=1 -B=c:\Users\ok99m\VSC\ESP32\test\build -S=c:\Users\ok99m\VSC\ESP32\test 

-- Found Git: C:/Users/ok99m/.espressif/tools/idf-git/2.39.2/cmd/git.exe (found version "2.39.2.windows.1") 
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/Users/ok99m/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Users/ok99m/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Users/ok99m/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- git rev-parse returned 'fatal: not a git repository (or any of the parent directories): .git'
-- Could not use 'git describe' to determine PROJECT_VER.
-- Building ESP-IDF components for target esp32
-- Project sdkconfig file C:/Users/ok99m/VSC/ESP32/test/sdkconfig
-- Compiler supported targets: xtensa-esp-elf
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of time_t
-- Check size of time_t - done
-- Found Python3: C:/Users/ok99m/.espressif/python_env/idf5.2_py3.11_env/Scripts/python.exe (found version "3.11.2") found components: Interpreter 
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS
-- Performing Test C_COMPILER_SUPPORTS_WFORMAT_SIGNEDNESS - Success
-- App "test" version: 1
-- Adding linker script C:/Users/ok99m/VSC/ESP32/test/build/esp-idf/esp_system/ld/memory.ld
-- Adding linker script C:/Users/ok99m/VSC/ESP32/test/build/esp-idf/esp_system/ld/sections.ld.in
-- Adding linker script C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.api.ld
-- Adding linker script C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-data.ld
-- Adding linker script C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.syscalls.ld
-- Adding linker script C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
-- Adding linker script C:/Users/ok99m/esp/v5.2.2/esp-idf/components/soc/esp32/ld/esp32.peripherals.ld
-- Components: app_trace app_update bootloader bootloader_support bt cmock console cxx driver efuse esp-tls esp_adc esp_app_format esp_bootloader_format esp_coex esp_common esp_eth esp_event esp_gdbstub esp_hid esp_http_client esp_http_server esp_https_ota esp_https_server esp_hw_support esp_lcd esp_local_ctrl esp_mm esp_netif esp_netif_stack esp_partition esp_phy esp_pm esp_psram esp_ringbuf esp_rom esp_system esp_timer esp_wifi espcoredump esptool_py fatfs freertos hal heap http_parser idf_test ieee802154 json log lwip main mbedtls mqtt newlib nvs_flash nvs_sec_provider openthread partition_table perfmon protobuf-c protocomm pthread sdmmc soc spi_flash spiffs tcp_transport ulp unity usb vfs wear_levelling wifi_provisioning wpa_supplicant xtensa
-- Component paths: C:/Users/ok99m/esp/v5.2.2/esp-idf/components/app_trace C:/Users/ok99m/esp/v5.2.2/esp-idf/components/app_update C:/Users/ok99m/esp/v5.2.2/esp-idf/components/bootloader C:/Users/ok99m/esp/v5.2.2/esp-idf/components/bootloader_support C:/Users/ok99m/esp/v5.2.2/esp-idf/components/bt C:/Users/ok99m/esp/v5.2.2/esp-idf/components/cmock C:/Users/ok99m/esp/v5.2.2/esp-idf/components/console C:/Users/ok99m/esp/v5.2.2/esp-idf/components/cxx C:/Users/ok99m/esp/v5.2.2/esp-idf/components/driver C:/Users/ok99m/esp/v5.2.2/esp-idf/components/efuse C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp-tls C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_adc C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_app_format C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_bootloader_format C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_coex C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_common C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_eth C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_event C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_gdbstub C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_hid C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_http_client C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_http_server C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_https_ota C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_https_server C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_hw_support C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_lcd C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_local_ctrl C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_mm C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_netif C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_netif_stack C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_partition C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_phy C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_pm C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_psram C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_ringbuf C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_rom C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_system C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_timer C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_wifi C:/Users/ok99m/esp/v5.2.2/esp-idf/components/espcoredump C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esptool_py C:/Users/ok99m/esp/v5.2.2/esp-idf/components/fatfs C:/Users/ok99m/esp/v5.2.2/esp-idf/components/freertos C:/Users/ok99m/esp/v5.2.2/esp-idf/components/hal C:/Users/ok99m/esp/v5.2.2/esp-idf/components/heap C:/Users/ok99m/esp/v5.2.2/esp-idf/components/http_parser C:/Users/ok99m/esp/v5.2.2/esp-idf/components/idf_test C:/Users/ok99m/esp/v5.2.2/esp-idf/components/ieee802154 C:/Users/ok99m/esp/v5.2.2/esp-idf/components/json C:/Users/ok99m/esp/v5.2.2/esp-idf/components/log C:/Users/ok99m/esp/v5.2.2/esp-idf/components/lwip C:/Users/ok99m/VSC/ESP32/test/main C:/Users/ok99m/esp/v5.2.2/esp-idf/components/mbedtls C:/Users/ok99m/esp/v5.2.2/esp-idf/components/mqtt C:/Users/ok99m/esp/v5.2.2/esp-idf/components/newlib C:/Users/ok99m/esp/v5.2.2/esp-idf/components/nvs_flash C:/Users/ok99m/esp/v5.2.2/esp-idf/components/nvs_sec_provider C:/Users/ok99m/esp/v5.2.2/esp-idf/components/openthread C:/Users/ok99m/esp/v5.2.2/esp-idf/components/partition_table C:/Users/ok99m/esp/v5.2.2/esp-idf/components/perfmon C:/Users/ok99m/esp/v5.2.2/esp-idf/components/protobuf-c C:/Users/ok99m/esp/v5.2.2/esp-idf/components/protocomm C:/Users/ok99m/esp/v5.2.2/esp-idf/components/pthread C:/Users/ok99m/esp/v5.2.2/esp-idf/components/sdmmc C:/Users/ok99m/esp/v5.2.2/esp-idf/components/soc C:/Users/ok99m/esp/v5.2.2/esp-idf/components/spi_flash C:/Users/ok99m/esp/v5.2.2/esp-idf/components/spiffs C:/Users/ok99m/esp/v5.2.2/esp-idf/components/tcp_transport C:/Users/ok99m/esp/v5.2.2/esp-idf/components/ulp C:/Users/ok99m/esp/v5.2.2/esp-idf/components/unity C:/Users/ok99m/esp/v5.2.2/esp-idf/components/usb C:/Users/ok99m/esp/v5.2.2/esp-idf/components/vfs C:/Users/ok99m/esp/v5.2.2/esp-idf/components/wear_levelling C:/Users/ok99m/esp/v5.2.2/esp-idf/components/wifi_provisioning C:/Users/ok99m/esp/v5.2.2/esp-idf/components/wpa_supplicant C:/Users/ok99m/esp/v5.2.2/esp-idf/components/xtensa
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/ok99m/VSC/ESP32/test/build

 *  Task wird ausgeführt: C:\Users\ok99m\.espressif\tools\ninja\1.11.1\ninja.exe  

[6/924] Generating ../../partition_table/partition-table.bin
Partition table binary generated. Contents:
*******************************************************************************
# ESP-IDF Partition Table
# Name, Type, SubType, Offset, Size, Flags
nvs,data,nvs,0x9000,24K,
phy_init,data,phy,0xf000,4K,
factory,app,factory,0x10000,1M,
*******************************************************************************
[612/924] Performing configure step for 'bootloader'
-- Found Git: C:/Users/ok99m/.espressif/tools/idf-git/2.39.2/cmd/git.exe (found version "2.39.2.windows.1")
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- The ASM compiler identification is GNU
-- Found assembler: C:/Users/ok99m/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Users/ok99m/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-gcc.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Users/ok99m/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/bin/xtensa-esp32-elf-g++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Building ESP-IDF components for target esp32
-- Project sdkconfig file C:/Users/ok99m/VSC/ESP32/test/sdkconfig
-- Compiler supported targets: xtensa-esp-elf
-- Looking for sys/types.h
-- Looking for sys/types.h - found
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stddef.h
-- Looking for stddef.h - found
-- Check size of time_t
-- Check size of time_t - done
-- Adding linker script C:/Users/ok99m/esp/v5.2.2/esp-idf/components/soc/esp32/ld/esp32.peripherals.ld
-- Bootloader project name: "bootloader" version: 1
-- Adding linker script C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.ld
-- Adding linker script C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.api.ld
-- Adding linker script C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_rom/esp32/ld/esp32.rom.newlib-funcs.ld
-- Adding linker script C:/Users/ok99m/esp/v5.2.2/esp-idf/components/bootloader/subproject/main/ld/esp32/bootloader.ld
-- Adding linker script C:/Users/ok99m/esp/v5.2.2/esp-idf/components/bootloader/subproject/main/ld/esp32/bootloader.rom.ld
-- Components: bootloader bootloader_support efuse esp_app_format esp_bootloader_format esp_common esp_hw_support esp_rom esp_system esptool_py freertos hal log main micro-ecc newlib partition_table soc spi_flash xtensa
-- Component paths: C:/Users/ok99m/esp/v5.2.2/esp-idf/components/bootloader C:/Users/ok99m/esp/v5.2.2/esp-idf/components/bootloader_support C:/Users/ok99m/esp/v5.2.2/esp-idf/components/efuse C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_app_format C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_bootloader_format C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_common C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_hw_support C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_rom C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esp_system C:/Users/ok99m/esp/v5.2.2/esp-idf/components/esptool_py C:/Users/ok99m/esp/v5.2.2/esp-idf/components/freertos C:/Users/ok99m/esp/v5.2.2/esp-idf/components/hal C:/Users/ok99m/esp/v5.2.2/esp-idf/components/log C:/Users/ok99m/esp/v5.2.2/esp-idf/components/bootloader/subproject/main C:/Users/ok99m/esp/v5.2.2/esp-idf/components/bootloader/subproject/components/micro-ecc C:/Users/ok99m/esp/v5.2.2/esp-idf/components/newlib C:/Users/ok99m/esp/v5.2.2/esp-idf/components/partition_table C:/Users/ok99m/esp/v5.2.2/esp-idf/components/soc C:/Users/ok99m/esp/v5.2.2/esp-idf/components/spi_flash C:/Users/ok99m/esp/v5.2.2/esp-idf/components/xtensa
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/ok99m/VSC/ESP32/test/build/bootloader
[662/924] Performing build step for 'bootloader'
[1/106] Generating project_elf_src_esp32.c
[2/106] Building C object esp-idf/xtensa/CMakeFiles/__idf_xtensa.dir/eri.c.obj
[3/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/interrupts.c.obj
[4/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/dport_access_common.c.obj
[5/106] Building C object esp-idf/xtensa/CMakeFiles/__idf_xtensa.dir/xt_trax.c.obj
[6/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/rmt_periph.c.obj
[7/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/gpio_periph.c.obj
[8/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/dport_access.c.obj
[9/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/uart_periph.c.obj
[10/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/i2s_periph.c.obj
[11/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/sdm_periph.c.obj
[12/106] Building C object CMakeFiles/bootloader.elf.dir/project_elf_src_esp32.c.obj
[13/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/pcnt_periph.c.obj
[14/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/spi_periph.c.obj
[15/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/lldesc.c.obj
[16/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/ledc_periph.c.obj
[17/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/adc_periph.c.obj
[18/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/timer_periph.c.obj
[19/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/mpi_periph.c.obj
[20/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/mcpwm_periph.c.obj
[21/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/dac_periph.c.obj
[22/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/twai_periph.c.obj
[23/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/lcd_periph.c.obj
[24/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/i2c_periph.c.obj
[25/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/sdmmc_periph.c.obj
[26/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/touch_sensor_periph.c.obj
[27/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/rtc_io_periph.c.obj
[28/106] Building C object esp-idf/soc/CMakeFiles/__idf_soc.dir/esp32/sdio_slave_periph.c.obj
[29/106] Building C object esp-idf/hal/CMakeFiles/__idf_hal.dir/hal_utils.c.obj
[30/106] Building C object esp-idf/hal/CMakeFiles/__idf_hal.dir/mmu_hal.c.obj
[31/106] Building C object esp-idf/hal/CMakeFiles/__idf_hal.dir/mpu_hal.c.obj
[32/106] Building C object esp-idf/hal/CMakeFiles/__idf_hal.dir/efuse_hal.c.obj
[33/106] Building C object esp-idf/esp_bootloader_format/CMakeFiles/__idf_esp_bootloader_format.dir/esp_bootloader_desc.c.obj
[34/106] Building C object esp-idf/hal/CMakeFiles/__idf_hal.dir/wdt_hal_iram.c.obj
[35/106] Building C object esp-idf/hal/CMakeFiles/__idf_hal.dir/esp32/efuse_hal.c.obj
[36/106] Building C object esp-idf/hal/CMakeFiles/__idf_hal.dir/esp32/cache_hal_esp32.c.obj
[37/106] Building C object esp-idf/spi_flash/CMakeFiles/__idf_spi_flash.dir/spi_flash_wrap.c.obj
[38/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_random.c.obj
[39/106] Building C object esp-idf/micro-ecc/CMakeFiles/__idf_micro-ecc.dir/uECC_verify_antifault.c.obj
[40/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_mem.c.obj
[41/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_clock_init.c.obj
[42/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/secure_boot.c.obj
[43/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_efuse.c.obj
[44/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_random_esp32.c.obj
[45/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/flash_encrypt.c.obj
[46/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/flash_partitions.c.obj
[47/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/esp32/bootloader_soc.c.obj
[48/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_common.c.obj
[49/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_common_loader.c.obj
[50/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_clock_loader.c.obj
[51/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/bootloader_flash/src/bootloader_flash.c.obj
[52/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/bootloader_flash/src/bootloader_flash_config_esp32.c.obj
[53/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/bootloader_flash/src/flash_qio_mode.c.obj
[54/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_console_loader.c.obj
[55/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_init.c.obj
[56/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/esp32/bootloader_sha.c.obj
[57/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_console.c.obj
[58/106] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/esp32/esp_efuse_fields.c.obj
[59/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_panic.c.obj
[60/106] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/esp32/esp_efuse_table.c.obj
[61/106] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/esp32/esp_efuse_utility.c.obj
[62/106] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/esp_efuse_fields.c.obj
[63/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/bootloader_utility.c.obj
[64/106] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/esp_efuse_api.c.obj
[65/106] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32/cpu_region_protect.c.obj
[66/106] Building C object esp-idf/esp_system/CMakeFiles/__idf_esp_system.dir/esp_err.c.obj
[67/106] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/esp_memory_utils.c.obj
[68/106] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/efuse_controller/keys/without_key_purposes/three_key_blocks/esp_efuse_api_key.c.obj
[69/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/esp32/bootloader_esp32.c.obj
[70/106] Building C object esp-idf/bootloader_support/CMakeFiles/__idf_bootloader_support.dir/src/esp_image_format.c.obj
[71/106] Building C object esp-idf/efuse/CMakeFiles/__idf_efuse.dir/src/esp_efuse_utility.c.obj
[72/106] Building C object esp-idf/esp_rom/CMakeFiles/__idf_esp_rom.dir/patches/esp_rom_sys.c.obj
[73/106] Building C object esp-idf/esp_rom/CMakeFiles/__idf_esp_rom.dir/patches/esp_rom_crc.c.obj
[74/106] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/cpu.c.obj
[75/106] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32/rtc_init.c.obj
[76/106] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32/chip_info.c.obj
[77/106] Building ASM object esp-idf/esp_rom/CMakeFiles/__idf_esp_rom.dir/patches/esp_rom_longjmp.S.obj
[78/106] Building C object esp-idf/esp_rom/CMakeFiles/__idf_esp_rom.dir/patches/esp_rom_efuse.c.obj
[79/106] Building C object esp-idf/esp_common/CMakeFiles/__idf_esp_common.dir/src/esp_err_to_name.c.obj
[80/106] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32/rtc_sleep.c.obj
[81/106] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32/rtc_time.c.obj
[82/106] Building C object esp-idf/esp_rom/CMakeFiles/__idf_esp_rom.dir/patches/esp_rom_uart.c.obj
[83/106] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32/rtc_clk_init.c.obj
[84/106] Building C object esp-idf/log/CMakeFiles/__idf_log.dir/log_noos.c.obj
[85/106] Building C object esp-idf/main/CMakeFiles/__idf_main.dir/bootloader_start.c.obj
[86/106] Building C object esp-idf/log/CMakeFiles/__idf_log.dir/log_buffers.c.obj
[87/106] Building C object esp-idf/log/CMakeFiles/__idf_log.dir/log.c.obj
[88/106] Building C object esp-idf/esp_hw_support/CMakeFiles/__idf_esp_hw_support.dir/port/esp32/rtc_clk.c.obj
[89/106] Building C object esp-idf/esp_rom/CMakeFiles/__idf_esp_rom.dir/patches/esp_rom_spiflash.c.obj
[90/106] Linking C static library esp-idf\log\liblog.a
[91/106] Linking C static library esp-idf\esp_rom\libesp_rom.a
[92/106] Linking C static library esp-idf\esp_common\libesp_common.a
[93/106] Linking C static library esp-idf\esp_hw_support\libesp_hw_support.a
[94/106] Linking C static library esp-idf\esp_system\libesp_system.a
[95/106] Linking C static library esp-idf\efuse\libefuse.a
[96/106] Linking C static library esp-idf\bootloader_support\libbootloader_support.a
[97/106] Linking C static library esp-idf\esp_bootloader_format\libesp_bootloader_format.a
[98/106] Linking C static library esp-idf\spi_flash\libspi_flash.a
[99/106] Linking C static library esp-idf\hal\libhal.a
[100/106] Linking C static library esp-idf\micro-ecc\libmicro-ecc.a
[101/106] Linking C static library esp-idf\soc\libsoc.a
[102/106] Linking C static library esp-idf\xtensa\libxtensa.a
[103/106] Linking C static library esp-idf\main\libmain.a
[104/106] Linking C executable bootloader.elf
[105/106] Generating binary image from built executable
esptool.py v4.7.0
Creating esp32 image...
Merged 2 ELF sections
Successfully created esp32 image.
Generated C:/Users/ok99m/VSC/ESP32/test/build/bootloader/bootloader.bin
[106/106] cmd.exe /C "cd /D C:\Users\ok99m\VSC\ESP32\test\build\bootloader\esp-idf\esptool_py && C:\Users\ok99m\.espressif\python_env\idf5.2_py3.11_env\Scripts\python.exe C:/Users/ok99m/esp/v5.2.2/esp-idf/components/partition_table/check_sizes.py --offset 0x8000 bootloader 0x1000 C:/Users/ok99m/VSC/ESP32/test/build/bootloader/bootloader.bin"
Bootloader binary size 0x6860 bytes. 0x7a0 bytes (7%) free.
[923/924] Generating binary image from built executable
esptool.py v4.7.0
Creating esp32 image...
Merged 2 ELF sections
Successfully created esp32 image.
Generated C:/Users/ok99m/VSC/ESP32/test/build/test.bin
[924/924] cmd.exe /C "cd /D C:\Users\ok99m\VSC\ESP32\test\build\esp-idf\esptool_py && C:\Users\ok99m\.espressif\python_env\idf5.2_py3.11_env\S...000 partition --type app C:/Users/ok99m/VSC/ESP32/test/build/partition_table/partition-table.bin C:/Users/ok99m/VSC/ESP32/test/build/test.bin 
test.bin binary size 0xbabc0 bytes. Smallest app partition is 0x100000 bytes. 0x45440 bytes (27%) free.

More Information.

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_wifi.h"
#include "esp_event.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "lwip/err.h"
#include "lwip/sys.h"
#include "esp_netif.h"

#define WIFI_SSID "TESTWIFI"
#define WIFI_PASS "Password"
#define MAX_RETRY 5

static const char *TAG = "wifi_station";

static EventGroupHandle_t s_wifi_event_group;
static int s_retry_num = 0;

#define WIFI_CONNECTED_BIT BIT0
#define WIFI_FAIL_BIT BIT1

static void wifi_init_softap(void);

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 == WIFI_EVENT && event_id == WIFI_EVENT_STA_DISCONNECTED) {
if (s_retry_num < MAX_RETRY) {
esp_wifi_connect();
s_retry_num++;
ESP_LOGI(TAG, "retry to connect to the AP");
} else {
xEventGroupSetBits(s_wifi_event_group, WIFI_FAIL_BIT);
}
ESP_LOGI(TAG, "disconnected from AP");
} else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_GOT_IP) {
ip_event_got_ip_t* event = (ip_event_got_ip_t*) event_data;
char ip_str[16]; // Buffer to store the IP address string
esp_ip4addr_ntoa(&event->ip_info.ip, ip_str, sizeof(ip_str));
ESP_LOGI(TAG, "got ip: %s", ip_str);
s_retry_num = 0;
xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
} else {
ESP_LOGI(TAG, "Here");
}
}

void wifi_init_sta(void) {
s_wifi_event_group = xEventGroupCreate();

ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
esp_netif_create_default_wifi_sta();

wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));

esp_event_handler_instance_t instance_any_id;
esp_event_handler_instance_t instance_got_ip;
ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT,
                                                    ESP_EVENT_ANY_ID,
                                                    &event_handler,
                                                    NULL,
                                                    &instance_any_id));
ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT,
                                                    IP_EVENT_STA_GOT_IP,
                                                    &event_handler,
                                                    NULL,
                                                    &instance_got_ip));

wifi_config_t wifi_config = {
    .sta = {
        .ssid = WIFI_SSID,
        .password = WIFI_PASS,
        .threshold.authmode = WIFI_AUTH_WPA2_PSK,
        .pmf_cfg = {
            .capable = true,
            .required = false
        },
    },
};
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config));
ESP_ERROR_CHECK(esp_wifi_start());

ESP_LOGI(TAG, "wifi_init_sta finished.");

EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group,
                                       WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
                                       pdFALSE,
                                       pdFALSE,
                                       portMAX_DELAY);

if (bits & WIFI_CONNECTED_BIT) {
    ESP_LOGI(TAG, "connected to ap SSID:%s password:%s",
             WIFI_SSID, WIFI_PASS);
} else if (bits & WIFI_FAIL_BIT) {
    ESP_LOGI(TAG, "Failed to connect to SSID:%s, switching to AP mode", WIFI_SSID);
    wifi_init_softap();
} else {
    ESP_LOGE(TAG, "UNEXPECTED EVENT");
}

ESP_ERROR_CHECK(esp_event_handler_instance_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, instance_got_ip));
ESP_ERROR_CHECK(esp_event_handler_instance_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, instance_any_id));
vEventGroupDelete(s_wifi_event_group);

}

static void wifi_init_softap(void) {
esp_netif_create_default_wifi_ap();

wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&cfg));

wifi_config_t wifi_config = {
    .ap = {
        .ssid = "ESP32_AP",
        .ssid_len = strlen("ESP32_AP"),
        .password = "esp32_password",
        .max_connection = 4,
        .authmode = WIFI_AUTH_WPA_WPA2_PSK
    },
};
if (strlen("esp32_password") == 0) {
    wifi_config.ap.authmode = WIFI_AUTH_OPEN;
}

ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP));
ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_AP, &wifi_config));
ESP_ERROR_CHECK(esp_wifi_start());

ESP_LOGI(TAG, "wifi_init_softap finished. SSID:%s password:%s",
         "ESP32_AP", "esp32_password");

}

void app_main(void) {
ESP_ERROR_CHECK(nvs_flash_init());
wifi_init_sta();
}

@christian94M christian94M added the Type: Bug bugs in IDF label Jul 23, 2024
@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting.

@github-actions github-actions bot changed the title Wifi connection loss is not recognised Wifi connection loss is not recognised (IDFGH-13307) Jul 23, 2024
@espressif-bot espressif-bot added the Status: Opened Issue is new label Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Opened Issue is new Type: Bug bugs in IDF
Projects
None yet
Development

No branches or pull requests

4 participants