cc3200: Trigger a new network scan when WLAN.scan() is called.
This commit is contained in:
parent
c832bde05f
commit
37337427c3
|
@ -121,6 +121,8 @@ typedef struct _wlan_obj_t {
|
||||||
|
|
||||||
#define MODWLAN_TIMEOUT_MS 5000
|
#define MODWLAN_TIMEOUT_MS 5000
|
||||||
#define MODWLAN_MAX_NETWORKS 20
|
#define MODWLAN_MAX_NETWORKS 20
|
||||||
|
#define MODWLAN_SCAN_PERIOD_S 300 // 5 minutes
|
||||||
|
#define MODWLAN_WAIT_FOR_SCAN_MS 950
|
||||||
|
|
||||||
#define ASSERT_ON_ERROR( x ) ASSERT((x) >= 0 )
|
#define ASSERT_ON_ERROR( x ) ASSERT((x) >= 0 )
|
||||||
|
|
||||||
|
@ -485,10 +487,6 @@ modwlan_Status_t wlan_sl_enable (SlWlanMode_t mode, const char *ssid, uint8_t ss
|
||||||
else {
|
else {
|
||||||
ASSERT_ON_ERROR(sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER,
|
ASSERT_ON_ERROR(sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER,
|
||||||
sizeof(ucPower), (unsigned char *)&ucPower));
|
sizeof(ucPower), (unsigned char *)&ucPower));
|
||||||
// Enable scanning every 60 seconds
|
|
||||||
uint32_t scanSeconds = 60;
|
|
||||||
ASSERT_ON_ERROR(sl_WlanPolicySet(SL_POLICY_SCAN , MODWLAN_SL_SCAN_ENABLE, (_u8 *)&scanSeconds, sizeof(scanSeconds)));
|
|
||||||
|
|
||||||
if (mode == ROLE_P2P) {
|
if (mode == ROLE_P2P) {
|
||||||
// Switch to P2P mode
|
// Switch to P2P mode
|
||||||
ASSERT_ON_ERROR(sl_WlanSetMode(mode));
|
ASSERT_ON_ERROR(sl_WlanSetMode(mode));
|
||||||
|
@ -916,6 +914,13 @@ STATIC mp_obj_t wlan_scan(mp_obj_t self_in) {
|
||||||
uint8_t _index = 0;
|
uint8_t _index = 0;
|
||||||
mp_obj_t nets = NULL;
|
mp_obj_t nets = NULL;
|
||||||
|
|
||||||
|
// trigger a new newtork scanning
|
||||||
|
uint32_t scanSeconds = MODWLAN_SCAN_PERIOD_S;
|
||||||
|
ASSERT_ON_ERROR(sl_WlanPolicySet(SL_POLICY_SCAN , MODWLAN_SL_SCAN_ENABLE, (_u8 *)&scanSeconds, sizeof(scanSeconds)));
|
||||||
|
|
||||||
|
// wait for the scan to be completed
|
||||||
|
HAL_Delay (MODWLAN_WAIT_FOR_SCAN_MS);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (sl_WlanGetNetworkList(_index++, 1, &wlanEntry) <= 0) {
|
if (sl_WlanGetNetworkList(_index++, 1, &wlanEntry) <= 0) {
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue