This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3301: How to obtain the reasons for WiFi connecting failure

Part Number: CC3301

Hi,

In Rtos sdk, we call Wlan_Connect() to connect to AP,  if successful, the host will recevie WLAN_EVENT_CONNECT event,  if failed, the host will get nothing but timeout.

so we can't get the reason of failure. Is there any method which we can get the reason code of connecting failure.

Thanks.

  • You will get reason code only upon disconnection.

  • You can use 802.11 sniffer  to check the failure in the connection or send us an NWP log.

  • What we want is to know the failure's reason code in the program, such as the wrong key.

    and when connect fails, there is no disconnect event.

  • You should get disconnect indication for most such cases. 

    Do you have anything specific where you don't see the disconnect event?

  • You can see below code come from your sdk, only when timeout, we can know connect failed, and don't know the detail reason, is there other method to know the connect failed not timeout. actually when timeout, it will call Wlan_Disconnect(), this will get a disconnect event, but the reason code always is 

    WLAN_DISCONNECT_USER_INITIATED(200).  
    We can see many reasoncodes about disconnect are defined in wlan_if.h,  my question is how can we get these reasoncodes about connection failed,
    #define WLAN_DISCONNECT_STA_NOT_AUTH                                        (9)
    #define WLAN_DISCONNECT_INVALID_PAIRWISE_CIPHER                             (19)
    #define WLAN_DISCONNECT_USER_INITIATED                                      (200)
    #define WLAN_DISCONNECT_AUTH_TIMEOUT                                        (202)
    #define WLAN_DISCONNECT_ASSOC_TIMEOUT                                       (203)
    #define WLAN_DISCONNECT_SECURITY_FAILURE                                    (204)
    #define WLAN_DISCONNECT_WHILE_CONNNECTING                                   (208)
    #define WLAN_DISCONNECT_MISSING_CERT                                        (209)
    #define WLAN_DISCONNECT_CERTIFICATE_EXPIRED                                 (210)

        /* Connect to AP */
        ret = Wlan_Connect((const signed char *)(ConnectParams.ssid),
                           strlen((const char *)(ConnectParams.ssid)),
                           NULL,
                           ConnectParams.secParams.Type,
                           (const char *)(ConnectParams.secParams.Key),
                           ((ConnectParams.secParams.Key != NULL) ? strlen((const char *)ConnectParams.secParams.Key) : 0));

        ASSERT_AND_CLEAN_CONNECT(ret, WLAN_ERROR, &ConnectParams);


        /* Wait for connection events:
         * In order to verify that connection was successful,
         * we pend on two incoming events: Connected and Ip acquired.
         * The semaphores below are pend by this (Main) context.
         * They will be signaled once an asynchronous event
         * Indicating that the NWP has connected and acquired IP address is raised.
         * For further information, see this application read me file.
         */
        if(!IS_STA_CONNECTED(app_CB.Status))
        {
            ret = osi_SyncObjWait(&app_CB.CON_CB.connectEventSyncObj,
                                   WLAN_EVENT_TOUT);
            if(ret == TIMEOUT_SEM)
            {
                UART_PRINT("\n\r[wlanconnect] : Timeout expired connecting to AP: %s\n\r",
                           ConnectParams.ssid);
                Wlan_Disconnect();
                FreeConnectCmd(&ConnectParams);
                return(-1);
            }
        }


        FreeConnectCmd(&ConnectParams);
        return(0);

  • ok. we will need to check this.

    I think that for most of the errors you should expect the disconnection event with the real error code (at least the ones that invoke 802.11 disconnection event).

    The timeout is for the cases where the AP did not respond. If that is not the case - we will fix it. 

  • Did you get a Disconnection event (i.e. the event handler registered with Wlan_Start - you should receive event WLAN_EVENT_DISCONNECT and the parameters (WlanEventDisconnect_t) should include the reasoncode)

  • I registered an event handler with Wlan_Start, if connect success, I can get WLAN_EVENT_CONNECT event, buf if connect failed, I can't get

    WLAN_EVENT_DISCONNECT event.
  • I was able to reproduce this. 

    Indeed there are cases where you only get the timeout without getting a DISCONNECTION with error code.

    We'll debug this and provide a fix in one of the next releases.