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.

LAUNCHXL-CC3235SF: sl_WlanPolicySet causes subsequent failure to connect to AP

Part Number: LAUNCHXL-CC3235SF

Hello,

I would like to do a period WiFi scan while connected to an AP.  However, when I enable the policy, it causes the failure to connect to an AP (it does do a scan, though!):

sl_WlanPolicySet(SL_WLAN_POLICY_SCAN, SL_WLAN_SCAN_POLICY(1,1), (unsigned char*)&scanInterval, sizeof(scanInterval));

I need to disable the policy, then it connects:

sl_WlanPolicySet(SL_WLAN_POLICY_SCAN, SL_WLAN_DISABLE_SCAN, 0, 0);

Because policy set writes to flash, I don't want to do it often.  Therefore, is there a good solution to this that doesn't require writing to flash all the time?

Thanks!

  • Hi Fred,

    Setting the scan policy should not cause the device to fail to connect to an AP. What error are you getting? Can you share a snippet of your code when this occurs?

    Best regards,

    Sarah

  • Hi, Sarah,

    There is no error, the device simply won't connect to the AP anymore.  Very odd. 

    However, I think I can set the non-persistence flag so that the changes are not written to flash:


    sl_WlanPolicySet(SL_WLAN_POLICY_SCAN, SL_WLAN_SCAN_POLICY(1,0) | SL_WLAN_CONN_POLICY_NON_PERSISTENT_FLAG, (unsigned char*)&scanInterval, sizeof(scanInterval));

    and

    sl_WlanPolicySet(SL_WLAN_POLICY_SCAN, SL_WLAN_DISABLE_SCAN | SL_WLAN_CONN_POLICY_NON_PERSISTENT_FLAG, 0, 0);

    Therefore, I can do those commands before and after every scan without wearing out the flash (at least that is my thinking).  That should protect the flash, is that right? 

    Thanks again!

  • Hi Fred,

    I do not suggest you work around this issue. We should debug why you are unable to connect to an AP.

    Are you already connected to an AP when you start the scan policy? How are you determining that you are unable to connect? Are you using a connection policy? Do you have your async handlers printing incoming events to a terminal?

    Best regards,

    Sarah

  • Thanks for having me take another look, Sarah.  I moved this statement to after the NWP is started:

    scanInterval = 60;

    retval = sl_WlanPolicySet(SL_WLAN_POLICY_SCAN, SL_WLAN_SCAN_POLICY(1,0), (unsigned char*)&scanInterval, sizeof(scanInterval));

    Now, it doesn't disconnect from the AP. 

    However, a strange thing: it updates the results only once.  Subsequent reads reproduce the previous results...

  • Hi Fred,

    sl_WlanPolicySet() starts the periodic scan policy, but your application has to call sl_WlanGetNetworkList() to retrieve the latest results. See the Scan Policy section of the NWP Programmer's Guide for details.

    Also keep in mind the list won't update until your next scan interval, and old results will not drop off ("age") until 2x the scan interval.

    Best regards,

    Sarah

  • Thanks, again, Sarah.  I am glad you pushed me a bit because I found that I was toggle the NWP at an inopportune spot.  That's what was causing the network disconnect.  So, the root cause is now known for that.

    However, even if I set scanInterval = 60 (at least I think the parameter is in seconds!), and check the scan results every few minutes (using sl_WlanGetNetworkList), it never gets updated.  However, when I do the finagling that I specified above, it works Ok.  So, it's a bit of a mystery.  Unfortunately, I don't think there is a way to dig into the NWP to see what it's doing.  That is the curse of hiding all the good stuff: it makes it easy at times, and not so easy at other times!

    Cheers,

    Fred.