我在一个TASK中开启了Wlan扫描策略,每隔5s扫描一次,在以后的代码里面都没有disable scan
{
unsigned char policyOpt;
unsigned long IntervalVal = 5;
int lRetVal;
policyOpt = SL_SCAN_POLICY(1);
lRetVal = sl_WlanPolicySet(SL_POLICY_SCAN , policyOpt,
(unsigned char *)(IntervalVal), sizeof(IntervalVal));
}
{
int lRetVal;
// The scan results are occupied in netEntries[]
lRetVal = sl_WlanGetNetworkList(0, SCAN_TABLE_SIZE, netEntries);
if(lRetVal == -1)
{
UART_PRINT("can not get scan results…\r\n");
}
Terry Han:
在读取RSSI信号质量的时候,需要增加一点延时,不能连续不间断的读取,在读取时候增加延时后进行读取
user4905330:
回复 Terry Han:
谢谢 Terry的回复, 我读RSSI的TASK是 每隔3s读一次,而且每次读之前都osi_Sleep了 200ms, 可是都出来的还是一样的, 感觉好像底层就没有scan。每次断开重新启动设备的时候 值才会变一次。
Terry Han:
// enable scan
//
ucpolicyOpt = SL_SCAN_POLICY(1);
//
// set scan cycle to 10 seconds
//
policyVal.uiPolicyLen = 10;
//
// set scan policy – this starts the scan
//
lRetVal = sl_WlanPolicySet(SL_POLICY_SCAN , ucpolicyOpt,
(unsigned char*)(policyVal.ucPolicy), sizeof(policyVal));
Terry Han:
回复 user4905330:
/启动扫描热点
ui_policy_inv = 5;
ucpolicy_opt = SL_SCAN_POLICY(1);
ret_val = sl_WlanPolicySet(SL_POLICY_SCAN, ucpolicy_opt, (unsigned char *)(&ui_policy_inv), sizeof(ui_policy_inv));
if(ret_val < 0){
DO_Printf("Wlan Enable Scan Policy Failure.\r\n");
goto return_point;
}开启扫描热点后,等待一段时间,让芯片内部去扫描一些结果,然后循环去查询这个结果列表
?
1
2
3
4
5
6
7
8
9
10
11
12
13i_val = 20;
while(i_val–){
vTaskDelay(1350);memset(wlan_net_entries, 0, sizeof(wlan_net_entries));
ret_val = sl_WlanGetNetworkList(i_val, (unsigned char)WLAN_MAX_NET_ENTRIE_COUNT, &wlan_net_entries[0]);
if(ret_val == 0){
return -1;//无法扫描到热点
}else{
for(j_val = 0;j_val < WLAN_MAX_FILTER_ENTRIE_COUNT;j_val++){
i8 rssi = wlan_net_entries[j_val].rssi;
}
}