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.

CC3100 connection time

Other Parts Discussed in Thread: CC3100

Hi,


We are developing a embedded low-power Wi-Fi device with CC3100 in which the battery life is a critical point. We are testing with:

CC3100BOST Rev 3.3 (XCC3100HZ)
CC31xx Service Pack 1.0.0.1.1 applied
Host Driver Version: 1.0.0.1
Build Version 2.2.7.1.31.1.2.4.2.1.5.3.23
Simple Link Studio with Eclipse 4.4.1 and CC3100 SDK v1.0.0

We are trying to hibernate the CC3100 and reconnect it to the wifi network as fast as possible. After reading SWRA462, I assume the fastest way to reconnect is with a WLAN Profile and a static IP, but we have a reconnection time of 2,5 seconds.

In every cycle, I can see with the nHIB LED:
- 2,52 second running
- 1,2 senconds hibernating

My UDP server is receiving a UDP datagram every 3.7 seconds.

The main loop is:

    while (1)
    {			
			_u8 mode = sl_Start(0, pConfig, 0);

			SlSecParams_t g_SecParams;
			g_SecParams.Key = "password";
			g_SecParams.KeyLen = strlen((char*)"password");
			g_SecParams.Type = SL_SEC_TYPE_WPA;
			
			g_Status = 0;
			sl_WlanConnect(staticWLanInfo.ssid,strlen((const char *)staticWLanInfo.ssid),0,&g_SecParams,0);
			while((!IS_CONNECTED(g_Status)) || (!IS_IP_ACQUIRED(g_Status)));
			
			// send a UDP datagram
			BsdUdpClient(portInfo.udpPort);
			
			// hibernate
			sl_Stop(0);
    }

The initial CC3100 configuration is:

static _i32 configureSimpleLinkToDefaultState(_i8 *pConfig)
{
    SlVersionFull   ver = {0};
    _WlanRxFilterOperationCommandBuff_t  RxFilterIdMask = {0};

    _u8           val = 1;
    _u8           configOpt = 0;
    _u8           configLen = 0;
    _u8           power = 0;

    _i32          retVal = -1;
    _i32          mode = -1;

    mode = sl_Start(0, pConfig, 0);
    ASSERT_ON_ERROR(mode);

    /* If the device is not in station-mode, try configuring it in station-mode */
    if (ROLE_STA != mode)
    {
        if (ROLE_AP == mode)
        {
            /* If the device is in AP mode, we need to wait for this event before doing anything */
            while(!IS_IP_ACQUIRED(g_Status));
        }

        /* Switch to STA role and restart */
        retVal = sl_WlanSetMode(ROLE_STA);
        ASSERT_ON_ERROR(retVal);

        retVal = sl_Stop(SL_STOP_TIMEOUT);
        ASSERT_ON_ERROR(retVal);

        retVal = sl_Start(0, pConfig, 0);
        ASSERT_ON_ERROR(retVal);

        /* Check if the device is in station again */
        if (ROLE_STA != retVal)
        {
            /* We don't want to proceed if the device is not coming up in station-mode */
            ASSERT_ON_ERROR(DEVICE_NOT_IN_STATION_MODE);
        }
    }

    /* Get the device's version-information */
    configOpt = SL_DEVICE_GENERAL_VERSION;
    configLen = sizeof(ver);
    retVal = sl_DevGet(SL_DEVICE_GENERAL_CONFIGURATION, &configOpt, &configLen, (_u8 *)(&ver));
    ASSERT_ON_ERROR(retVal);

    printf("Host Driver Version: %s\n",SL_DRIVER_VERSION);
    printf("Build Version %d.%d.%d.%d.31.%d.%d.%d.%d.%d.%d.%d.%d\n",
                        ver.NwpVersion[0],ver.NwpVersion[1],ver.NwpVersion[2],ver.NwpVersion[3],
                        ver.ChipFwAndPhyVersion.FwVersion[0],ver.ChipFwAndPhyVersion.FwVersion[1],
                        ver.ChipFwAndPhyVersion.FwVersion[2],ver.ChipFwAndPhyVersion.FwVersion[3],
                        ver.ChipFwAndPhyVersion.PhyVersion[0],ver.ChipFwAndPhyVersion.PhyVersion[1],
                        ver.ChipFwAndPhyVersion.PhyVersion[2],ver.ChipFwAndPhyVersion.PhyVersion[3]);

		/* Delete all profiles (0xFF) stored */
		sl_WlanProfileDel(0xFF);

		SlSecParams_t g_SecParams;
		g_SecParams.Key = "password";
		g_SecParams.KeyLen = strlen((char*)"password");
		g_SecParams.Type = SL_SEC_TYPE_WPA;
		sl_WlanProfileAdd("SSID", strlen((char*)"SSID"), 0, &g_SecParams, 0,7,0);

    //Connecting to the Access point

    /* Set connection policy to Auto + SmartConfig (Device's default connection policy) */
		retVal = sl_WlanPolicySet(SL_POLICY_CONNECTION, SL_CONNECTION_POLICY(1, 0, 0, 0, 0), NULL, 0); // PROFILE
    ASSERT_ON_ERROR(retVal);

    /*
     * Device in station-mode. Disconnect previous connection if any
     * The function returns 0 if 'Disconnected done', negative number if already disconnected
     * Wait for 'disconnection' event if 0 is returned, Ignore other return-codes
     */
    retVal = sl_WlanDisconnect();
    if(0 == retVal)
    {
        /* Wait */
        while(IS_CONNECTED(g_Status));
    }

    /* Disable DHCP client*/
		SlNetCfgIpV4Args_t ipV4;
		ipV4.ipV4 = CONFIG_IP;
		ipV4.ipV4Mask = AP_MASK;
		ipV4.ipV4Gateway = AP_GATEWAY;
		ipV4.ipV4DnsServer = AP_DNS;
		// After calling this API device will be configure for static IP address.
		retVal = sl_NetCfgSet(SL_IPV4_STA_P2P_CL_STATIC_ENABLE,1, sizeof(SlNetCfgIpV4Args_t), (_u8 *)&ipV4);
		ASSERT_ON_ERROR(retVal);

    /* Disable scan */
    configOpt = SL_SCAN_POLICY(0);
    retVal = sl_WlanPolicySet(SL_POLICY_SCAN , configOpt, NULL, 0);
    ASSERT_ON_ERROR(retVal);

    /* Set Tx power level for station mode
       Number between 0-15, as dB offset from max power - 0 will set maximum power */
    power = 0;
    retVal = sl_WlanSet(SL_WLAN_CFG_GENERAL_PARAM_ID, WLAN_GENERAL_PARAM_OPT_STA_TX_POWER, 1, (_u8 *)&power);
    ASSERT_ON_ERROR(retVal);

    /* Set PM policy to normal */
    retVal = sl_WlanPolicySet(SL_POLICY_PM , SL_NORMAL_POLICY, NULL, 0);
    ASSERT_ON_ERROR(retVal);

    /* Unregister mDNS services */
    retVal = sl_NetAppMDNSUnRegisterService(0, 0);
    ASSERT_ON_ERROR(retVal);

    /* Remove  all 64 filters (8*8) */
    memset(RxFilterIdMask.FilterIdMask, 0xFF, 8);
    retVal = sl_WlanRxFilterSet(SL_REMOVE_RX_FILTER, (_u8 *)&RxFilterIdMask,
                       sizeof(_WlanRxFilterOperationCommandBuff_t));
    ASSERT_ON_ERROR(retVal);

    retVal = sl_Stop(SL_STOP_TIMEOUT);
    ASSERT_ON_ERROR(retVal);

    retVal = initializeAppVariables();
    ASSERT_ON_ERROR(retVal);

    return retVal; /* Success */
}		

Can you help me with the best way to reduce the reconnection time?

Thanks,
Rubén