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.

CC3220SF-LAUNCHXL: Is this the right way to manually handle the connections?

Part Number: CC3220SF-LAUNCHXL

For some reasons I cannot use the Profiles (one of them is that I have multiple credentials with the same ssid, and this is not supported by your profiles).
Hence I created my own ones. It's simply an array of ssid and keys (WPA2 only). Then I try to connect with the first one, if it fails or timeouts I try with the next one and so on. Here my connect function:

static _i16 NetworkConnect(int idx)
{
    s_AppContext * const pCtx = &gAppCtx;

    SlWlanSecParams_t SecParams;
    _i16 ret;

    UART_PRINT("[SYS] Connecting using credentials #%d...\r\n", idx);

    // Cancel an ongoing connection attempt
    ret = sl_WlanDisconnect();
    if (ret < 0)
    {
        if (ret != SL_ERROR_WLAN_WIFI_ALREADY_DISCONNECTED) ASSERT_ON_ERROR(ret);
    }

// Try with the new credentials SecParams.Type = SL_WLAN_SEC_TYPE_WPA_WPA2; SecParams.Key = (_i8 *) _Settings.wifi.key[idx]; SecParams.KeyLen = strlen((char *) SecParams.Key); char *ssid = _Settings.wifi.ssid[idx]; ret = sl_WlanConnect((_i8 *) ssid, strlen(ssid), NULL, &SecParams, NULL); ASSERT_ON_ERROR(ret); pCtx->asyncEvtTimeout = ASYNC_EVT_TIMEOUT; StartAsyncEvtTimer(); return ret; }

There must be something wrong because if during the first call it tries to connect to a non-available AP it timeouts (ok) but also the next ones (which is toward an available AP) timeouts!
Instead if I call the right AP at first it connects correctly.

Is my approach wrong?

  • Hi,

    What connection policy do you have set?
    What error do you get when you try the profile?

    Regards,
    Charles O
  • Hi! Thanks for your answer. Right now I haven't explicitly set a Policy yet. My SimpleLink configuration is the following:

    static int32_t InitSimplelink(uint8_t const role)
    {
        s_AppContext * const pCtx = &gAppCtx;
        _i32 ret = -1;
    
        pCtx->role = role;
        pCtx->currentState = APP_STATE_STARTING;
        pCtx->pendingEvents = 0;
    
        if ((ret = sl_Start(0, 0, 0)) == SL_ERROR_RESTORE_IMAGE_COMPLETE)
        {
            UART_PRINT(2, "sl_Start Failed\r\n");
            UART_PRINT(2, "\r\nr\nReturn to Factory Default been Completed\r\nPlease RESET the Board\r\nr\n");
            Platform_FactoryDefaultIndication();
            while (1);
        }
    
        // DNS
        SlNetAppDnsClientTime_t Time;
        Time.MaxResponseTime = 2000;
        Time.NumOfRetries = 10;
        ret = sl_NetAppSet(SL_NETAPP_DNS_CLIENT_ID, SL_NETAPP_DNS_CLIENT_TIME, sizeof(Time), (_u8*) &Time);
        ASSERT_ON_ERROR(ret);
    
        // Disable IPv6
        _u32 ifBitmap = 0;
        ret = sl_NetCfgSet(SL_NETCFG_IF, SL_NETCFG_IF_STATE, sizeof(ifBitmap), (uint8_t *) &ifBitmap);
        ASSERT_ON_ERROR(ret);
    
        SignalEvent(APP_EVENT_STARTED);
        pCtx->asyncEvtTimeout = ASYNC_EVT_TIMEOUT;
        StartAsyncEvtTimer();
        return ret;
    }

    When I try a "profile" (in the meaning of ssid+key) for a non-available network it just timeouts (i.e. I receive the application event ASYNC_EVT_TIMEOUT). Then I try with the available one and it also timeouts. But trying with this first (the available one) leads to a successfully connection.