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.

LAUNCHCC3235MOD: tcpecho_CC3235SF_LAUNCHXL_tirtos7_ticlang connect as server should be in default station mode(I thought)

Part Number: LAUNCHCC3235MOD
Other Parts Discussed in Thread: CC3235SF

I am evidently confused about how a client (W10 echo client) to tcpecho_CC3235SF_LAUNCHXL_tirtos7_ticlang. I saw the DEMO station but also thought it would stay in sefault mode(which is station on local network). The connect looks wrong to me, but that's the question?

#define TCPPORT 							  (1000)
//...
void Connect(void)
{
    SlWlanSecParams_t   secParams = {0};
    int16_t ret = 0;
    secParams.Key = (signed char*)SECURITY_KEY;
    secParams.KeyLen = strlen(SECURITY_KEY);
    secParams.Type = SECURITY_TYPE;
    Display_printf(display, 0, 0, "Connecting to : %s.\r\n",SSID_NAME);
    ret = sl_WlanConnect((signed char*)SSID_NAME, strlen(SSID_NAME), 0, &secParams, 0);
    if (ret)
    {
        printError("Connection failed", ret);
    }
}

void *TaskCreate(void (*pFun)(void *), char *Name, int Priority, uint32_t StackSize,
        uintptr_t Arg1, uintptr_t Arg2, uintptr_t argReserved)
{
    int32_t             status = 0;
    pthread_attr_t      pAttrs_tcp;
    struct sched_param  priParam;


    /* Start the TCP Worker  */
    pthread_attr_init(&pAttrs_tcp);
    priParam.sched_priority = Priority;
    status = pthread_attr_setschedparam(&pAttrs_tcp, &priParam);
    status |= pthread_attr_setstacksize(&pAttrs_tcp, StackSize);

    status = pthread_create(&tcpworker_thread, &pAttrs_tcp, (void *(*)(void *))pFun, (void *)Arg1);

    if (status < 0) {
        return (NULL);
    }

    return ((void *)!status);
}

void mainThread(void *pvParameters)
{
    int32_t             status = 0;
    pthread_attr_t      pAttrs_spawn;
    struct sched_param  priParam;

    SPI_init();
    Display_init();
    display = Display_open(Display_Type_UART, NULL);
    if (display == NULL) {
        /* Failed to open display driver */
        while(1);
    }

    /* Start the SimpleLink Host */
    pthread_attr_init(&pAttrs_spawn);
    priParam.sched_priority = SPAWN_TASK_PRIORITY;
    status = pthread_attr_setschedparam(&pAttrs_spawn, &priParam);
    status |= pthread_attr_setstacksize(&pAttrs_spawn, TASK_STACK_SIZE);

    status = pthread_create(&spawn_thread, &pAttrs_spawn, sl_Task, NULL);
    if(status)
    {
        printError("Task create failed", status);
    }

	/* Turn NWP on - initialize the device*/
    mode = sl_Start(0, 0, 0);
    if (mode < 0)
    {
        Display_printf(display, 0, 0,"\n\r[line:%d, error code:%d] %s\n\r", __LINE__, mode, DEVICE_ERROR);
    }

    if(mode != ROLE_STA)
    {
        /* Set NWP role as STA */
        mode = sl_WlanSetMode(ROLE_STA);
        if (mode < 0)
        {
            Display_printf(display, 0, 0,"\n\r[line:%d, error code:%d] %s\n\r", __LINE__, mode, WLAN_ERROR);
        }

        /* For changes to take affect, we restart the NWP */
        status = sl_Stop(SL_STOP_TIMEOUT);
        if (status < 0)
        {
            Display_printf(display, 0, 0,"\n\r[line:%d, error code:%d] %s\n\r", __LINE__, status, DEVICE_ERROR);
        }

        mode = sl_Start(0, 0, 0);
        if (mode < 0)
        {
            Display_printf(display, 0, 0,"\n\r[line:%d, error code:%d] %s\n\r", __LINE__, mode, DEVICE_ERROR);
        }
    }

    if(mode != ROLE_STA)
    {
        printError("Failed to configure device to it's default state", mode);
    }

    Connect();
}

  • How can I get this to be a server in station mode and as what I believe is the working default? As soon as I stop debugging the device is pingable again on the local network.

  • Got it to work (bug in my client for what server expected. Now i wonder how to just use the default profile(or highest priority)?

    #define SLNET_IF_WIFI_NAME                    "trog3235" //"CC32xx"
    
    #define SSID_NAME                             "WR000150"  //my local ssid      /* AP SSID */
    #define SECURITY_TYPE                         SL_WLAN_SEC_TYPE_WPA_WPA2 /* Security type could be SL_WLAN_SEC_TYPE_OPEN */
    #define SECURITY_KEY                          "xxxxxxxxxxxxxxxxxxx" // "12345678" password of the secured AP */
    

    The only weird thing to me is the router has it at same address on 2.4GHz ssid=WR0001 and when it runs on 5GHz WR00150 tcpEcho, they have the same address 192.168.1.94.The MACs are the same.  

  • Hi Malcolm,

    I have assigned this to one of our SW engineers, please allow until Monday for a response.

  • Hi Malcolm,

    Please allow for a response tomorrow, I forgot they are observing Yom Kippur today.

  • Hi Malcolm,

    Not sure exactly what was the original issue as it should move to station mode and connect. I am happy though that you got it working.

    The example uses an explicit connection to the AP but if you want you can change it to a profile. After the sl_Start(), you can remove the Connect() and it should automatically connect. The examples we provide with the SDK are part of the netif module that can be found on two examples in the SDK, connection_manager and mqtt_client.

    You can also read about it under the <SDK install dir>/docs/ns/NS_Users_Guide.html.

    Regards,

    Shlomi