微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI WIFI设计交流 > cc3200开发板的scan_policy例程

cc3200开发板的scan_policy例程

时间:10-02 整理:3721RD 点击:

怎样提高WlanScan函数的扫描速度呀?现在是11秒扫描一次,好慢呀?求解

static long WlanScan(void *pvParameters)
{
  
    long lRetVal = -1;

    unsigned short ucIndex;
    unsigned char ucpolicyOpt;
    union
    {
        unsigned char ucPolicy[4];
        unsigned int uiPolicyLen;
    }policyVal;
   
    InitializeAppVariables();

    //
    // Following function configure the device to default state by cleaning
    // the persistent settings stored in NVMEM (viz. connection profiles &
    // policies, power policy etc)
    //
    // Applications may choose to skip this step if the developer is sure
    // that the device is in its default state at start of applicaton
    //
    // Note that all profiles and persistent settings that were done on the
    // device will be lost
    //
    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");
        }
        return lRetVal;
    }

    //UART_PRINT("Device is configured in default state \n\r");

    //
    // Assumption is that the device is configured in station mode already
    // and it is in its default state
    //
    lRetVal = sl_Start(0, 0, 0);
    if (lRetVal < 0 || ROLE_STA != lRetVal)
    {
        UART_PRINT("Failed to start the device \n\r");
        return lRetVal;
    }

    //UART_PRINT("Device started as STATION \n\r");

    //
    // make sure the connection policy is not set (so no scan is run in the
    // background)
    //
    ucpolicyOpt = SL_CONNECTION_POLICY(0, 0, 0, 0,0);
    lRetVal = sl_WlanPolicySet(SL_POLICY_CONNECTION , ucpolicyOpt, NULL, 0);
    if(lRetVal != 0)
    {
        GPIO_IF_LedOn(MCU_EXECUTE_FAIL_IND);
        UART_PRINT("Unable to clear the Connection Policy\n\r");
        return lRetVal;
    }
   
    //
    // 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));
    if(lRetVal!=0)
    {
        GPIO_IF_LedOn(MCU_EXECUTE_FAIL_IND);
        UART_PRINT("Unable to set the Scan Policy\n\r");
        return lRetVal;
    }
    MAP_UtilsDelay(8000000);
    //
    // get scan results - all 20 entries in one transaction
    //
    ucIndex = 0;
    //
    // retVal indicates the valid number of entries
    // The scan results are occupied in netEntries[]
    //
    lRetVal = sl_WlanGetNetworkList(ucIndex, (unsigned char)WLAN_SCAN_COUNT,
                                    &netEntries[ucIndex]);
    if(lRetVal==0)
    {
        GPIO_IF_LedOn(MCU_EXECUTE_FAIL_IND);
        UART_PRINT("Unable to retreive the network list\n\r");
        return lRetVal;
    }
    /* put a break point here and check netEntries[] value for scan ssid list */
    //
    // get scan results - 4 transactions of 5 entries
    //
    ucIndex = 0;
    memset(netEntries, 0, sizeof(netEntries));

    do
    {
        lRetVal = sl_WlanGetNetworkList(ucIndex,
                                        (unsigned char)WLAN_SCAN_COUNT/4,
                                        &netEntries[ucIndex]);
        ucIndex += lRetVal;
    }
    while ((lRetVal == WLAN_SCAN_COUNT/4) && (ucIndex < WLAN_SCAN_COUNT));
    /* put a break point here and check netEntries[] value for scan ssid list */
    //
    // disable scan
    //
    ucpolicyOpt = SL_SCAN_POLICY(0);
    lRetVal = sl_WlanPolicySet(SL_POLICY_SCAN , ucpolicyOpt, NULL, 0);
    if(lRetVal != 0)
    {
        GPIO_IF_LedOn(MCU_EXECUTE_FAIL_IND);
        UART_PRINT("Unable to Clear the Scan Policy\n\r");
        return lRetVal;
    }


    //UART_PRINT("SUCCESS\n\r");

    return SUCCESS;
}

MAP_UtilsDelay(8000000);这是延迟了多少秒呀

80M的晶振,参数表示节拍数,你可以确定时间了

想要输出三个路由器的强度,发现延迟在(1000000)时,只能扫出1个来,延迟(5000000)时,可以全都扫出来,串口助手上显示的时间间隔为3秒,请问有没有什么办法扫描更快一点。

 你是想要扫描的频率更高吗?那可以减小下面的参数:

    // set scan cycle to 10 seconds 
    //
    policyVal.uiPolicyLen = 10;

这个参数是在哪儿定义的原型?可以设置为小数吗?

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top