nrf5340/nrf7002 Connecting to wifi : ends up in blocked state consuming 60mA current?

nrf5340+nrf7002 running Zephyr with NCS v2.6.x. 

When trying to connect to a wifi AP with incorrect credentials, I have several issues:

1/ the result of the (failed) connect request always returns 10s later, no matter the value of 'timeout' in the wifi_connect_req_params structure passed to the net_mgmt request.

- shouldn't it use the timeout value?

2/ the result, returned as event NET_EVENT_WIFI_CONNECT_RESULT in a net_mgmt callback handler, doesn't give me a 'result' I can use?

How do I find out that the connection  attempt failed? I tried checking the 'state' of the connection by doing a NET_REQUEST_WIFI_IFACE_STATUS, but it shows the state as being 'WIFI_STATE_ASSOCIATED', which the wifi demo code uses to indicate the wifi is connected!

(I can clearly see that the attempt has stopped after 10s because the power consumpion drops back to 5-6mA, instead of around 60mA)

3/ if I do not explicltly disconnect after the failed attempt, the stack continually retries the connection every 30s, and appears to have a memory leak of about 120 bytes at eash attempt... leading eventually to a hang because it exhausts the heap...

To avoid this, I added a 'connect timer' in my code, which does an explicit NET_REQUEST_WIFI_DISCONNECT after X seconds. This stops the automatic retry, and lets my code retry the connect at its own pace....

However:

4/ After a few attempts (<10, one every 3 minutes), the wifi stack seems to get in a bad state, and the power consumption sticks at 60mA average! (as though it was still trying to connect to the AP)

I get this log:

[00:57:24.123,870] <err> wifi_nrf: nrf_wifi_wpa_supp_scan_abort: Timedout waiting for scan abort response, ret = -11

Requesting a disconnect operation is accepted by the wifi stack but has no apparent affect on the power consumption. And it doesn't then accept a connect attempt with valid credentials after getting in this state. Could this be because I force disconnect when its still trying to connect?

Any pointers on how to get this to be more robust?

thanks

Parents
  • When it runs out of memory, the logs:

    [14:23:55.279,052] <err> wifi_nrf: umac_cmd_alloc: Failed to allocate UMAC cmd
    [14:23:55.286,895] <err> wifi_nrf: umac_cmd_cfg: umac_cmd_alloc failed
    [14:23:55.294,067] <err> wifi_nrf: nrf_wifi_wpa_set_supp_port: nrf_wifi_fmac_chg_sta failed
    [14:23:56.303,741] <err> wifi_nrf: nrf_wifi_fmac_scan: Unable to allocate memory
    [14:23:56.311,737] <err> wifi_nrf: nrf_wifi_wpa_supp_scan2: Scan trigger failed

    And the memory:

    [14:24:03.500,335] <inf> app: System Stats: Heap now : free 1580, used 67112, max used 68040.

    Just after boot, free is around 13000, and is stable when the wifi is connected.

Reply
  • When it runs out of memory, the logs:

    [14:23:55.279,052] <err> wifi_nrf: umac_cmd_alloc: Failed to allocate UMAC cmd
    [14:23:55.286,895] <err> wifi_nrf: umac_cmd_cfg: umac_cmd_alloc failed
    [14:23:55.294,067] <err> wifi_nrf: nrf_wifi_wpa_set_supp_port: nrf_wifi_fmac_chg_sta failed
    [14:23:56.303,741] <err> wifi_nrf: nrf_wifi_fmac_scan: Unable to allocate memory
    [14:23:56.311,737] <err> wifi_nrf: nrf_wifi_wpa_supp_scan2: Scan trigger failed

    And the memory:

    [14:24:03.500,335] <inf> app: System Stats: Heap now : free 1580, used 67112, max used 68040.

    Just after boot, free is around 13000, and is stable when the wifi is connected.

Children
No Data
Related