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.

The device will not auto connect to an AP from stored profiles in station mode

Dear all

I can get SL_WLAN_CONNECT_EVENT and SL_NETAPP_IPV4_IPACQUIRED_EVENT after my device connect to an AP.

Then I try the following test in order to check the reconnect capability.

1. power off my AP.

2. the device will receive SL_WLAN_DISCONNECT_EVENT

3. power on my AP

Because I already set auto connect policy( using sl_WlanPolicySet) at the beginning.

Therefore I suppost that I could get SL_WLAN_CONNECT_EVENT after my AP is power on.

below is the code flow :

1. sl_start(0,0,0) to init device

2. sl_WlanProfileDel(0xFF) to make sure there is only one AP information by the following ProfileAdd function call

3. sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1, 0,0,0,0), NULL, 0) set AUTO connect policy

3. sl_WlanProfileAdd add one AP information

4. Get SL_WLAN_CONNECT_EVENT after my device connect to an AP

5. Get SL_WLAN_DISCONNECT_EVENT after I power off my AP

6. NO SL_WLAN_CONNECT_EVENT when I powr on my AP

From the spec, the device should try to connect to an AP from the stored profile after setting sl_WlanPolicySet.

How should I set in order to enable AUTO reconnect capabiility ?

Thank you

Veloso

  • Veloso,

    I'll check it on my setup and get back. Which SP and SDK version are you on? And, did you modify the scan cycle/interval?

    -/Praneet
  • Hi Praneet

    Thanks for you help
    My SDK version is 1.0.0.1
    Howver I am not sure what my SP version is.
    Thyerefore I try to get it from sl_DevGet:
    NWP: 2.0.7.0
    FW: 0.0.4.1

    And I do not use any scan policy in my project.

    Veloso
  • Veloso,

    You are on an older version of SP - Suggest you upgrade to the latest.

    I was not able to reproduce the issue w/ the latest package. Below is the code-snippet and the logs

    static long SetConnectionPolicy()
    
    {
    
       unsigned char policyVal;
    
       long lRetVal = -1;
    
       /* Clear all stored profiles and reset the policies */
    
       lRetVal = sl_WlanProfileDel(0xFF);
    
       ASSERT_ON_ERROR(lRetVal);
    
       lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(0,0,0,0,0), 0, 0);
    
       ASSERT_ON_ERROR(lRetVal);
    
       //Add Profile
    
       /* user needs to change SSID_NAME = "<Secured AP>"
    
                SECURITY_TYPE = SL_SEC_TYPE_WPA
    
                SECURITY_KEY = "<password>"
    
         and set the priority as per requirement
    
         to connect with a secured AP */
    
       SlSecParams_t secParams;
    
       secParams.Key = SECURITY_KEY;
    
       secParams.KeyLen = strlen(SECURITY_KEY);
    
       secParams.Type = SECURITY_TYPE;
    
       lRetVal = sl_WlanProfileAdd(SSID_NAME,strlen(SSID_NAME),0,&secParams,0,1,0);
    
       ASSERT_ON_ERROR(lRetVal);
    
       //set AUTO policy
    
       lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION,
    
                         SL_CONNECTION_POLICY(1,0,0,0,0),
    
                         &policyVal, 1 /*PolicyValLen*/);
    
       ASSERT_ON_ERROR(lRetVal);
    
       while(1)
    
       {
    
           //wait until IP is acquired
    
           while((!IS_CONNECTED(g_ulStatus)) || (!IS_IP_ACQUIRED(g_ulStatus)))
    
           {
    
               _SlNonOsMainLoopTask();
    
           }
    
           UART_PRINT("\n\r===>>> Device connected to AP\n\r");
    
           // Wait
    
           while(IS_CONNECTED(g_ulStatus))
    
           {
    
               _SlNonOsMainLoopTask();
    
           }
    
           CLR_STATUS_BIT(g_ulStatus, STATUS_BIT_CONNECTION);
    
           CLR_STATUS_BIT(g_ulStatus, STATUS_BIT_IP_AQUIRED);
    
           UART_PRINT("\n\r===>>> Device disconnected from AP\n\r");
    
       }
    
    }

    
    		 *************************************************
    		           CC3200 CONNECTION_POLICY Application       
    		 *************************************************
    
    
    
    Host Driver Version: 1.0.0.1
    Build Version 2.2.0.1.31.1.2.0.2.1.0.3.23
    Device is configured in default state 
    Device started as STATION 
    [WLAN EVENT] STA Connected to the AP: TP-LINK-APK2 ,BSSID: a0:f3:c1:b1:d6:6e
    [NETAPP EVENT] IP Acquired: IP=192.168.0.100 , Gateway=192.168.0.1
    
    ===>>> Device connected to AP
    [WLAN ERROR]Device disconnected from the AP AP: TP-LINK-APK2,BSSID: a0:f3:c1:b1:d6:6e on an ERROR..!! 
    
    ===>>> Device disconnected from AP
    [WLAN EVENT] STA Connected to the AP: TP-LINK-APK2 ,BSSID: a0:f3:c1:b1:d6:6e
    [NETAPP EVENT] IP Acquired: IP=192.168.0.100 , Gateway=192.168.0.1
    
    ===>>> Device connected to AP
    [WLAN ERROR]Device disconnected from the AP AP: TP-LINK-APK2,BSSID: a0:f3:c1:b1:d6:6e on an ERROR..!! 
    
    ===>>> Device disconnected from AP
    [WLAN EVENT] STA Connected to the AP: TP-LINK-APK2 ,BSSID: a0:f3:c1:b1:d6:6e
    [WLAN ERROR]Device disconnected from the AP AP: TP-LINK-APK2,BSSID: a0:f3:c1:b1:d6:6e on an ERROR..!! 
    [WLAN EVENT] STA Connected to the AP: TP-LINK-APK2 ,BSSID: a0:f3:c1:b1:d6:6e
    [NETAPP EVENT] IP Acquired: IP=192.168.0.100 , Gateway=192.168.0.1
    
    ===>>> Device connected to AP
    [WLAN ERROR]Device disconnected from the AP AP: TP-LINK-APK2,BSSID: a0:f3:c1:b1:d6:6e on an ERROR..!! 
    
    ===>>> Device disconnected from AP
    [WLAN EVENT] STA Connected to the AP: TP-LINK-APK2 ,BSSID: a0:f3:c1:b1:d6:6e
    [NETAPP EVENT] IP Acquired: IP=192.168.0.100 , Gateway=192.168.0.1
    
    ===>>> Device connected to AP
    

    -/Praneet

  • Veloso,

    Hope the snippet helps.
    I'm closing this thread - Please let me know if you need additional information. I suggest you open a new thread w/ references to the current one for us to track it better.

    -/Praneet