主题中讨论的其他器件:CC3235SF
对于客户端(W10回显客户端)如何与 tcpecho_CC3235SF_LAUNCHXL_tirtos7_ticlang 很明显、我感到困惑。 我看到了 demo 站,但也认为它会保持 SEFAULT 模式(这是在本地网络上的站)。 连接对我来说似乎是错的、但这就是问题吗?
#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();
}