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

W (42148) wifi:m f null Getting This warning and then wifi is never reconnected in the execution #448

Closed
Rahul14singh opened this issue Mar 28, 2024 · 1 comment

Comments

@Rahul14singh
Copy link

Rahul14singh commented Mar 28, 2024

Using esp-wifi on esp32 Kaluga Board

Code :

#define EXAMPLE_ESP_WIFI_SSID      "SSID"
#define EXAMPLE_ESP_WIFI_PASS      "PASS"

#define EXAMPLE_ESP_MAXIMUM_RETRY  CONFIG_ESP_MAXIMUM_RETRY

#define MAX_HTTP_RECV_BUFFER 512
#define MAX_HTTP_OUTPUT_BUFFER 2048

#if CONFIG_ESP_WPA3_SAE_PWE_HUNT_AND_PECK
#define ESP_WIFI_SAE_MODE WPA3_SAE_PWE_HUNT_AND_PECK
#define EXAMPLE_H2E_IDENTIFIER ""
#elif CONFIG_ESP_WPA3_SAE_PWE_HASH_TO_ELEMENT
#define ESP_WIFI_SAE_MODE WPA3_SAE_PWE_HASH_TO_ELEMENT
#define EXAMPLE_H2E_IDENTIFIER CONFIG_ESP_WIFI_PW_ID
#elif CONFIG_ESP_WPA3_SAE_PWE_BOTH
#define ESP_WIFI_SAE_MODE WPA3_SAE_PWE_BOTH
#define EXAMPLE_H2E_IDENTIFIER CONFIG_ESP_WIFI_PW_ID
#endif
#if CONFIG_ESP_WIFI_AUTH_OPEN
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_OPEN
#elif CONFIG_ESP_WIFI_AUTH_WEP
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WEP
#elif CONFIG_ESP_WIFI_AUTH_WPA_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_PSK
#elif CONFIG_ESP_WIFI_AUTH_WPA2_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_PSK
#elif CONFIG_ESP_WIFI_AUTH_WPA_WPA2_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA_WPA2_PSK
#elif CONFIG_ESP_WIFI_AUTH_WPA3_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA3_PSK
#elif CONFIG_ESP_WIFI_AUTH_WPA2_WPA3_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WPA2_WPA3_PSK
#elif CONFIG_ESP_WIFI_AUTH_WAPI_PSK
#define ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD WIFI_AUTH_WAPI_PSK
#endif

#define CONFIG_EXAMPLE_RMT_TX_GPIO 45
#define CONFIG_EXAMPLE_STRIP_LED_NUMBER 1

#define WIFI_CONNECTED_BIT BIT0
#define WIFI_FAIL_BIT      BIT1

#define IMAGE_MAX_SIZE (100 * 1024)/**< The maximum size of a single picture in the boot animation */
#define IMAGE_WIDTH    320 /*!< width of jpeg file */
#define IMAGE_HEIGHT    240 /*!< height of jpeg file */
#define portTICK_RATE_MS 10

#define MAX_NAME_LENGTH 64
#define MAX_PRICE_LENGTH 5

#define DEFAULT_VREF    1100                            /*!< Use adc2_vref_to_gpio() to obtain a better estimate */
#define NO_OF_SAMPLES   64
#define SAMPLE_TIME     200
#define DEVIATION 0.1

#define AVG_SAMPLES   10
#define GPIO_DATA   GPIO_NUM_19
#define GPIO_SCLK   GPIO_NUM_20


static const char *TAG = "SMART_TROLLEY";

/* FreeRTOS event group to signal when we are connected*/
static EventGroupHandle_t s_wifi_event_group;

static int s_retry_num = 0;

static const adc_channel_t channel = ADC_CHANNEL_5;     /*!< PIO7 if ADC1, GPIO17 if ADC2 */
static const adc_bits_width_t width = ADC_BITWIDTH_13;

static const adc_atten_t atten = ADC_ATTEN_DB_11;
static const adc_unit_t unit = ADC_UNIT_1;
static QueueHandle_t adc_queue = NULL;

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 < EXAMPLE_ESP_MAXIMUM_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,"connect to the AP fail");
    } 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;
        ESP_LOGI(TAG, "got ip:" IPSTR, IP2STR(&event->ip_info.ip));
        s_retry_num = 0;
        xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT);
    }
}

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 = EXAMPLE_ESP_WIFI_SSID,
            .password = EXAMPLE_ESP_WIFI_PASS,
            /* Authmode threshold resets to WPA2 as default if password matches WPA2 standards (pasword len => 8).
             * If you want to connect the device to deprecated WEP/WPA networks, Please set the threshold value
             * to WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK and set the password with length and format matching to
             * WIFI_AUTH_WEP/WIFI_AUTH_WPA_PSK standards.
             */
            .threshold.authmode = ESP_WIFI_SCAN_AUTH_MODE_THRESHOLD,
            .sae_pwe_h2e = ESP_WIFI_SAE_MODE,
            .sae_h2e_identifier = EXAMPLE_H2E_IDENTIFIER,
        },
    };
    ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA) );
    ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config) );
    ESP_ERROR_CHECK(esp_wifi_start() );

    ESP_LOGI(TAG, "wifi_init_sta finished.");

    /* Waiting until either the connection is established (WIFI_CONNECTED_BIT) or connection failed for the maximum
     * number of re-tries (WIFI_FAIL_BIT). The bits are set by event_handler() (see above) */
    EventBits_t bits = xEventGroupWaitBits(s_wifi_event_group,
            WIFI_CONNECTED_BIT | WIFI_FAIL_BIT,
            pdFALSE,
            pdFALSE,
            portMAX_DELAY);

    /* xEventGroupWaitBits() returns the bits before the call returned, hence we can test which event actually
     * happened. */
    if (bits & WIFI_CONNECTED_BIT) {
        ESP_LOGI(TAG, "connected to ap SSID:%s password:%s",
                 EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS);
    } else if (bits & WIFI_FAIL_BIT) {
        ESP_LOGI(TAG, "Failed to connect to SSID:%s, password:%s",
                 EXAMPLE_ESP_WIFI_SSID, EXAMPLE_ESP_WIFI_PASS);
    } else {
        ESP_LOGE(TAG, "UNEXPECTED EVENT");
    }
}

This was working fine as I had used the same code earlier but after a few days I am running this project with this code and now I am running into the following issue:

I (23) boot: ESP-IDF v5.1.2 2nd stage bootloader
I (24) boot: compile time Mar 28 2024 05:40:43
I (24) boot: chip revision: v0.0
I (27) qio_mode: Enabling default flash chip QIO
I (32) boot.esp32s2: SPI Speed : 80MHz
I (37) boot.esp32s2: SPI Mode : QIO
I (42) boot.esp32s2: SPI Flash Size : 4MB
I (47) boot: Enabling RNG early entropy source...
I (52) boot: Partition Table:
I (56) boot: ## Label Usage Type ST Offset Length
I (63) boot: 0 nvs WiFi data 01 02 00009000 00006000
I (70) boot: 1 phy_init RF data 01 01 0000f000 00001000
I (78) boot: 2 factory factory app 00 00 00010000 00177000
I (85) boot: End of partition table
I (90) esp_image: segment 0: paddr=00010020 vaddr=3f000020 size=5c58ch (378252) map
I (163) esp_image: segment 1: paddr=0006c5b4 vaddr=3ffcce40 size=03a64h ( 14948) load
I (166) esp_image: segment 2: paddr=00070020 vaddr=40080020 size=baa8ch (764556) map
I (300) esp_image: segment 3: paddr=0012aab4 vaddr=3ffd08a4 size=00d28h ( 3368) load
I (301) esp_image: segment 4: paddr=0012b7e4 vaddr=40026000 size=16e3ch ( 93756) load
I (338) boot: Loaded app from partition at offset 0x10000
I (338) boot: Disabling RNG early entropy source...
I (350) cpu_start: Unicore app
I (350) cache: Instruction cache : size 8KB, 4Ways, cache line size 32Byte
I (352) cache: Data cache : size 16KB, 4Ways, cache line size 32Byte
I (360) esp_psram: Found 2MB PSRAM device
I (364) esp_psram: Speed: 80MHz
I (368) cpu_start: Pro cpu up.
I (591) esp_psram: SPI SRAM memory test OK
I (604) cpu_start: Pro cpu start user code
I (604) cpu_start: cpu freq: 240000000 Hz
I (604) cpu_start: Application information:
I (607) cpu_start: Project name: smart_trolley
I (613) cpu_start: App version: 32e5bf0-dirty
I (618) cpu_start: Compile time: Mar 28 2024 05:40:35
I (624) cpu_start: ELF file SHA256: c2556580cac24dbd...
I (630) cpu_start: ESP-IDF: v5.1.2
I (635) cpu_start: Min chip rev: v0.0
I (640) cpu_start: Max chip rev: v1.99
I (645) cpu_start: Chip rev: v0.0
I (650) heap_init: Initializing. RAM available for dynamic allocation:
I (657) heap_init: At 3FFD68F8 len 00025708 (149 KiB): DRAM
I (663) heap_init: At 3FFFC000 len 00003A10 (14 KiB): DRAM
I (669) heap_init: At 3FF9E000 len 00001FE8 (7 KiB): RTCRAM
I (676) esp_psram: Adding pool of 2048K of PSRAM memory to heap allocator
I (683) spi_flash: detected chip: generic
I (687) spi_flash: flash io: qio
W (695) rmt(legacy): legacy driver is deprecated, please migrate to driver/rmt_tx.h and/or driver/rmt_rx.h
W (726) ADC: legacy driver is deprecated, please migrate to esp_adc/adc_oneshot.h
I (726) app_start: Starting scheduler on CPU0
I (728) main_task: Started on CPU0
I (728) esp_psram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (738) main_task: Calling app_main()
I (748) SMART_TROLLEY: ESP_WIFI_MODE_STA
I (748) main_task: Returned from app_main()
I (768) wifi:wifi driver task: 3ffd8ee8, prio:23, stack:3584, core=0
I (768) wifi:wifi firmware version: 91b9630
I (768) wifi:wifi certification version: v7.0
I (768) wifi:config NVS flash: enabled
I (768) wifi:config nano formating: disabled
I (778) wifi:Init data frame dynamic rx buffer num: 32
I (778) wifi:Init static rx mgmt buffer num: 5
I (778) wifi:Init management short buffer num: 32
I (788) wifi:Init static tx buffer num: 16
I (788) wifi:Init tx cache buffer num: 32
I (798) wifi:Init static rx buffer size: 1600
I (798) wifi:Init static rx buffer num: 10
I (798) wifi:Init dynamic rx buffer num: 32
I (808) wifi_init: rx ba win: 6
I (808) wifi_init: tcpip mbox: 32
I (818) wifi_init: udp mbox: 6
I (818) wifi_init: tcp mbox: 6
I (818) wifi_init: tcp tx win: 5744
I (828) wifi_init: tcp rx win: 5744
I (828) wifi_init: tcp mss: 1440
I (838) wifi_init: WiFi IRAM OP enabled
I (838) wifi_init: WiFi RX IRAM OP enabled
I (848) phy_init: phy_version 2401,2a6dc26,Sep 26 2023,11:22:15
W (848) phy_init: failed to load RF calibration data (0x1102), falling back to full calibration
I (898) wifi:mode : sta (7c:df:a1:02:9c:a4)
I (898) wifi:enable tsf
I (908) SMART_TROLLEY: wifi_init_sta finished.
I (1518) wifi:new:<6,0>, old:<1,0>, ap:<255,255>, sta:<6,0>, prof:1
I (1758) wifi:state: init -> auth (b0)
I (1758) wifi:state: auth -> assoc (0)
I (1768) wifi:state: assoc -> run (10)
I (1778) wifi:connected with VM6193248_2.4GHz, aid = 35, channel 6, BW20, bssid = d0:cf:0e:c5:d9:b5
I (1778) wifi:security: WPA2-PSK, phy: bgn, rssi: -39
I (1788) wifi:pm start, type: 1

I (1798) wifi:AP's beacon interval = 102400 us, DTIM period = 1
I (2118) wifi:idx:0 (ifx:0, d0:cf:0e:c5:d9:b5), tid:0, ssn:1, winSize:64
I (3288) esp_netif_handlers: sta ip: 192.168.0.170, mask: 255.255.255.0, gw: 192.168.0.1
I (3288) SMART_TROLLEY: got ip:192.168.0.170
I (3288) SMART_TROLLEY: connected to ap SSID:VM6193248_2.4GHz password:XYZ
I (3298) SMART_TROLLEY: Weight Sensor Initiated
I (3298) gpio: GPIO[20]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (3308) gpio: GPIO[19]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (6268) gpio: GPIO[6]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (6268) gpio: GPIO[11]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (6268) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (6278) gpio: GPIO[16]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 0| Intr:0
I (6288) lcd: lcd_buffer_size: 2048, lcd_dma_size: 1024, lcd_dma_node_cnt: 2

I (6598) lcd: ST7789 init...

I (6598) lcd: lcd init ok

I (6598) SMART_TROLLEY: LCD Initiated
I (12678) app_peripherals: Camera module is ESP-S2-KALUGA
I (12678) gpio: GPIO[2]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:2
I (12678) cam_hal: cam init ok
I (12678) sccb: pin_sda 8 pin_scl 7
I (12688) sccb: sccb_i2c_port=1
I (12698) camera: Detected camera at address=0x30
I (12698) camera: Detected OV2640 camera
I (12698) camera: Camera PID=0x26 VER=0x42 MIDL=0x7f MIDH=0xa2
I (12788) s2 ll_cam: node_size: 3840, nodes_per_line: 1, lines_per_node: 8
I (12788) s2 ll_cam: dma_half_buffer_min: 3840, dma_half_buffer: 11520, lines_per_half_buffer: 24, dma_buffer_size: 23040
I (12798) cam_hal: buffer_size: 23040, half_buffer_size: 11520, node_buffer_size: 3840, node_cnt: 6, total_cnt: 10
I (12808) cam_hal: Allocating 115200 Byte frame buffer in PSRAM
I (12808) cam_hal: Allocating 115200 Byte frame buffer in PSRAM
I (12818) cam_hal: cam config ok
I (12818) ov2640: Set PLL: clk_2x: 1, clk_div: 3, pclk_auto: 1, pclk_div: 8
cam_hal: EV-VSYNC-OVF
I (13788) SMART_TROLLEY: Weight Reading: 15

I (13788) SMART_TROLLEY: Initial Weight: 15
I (13788) SMART_TROLLEY: LCD Initiated
I (15838) SMART_TROLLEY: Initializing RMT ...
I (15838) SMART_TROLLEY: LED -> white
W (31088) wifi:m f null

W (42248) wifi:m f null

I (42298) wifi:state: run -> init (4c0)
I (42298) wifi:pm stop, total sleep time: 26402756 us / 40509588 us

I (42298) wifi:idx:0, tid:0
I (42298) wifi:new:<6,0>, old:<6,0>, ap:<255,255>, sta:<6,0>, prof:1
W (42308) wifi:m f probe req l=0

I (42308) SMART_TROLLEY: retry to connect to the AP
I (42308) SMART_TROLLEY: connect to the AP fail
I (42358) wifi:new:<6,0>, old:<6,0>, ap:<255,255>, sta:<6,0>, prof:1
I (42358) wifi:state: init -> auth (b0)
W (42358) wifi:m f auth

I (43358) wifi:state: auth -> init (200)
I (43358) wifi:new:<6,0>, old:<6,0>, ap:<255,255>, sta:<6,0>, prof:1
W (43358) wifi:m f probe req l=0

I (43358) SMART_TROLLEY: retry to connect to the AP
I (43358) SMART_TROLLEY: connect to the AP fail
W (43478) wifi:m f probe req l=0

W (43598) wifi:m f probe req l=0

W (43718) wifi:m f probe req l=0

I have tried a lot of things like updating the components to the latest and playing around with partitions but am unable to figure out.

Also sometimes like flashing the same image repeatedly, it's working without issue and sometimes it breaks like this right from the start.

Any help or suggestions!!
Thanks 👍

@bjoernQ
Copy link
Contributor

bjoernQ commented Mar 28, 2024

Hello! This is the repository for bare-metal Rust WiFi and BLE support. You probably want to open this issue in https://github.com/espressif/esp-idf

Closing this

@bjoernQ bjoernQ closed this as completed Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

No branches or pull requests

2 participants