使用cc3200例程scan-polic可以扫描网络,能够获取正确的ssid和rssi,但当使用TI-RTOS时,创建任务运行WlanScan时,不能获取正确的RSSI,而ssid第一个是对的,下面的都是空的。请TI的专家指导下,谢谢!!
main函数如下:硬件初始化代码略去
lRetVal = VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY);
if(lRetVal < 0)
{
ERR_PRINT(lRetVal);
Message(" VStartSimpleLinkSpawnTask error\r\n");
LOOP_FOREVER();
}
lRetVal = osi_TaskCreate(WlanScan,(const signed char *)"wlan",OSI_STACK_SIZE,NULL,1,NULL );
if(lRetVal < 0)
{
ERR_PRINT(lRetVal);
Message(" osi_TaskCreate error\r\n");
LOOP_FOREVER();
}
osi_start();
}
扫描函数如下:
void WlanScan(void *pvParameters)
{
long lRetVal = -1;
unsigned short ucIndex;
unsigned char ucpolicyOpt;
union
{
unsigned char ucPolicy[4];
unsigned int uiPolicyLen;
}policyVal;
InitializeAppVariables();
lRetVal = ConfigureSimpleLinkToDefaultState();
if(lRetVal < 0)
{
if (DEVICE_NOT_IN_STATION_MODE == lRetVal)
{
UART_PRINT("Failed to configure the device in its default state\n\r");
}
}
UART_PRINT("Device is configured in default state \n\r");
lRetVal = sl_Start(0, 0, 0);
if (lRetVal < 0 || ROLE_STA != lRetVal)
{
UART_PRINT("Failed to start the device \n\r");
}
UART_PRINT("Device started as STATION \n\r");
ucpolicyOpt = SL_CONNECTION_POLICY(0, 0, 0, 0,0);
lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION , ucpolicyOpt, NULL, 0);
if(lRetVal != 0)
{
UART_PRINT("Unable to clear the Connection Policy\n\r");
}
ucpolicyOpt = SL_SCAN_POLICY(1);
policyVal.uiPolicyLen = 10;
lRetVal = sl_WlanPolicySet(SL_POLICY_SCAN , ucpolicyOpt,(unsigned char*)(policyVal.ucPolicy), sizeof(policyVal));
if(lRetVal!=0)
{
UART_PRINT("Unable to set the Scan Policy\n\r");
}
MAP_UtilsDelay(8000000);
while(1)
{
ucIndex = 0;
memset(netEntries, 0, sizeof(netEntries));
lRetVal = sl_WlanGetNetworkList(ucIndex, (unsigned char)WLAN_SCAN_COUNT,&netEntries[ucIndex]);
if(lRetVal==0)
{
UART_PRINT("Unable to retreive the network list\n\r");
}
for(ucIndex=0;ucIndex<lRetVal;ucIndex++)
{
UART_PRINT("ssid:%s\n\r",netEntries[ucIndex].ssid);
UART_PRINT("rssi:%d\n\r",netEntries[ucIndex].rssi);
}
MAP_UtilsDelay(8000000);
}
}
lin zhang12:
回复 Yonghua Pan:
#define WLAN_SCAN_COUNT 20
lin zhang12:
回复 Yonghua Pan:
程序上和WLAN_SCAN_COUNT等变量的设置上没有问题,我重新安装了SDK,并重新引入工程,把原来的代码拷贝过去就可以了,也许我把SDK中的某个库文件给修改了。谢谢。
zhangying Yan:
回复 lin zhang12:
表示遇到了同样的问题,请问你有重建SDK驱动程序库么?