CC3235MODASF: CC3235MODASF:When the CC3235 operates in AP mode as a client and sends a GET request, it encounters a Socket Error Error! code = -111, Description = GETTask: connect failed

Part Number: CC3235MODASF

Tool/software:

Dear TI FAE  Engineer
When the CC3235 operates in AP mode as a client and sends a GET request, it encounters a Socket Error Error! code = -111, Description = GETTask: connect failed.We look forward to your prompt response as the project is extremely urgent.Below is the code for httpget.c:
/*
 * Copyright (c) 2015-2017, Texas Instruments Incorporated
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *
 * * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 *
 * * Neither the name of Texas Instruments Incorporated nor the names of
 * its contributors may be used to endorse or promote products derived
 * from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
/*
 * ======== httpget.c ========
 * HTTP Client GET example application
 */
/* BSD support */
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <pthread.h>
#include <unistd.h>
#include <mqueue.h>
#include <assert.h>
#include <string.h>
#include "CRC32.h"
#include <ti/display/Display.h>
#include <ti/net/http/httpclient.h>
#include "semaphore.h"
#include <ti/net/slnetutils.h>
#include "user_program.h"
#define HOSTNAME "">http://www.example.com"
#define REQUEST_URI "/"
#define USER_AGENT "HTTPClient (ARM; TI-RTOS)\r\n\r\n"
#define charParams "/resource01/"
#define charParamLens 4
#define HTTP_MIN_RECV (256)
extern char gStationIp[];//IP地址
char ClientPostDataRespon[7];
char receiveUpdataUrl[11];
char UpdataUrl[10];
extern void HttpClient_GetParameter(const char *charparam, char *value);
extern Display_Handle display;
extern sem_t ipEventSyncObj;
extern sem_t SyncObj;
extern void printError(char *errString,
                       int code);
#include <ti/drivers/net/wifi/simplelink.h>
//POST相关的变量
extern uint8_t TemBleSoftInfo;
extern char BleSoftInfo;
//发数据至服务器
void HttpClient_SendPostRequest(const char *charParam, uint8_t charParamLen, char *value)
{
    int16_t len = 0;
    bool moreDataFlag = false;
    const char contentType[] = "text/plain; charset=utf-8";
    int16_t ret = 0;
    HTTPClient_Handle httpClientHandle;
    int16_t statusCode;
// // 获取互斥锁(如果被占用就等待)
// Semaphore_pend(httpMutexHandle, OS_WAIT_FOREVER);
    Display_printf(display, 0, 0, "POST\n");
    httpClientHandle = HTTPClient_create(&statusCode,0);
// Display_printf(display, 0, 0, "POSTClient_create\n");
    if(statusCode < 0)
    {
       printError("POSTTask: creation of http client handle failed",
                      statusCode);
    }
    ret = HTTPClient_setHeader(httpClientHandle,
                                 HTTPClient_HFIELD_REQ_CONTENT_TYPE,
                                 contentType,strlen(contentType)+1,
                                 HTTPClient_HFIELD_PERSISTENT);
// Display_printf(display, 0, 0, "setHeader\n");
   if(ret < 0)
   {
          printError("POSTTask: setting request header failed", ret);
   }
    ret = HTTPClient_connect(httpClientHandle,gStationIp,0,0);//gStationIp作为全局变量用
    Display_printf(display, 0, 0, "connected\n");
    if(ret < 0)
    {
       printError("POSTTask: connect failed", ret);
    }
    ret = HTTPClient_sendRequest(httpClientHandle,HTTP_METHOD_POST,charParam,
                                 value,charParamLen, 0);
// Display_printf(display, 0, 0, "SendedPOSTRequest\n");
    if(ret < 0)
      {
        printError("POSTTask: send failed", ret);
      }
    if(ret != HTTP_SC_OK)
      {
        printError("POSTTask: cannot get status", ret);
      }
     //Display_printf(display, 0, 0, "HTTP Response Status Code: %d\n", ret);
     len = 0;
     do
     {
         ret = HTTPClient_readResponseBody(httpClientHandle, ClientPostDataRespon, 7,
                                            &moreDataFlag);
         if(ret < 0)
         {
           printError("POSTTask: response body processing failed", ret);
         }
         Display_printf(display, 0, 0, "Send Msg:%.*s \r\n",ret,ClientPostDataRespon);
         len += ret;
     }
     while(moreDataFlag);
     //Display_printf(display, 0, 0, "Received %d bytes of payload\n", len);
     ret = HTTPClient_disconnect(httpClientHandle);
     if(ret < 0)
       {
         printError("POSTTask: disconnect failed", ret);
       }
     ret = HTTPClient_destroy(httpClientHandle);
     if(ret < 0)
       {
         printError("POSTTask: destroy Client failed", ret);
       }
     Display_printf(display, 0, 0, "POST finish\n");
// // 释放互斥锁
// Semaphore_post(httpMutexHandle);
}
/*********************************************************************
 * @fn SimpleProfile_SetParameter
 *
 * @brief send data.发送数据至服务器
 *
 * @param charparam, len value
 *
 * @return esp_gatt_status_t.
 */
void HttpClient_SetParameter(const char *charparam, uint16_t charParamLen, char *value )
{
     if(strcmp(charparam, SIMPLEPROFILE_CHAR1) == 0)
     {
         HttpClient_SendPostRequest(SIMPLEPROFILE_CHAR1,SIMPLEPROFILE_CHAR1_LEN,value);
     }
     else if(strcmp(charparam, SIMPLEPROFILE_CHAR2) == 0)
     {
         HttpClient_SendPostRequest(SIMPLEPROFILE_CHAR2,SIMPLEPROFILE_CHAR2_LEN,value);
     }
     else if(strcmp(charparam, SIMPLEPROFILE_CHAR3) == 0)
     {
         HttpClient_SendPostRequest(SIMPLEPROFILE_CHAR3,SIMPLEPROFILE_CHAR3_LEN,value);
     }
     else if(strcmp(charparam, SIMPLEPROFILE_CHAR4) == 0)
     {
         HttpClient_SendPostRequest(SIMPLEPROFILE_CHAR4,SIMPLEPROFILE_CHAR4_LEN,value);
     }
     else if(strcmp(charparam, SIMPLEPROFILE_CHAR5) == 0)
      {
         HttpClient_SendPostRequest(SIMPLEPROFILE_CHAR5,SIMPLEPROFILE_CHAR5_LEN,value);
      }
     else if(strcmp(charparam, SIMPLEPROFILE_CHAR6) == 0)
      {
         HttpClient_SendPostRequest(SIMPLEPROFILE_CHAR6,SIMPLEPROFILE_CHAR6_LEN,value);
      }
     else if(strcmp(charparam, SIMPLEPROFILE_CHAR7) == 0)
      {
         HttpClient_SendPostRequest(SIMPLEPROFILE_CHAR7,SIMPLEPROFILE_CHAR7_LEN,value);
      }
     else if(strcmp(charparam, SIMPLEPROFILE_CHAR8) == 0)
      {
         HttpClient_SendPostRequest(SIMPLEPROFILE_CHAR8,SIMPLEPROFILE_CHAR8_LEN,value);
      }
     else if(strcmp(charparam, SIMPLEPROFILE_CHAR9) == 0)
      {
         HttpClient_SendPostRequest(SIMPLEPROFILE_CHAR9,SIMPLEPROFILE_CHAR9_LEN,value);
      }
     else if(strcmp(charparam, SIMPLEPROFILE_CHAR10) == 0)
      {
         HttpClient_SendPostRequest(SIMPLEPROFILE_CHAR10,SIMPLEPROFILE_CHAR10_LEN,value);
      }
     else if(strcmp(charparam, SIMPLEPROFILE_CHAR11) == 0)
      {
         HttpClient_SendPostRequest(SIMPLEPROFILE_CHAR11,SIMPLEPROFILE_CHAR11_LEN,value);
      }
}
//从服务器接收数据
void HttpClient_SendGetRequest(const char *charParam, uint8_t charParamLen, char *value)
{
    int16_t len = 0;
    int connect_counter = 0;
    bool moreDataFlag = false;
    int16_t statusCode;
    const char contentType[] = "text/plain; charset=utf-8";
    int16_t ret = 0;
    HTTPClient_Handle httpClientHandle;
// // 获取互斥锁(如果被占用就等待)
// Semaphore_pend(httpMutexHandle, OS_WAIT_FOREVER);
    Display_printf(display, 0, 0, "GET\n");
    httpClientHandle = HTTPClient_create(&statusCode,0);
// Display_printf(display, 0, 0, "Client_created\n");
// Display_printf(display, 0, 0, "statusCode:%d\n",statusCode);
    if(statusCode < 0)
    {
       printError("GETTask: creation of http client handle failed",
                  statusCode);
    }
    ret = HTTPClient_setHeader(httpClientHandle,
                              HTTPClient_HFIELD_REQ_CONTENT_TYPE,
                              contentType,strlen(contentType)+1,
                              HTTPClient_HFIELD_PERSISTENT);
// Display_printf(display, 0, 0, "setHeader\n");
// Display_printf(display, 0, 0, "HTTPClient_setHeader:%d\n",ret);
    if(ret < 0)
    {
       printError("GETTask: setting request header failed", ret);
    }
// Display_printf(display, 0, 0, "gStationIp='%s'\n",gStationIp);
    Display_printf(display, 0, 0, "connecting\n");
    ret = HTTPClient_connect(httpClientHandle,gStationIp,0,0);//gStationIp作为全局变量用
// Display_printf(display, 0, 0, "connected\n");
// Display_printf(display, 0, 0, "HTTPClient_connect:%d\n",ret);
    if(ret < 0)
    {
       printError("GETTask: connect failed", ret);
// Display_printf(display, 0, 0, "GETTask: connect failed, try to reconnect\n");
// while(ret<0)//连接失败重复连接5000次
// {
// connect_counter++;
// ret = HTTPClient_connect(httpClientHandle,gStationIp,0,0);//gStationIp作为全局变量用
//
// }
// Display_printf(display, 0, 0, "reconnect:%d times\n",connect_counter);
    }
    ret = HTTPClient_sendRequest(httpClientHandle,HTTP_METHOD_GET,charParam,
                                       NULL,0,
                                       0);
// Display_printf(display, 0, 0, "SendedGetRequest\r\n");
// Display_printf(display, 0, 0, "HTTPClient_sendRequest:%d\n",ret);
    if(ret < 0)
    {
       printError("GETTask: send failed", ret);
    }
    if(ret != HTTP_SC_OK)
    {
       printError("GETTask: cannot get status", ret);
    }
       //Display_printf(display, 0, 0, "HTTP Response Status Code: %d\n", ret);
    len = 0;
    do
    {
       ret = HTTPClient_readResponseBody(httpClientHandle, value+len, charParamLen,
                                                &moreDataFlag);
// Display_printf(display, 0, 0, "HTTPClient_readResponseBody:%d\n",ret);
       if(ret < 0)
       {
          printError("GETTask: response body processing failed", ret);
       }
       Display_printf(display, 0, 0, "%s \r\n",value+len);
       len += ret;
    }while(moreDataFlag);
       //Display_printf(display, 0, 0, "Received %d bytes of payload\n", len);
    ret = HTTPClient_disconnect(httpClientHandle);
// Display_printf(display, 0, 0, "HTTPClient_disconnect:%d\n",ret);
    if(ret < 0)
    {
       printError("GETTask: disconnect failed", ret);
    }
    ret = HTTPClient_destroy(httpClientHandle);
// Display_printf(display, 0, 0, "HTTPClient_destroy:%d\n",ret);
    if(ret < 0)
    {
       printError("GETTask: destroy Client failed", ret);
    }
    Display_printf(display, 0, 0, "GET finish\n");
// // 释放互斥锁
// Semaphore_post(httpMutexHandle);
}
//void HttpClient_SendGetRequest(HTTPClient_Handle httpClientHandle,const char *charParam, uint8_t charParamLen, char *value)
/*********************************************************************
 * @fn HttpClient_GetRequest
 *
 * @brief receive data . 从服务器接收数据
 *
 * @param charparam, value
 *
 * @return esp_gatt_status_t.
 */
void HttpClient_GetParameter(const char *charparam, char *value)
{
   //char *prf_char;
// memcpy(dst, src, SIMPLEPROFILE_CHAR1_LEN);
   if(strcmp(charparam, SIMPLEPROFILE_CHAR1) == 0)
   {
    //HttpClient_SendGetRequest(httpClientHandle,SIMPLEPROFILE_CHAR0, SIMPLEPROFILE_CHAR0_LEN,receiveUpdataUrl);
// HttpClient_SendGetRequest(charparam,SIMPLEPROFILE_CHAR1_LEN,value);
    memcpy(value, userData.Tem_Attr_Buff, SIMPLEPROFILE_CHAR1_LEN);
   }
   else if(strcmp(charparam, SIMPLEPROFILE_CHAR2) == 0)
   {
     HttpClient_SendGetRequest(charparam,SIMPLEPROFILE_CHAR2_LEN,value);
     //memcpy(value, prf_char, SIMPLEPROFILE_CHAR2_LEN);
   }
   else if(strcmp(charparam, SIMPLEPROFILE_CHAR3) == 0)
   {
     HttpClient_SendGetRequest(charparam,SIMPLEPROFILE_CHAR3_LEN,value);
     //memcpy(value, prf_char, SIMPLEPROFILE_CHAR3_LEN);
   }
   else if(strcmp(charparam, SIMPLEPROFILE_CHAR4) == 0)
   {
     HttpClient_SendGetRequest(charparam,SIMPLEPROFILE_CHAR4_LEN,value);
     //memcpy(value, prf_char, SIMPLEPROFILE_CHAR4_LEN);
   }
   else if(strcmp(charparam, SIMPLEPROFILE_CHAR5) == 0)
   {
     HttpClient_SendGetRequest(charparam,SIMPLEPROFILE_CHAR5_LEN,value);
     //memcpy(value, prf_char, SIMPLEPROFILE_CHAR5_LEN);
   }
   else if(strcmp(charparam, SIMPLEPROFILE_CHAR6) == 0)
   {
     HttpClient_SendGetRequest(charparam,SIMPLEPROFILE_CHAR6_LEN,value);
     //memcpy(value, prf_char, SIMPLEPROFILE_CHAR6_LEN);
   }
   else if(strcmp(charparam, SIMPLEPROFILE_CHAR7) == 0)
   {
     HttpClient_SendGetRequest(charparam,SIMPLEPROFILE_CHAR7_LEN,value);
     //memcpy(value, prf_char, SIMPLEPROFILE_CHAR7_LEN);
   }
   else if(strcmp(charparam, SIMPLEPROFILE_CHAR8) == 0)
   {
    HttpClient_SendGetRequest(charparam,SIMPLEPROFILE_CHAR8_LEN,value);
    //memcpy(value, prf_char, SIMPLEPROFILE_CHAR8_LEN);
   }
   else if(strcmp(charparam, SIMPLEPROFILE_CHAR9) == 0)
   {
    HttpClient_SendGetRequest(charparam,SIMPLEPROFILE_CHAR9_LEN,value);
    //memcpy(value, prf_char, SIMPLEPROFILE_CHAR9_LEN);
   }
   else if(strcmp(charparam, SIMPLEPROFILE_CHAR10) == 0)
   {
    HttpClient_SendGetRequest(charparam,SIMPLEPROFILE_CHAR10_LEN,value);
    //memcpy(value, prf_char, SIMPLEPROFILE_CHAR10_LEN);
   }
   else if(strcmp(charparam, SIMPLEPROFILE_CHAR11) == 0)
   {
    HttpClient_SendGetRequest(charparam,SIMPLEPROFILE_CHAR11_LEN,value);
    //memcpy(value, prf_char, SIMPLEPROFILE_CHAR11_LEN);
   }
}
int SPIcount = 0;
int TIMEcount = 0;
void SimpleWifiPeripheral_processAppMsg(void)
{
    //int quecommand;
// Display_printf(display, 0, 0, "mq_receive\n");
    mq_receive(commandQueue, (char*)&command, sizeof(command), NULL);
    switch (command)
    {
    case SBP_SPI_TRANSFER_DONE_EVT://SPI传输事件
// Display_printf(display, 0, 0, "SPIcount:%d\n",SPIcount);
        usleep(10000);//test
        command=0;
        SPIcount++;
// get_flag = 0;//该函数执行置一
        User_processSPITransferDoneEvt(userData.state);
        break;
    case SBP_TIMER_OUT_EVT://定时器事件
// Display_printf(display, 0, 0, "TIMEcount:%d\n",TIMEcount);
        usleep(10000);//test
        userData.state = 0;
        command=0;
        TIMEcount++;
// post_flag = 1;//该函数执行置一
        User_processTimerOutEvt(userData.state);
        break;
    case SBP_CHAR_CHANGE_EVT://读取话题事件
        User_processCharValueChangeEvt(UpdataUrl);
        break;
    default:
        break;
    }
// mq_close();
}
/*
 * ======== SimpleWifiPeripheral_taskFxn ========
 * spi event and timeout event
 */
void* SimpleWifiPeripheral_taskFxn(void* pvParameters)//线程1
{
    enum RESOURCEx resource_post;
#if 1
    SlWlanConnStatusParam_t connectionParams;
    uint16_t Opt = 0;
    int32_t retVal = 0;
    uint16_t Size = 0;
#endif
#if 1
    Size = sizeof(SlWlanConnStatusParam_t);
    memset(&connectionParams, 0x7e, sizeof(SlWlanConnStatusParam_t));
    retVal = sl_WlanGet(SL_WLAN_CONNECTION_INFO, &Opt, &Size, (uint8_t *)&connectionParams);
    Display_printf(display, 0, 0, "connection status %d, mode %d\n",
                   connectionParams.ConnStatus, connectionParams.Mode);
#endif
    if (connectionParams.Mode == ROLE_AP)
    {
           //sem_wait(&ipEventSyncObj);//接收信号量获得IP值
           sem_wait(&SyncObj);
           Display_printf(display, 0, 0, "start \n");
    }
    for (;;)
    {
        usleep(10000);//延迟10毫秒
        SimpleWifiPeripheral_processAppMsg();
    }
}
/*
 * ======== httpTask ========
 * Makes a HTTP GET request
 */
void* httpTask(void* pvParameters)//线程2
{
    int32_t status = 0;
    uint8_t readCounter = 0;
    char compareCounter[1];
    char* counter;
// uint8_t ret = 0;
    pthread_t SimpleWifiPeripheral = (pthread_t)NULL;
    pthread_attr_t pAttrs;
    struct sched_param priPar;
    static int flag = 1;//get标志位
#if 0
    SlNetSock_Addr_t *sa;
    SlNetSock_AddrIn_t sAddr;
    uint8_t destIP[4];
#endif
#if 1
    SlWlanConnStatusParam_t connectionParams;
    uint16_t Opt = 0;
    int32_t retVal = 0;
    uint16_t Size = 0;
#endif
#if 1
    Size = sizeof(SlWlanConnStatusParam_t);
    memset(&connectionParams, 0x7e, sizeof(SlWlanConnStatusParam_t));
    retVal = sl_WlanGet(SL_WLAN_CONNECTION_INFO, &Opt, &Size, (uint8_t *)&connectionParams);
    Display_printf(display, 0, 0, "connection status %d, mode %d\n",
                   connectionParams.ConnStatus, connectionParams.Mode);
#endif
#if 0
    if (connectionParams.Mode == ROLE_AP)
    {
        sAddr.sin_family = SLNETSOCK_AF_INET;
        sAddr.sin_port = SlNetUtil_htons((unsigned short)80);
        destIP[0] = 10;
        destIP[1] = 123;
        destIP[2] = 45;
        destIP[3] = 3;
        sAddr.sin_addr.s_addr = SlNetUtil_htonl((((uint32_t) destIP[0] << 24) | ((uint32_t) destIP[1] << 16) | (destIP[2] << 8) | (destIP[3])));
        sa = (SlNetSock_Addr_t*)&sAddr; //HTTPClient_setProxy() expects a SlNetSock_Addr_t, but the input
                                       //is treated like a SlNetSock_AddrIn_t when the socket is created
        HTTPClient_setProxy(sa);
    }
#endif
    if (connectionParams.Mode == ROLE_AP)
    {
        sem_wait(&ipEventSyncObj);//接收信号量获得IP值
        Display_printf(display, 0, 0, "Sending a HTTP GET request to '%s'\n",gStationIp);//打印IP地址
        sem_post(&SyncObj);
    }
    else
    {
        Display_printf(display, 0, 0, "Sending a HTTP GET request to '%s'\n",HOSTNAME);
    }
    int conter =0;
    while(1)
    {
        conter++;
        HttpClient_SendGetRequest(SIMPLEPROFILE_CHAR0, SIMPLEPROFILE_CHAR0_LEN,receiveUpdataUrl);
        Display_printf(display, 0, 0, "%d\n",conter);
    }
    return(0);
}
  • Hi,

    What is a address where you try to send http request at AP mode? What clients are connected to device at AP mode?

    Jan

  • We have established a server and client system using the host computer, with the CC3235 chip serving as the second client. The host computer server connects to the CC3235 operating in AP mode. The host computer client parses file data and sends it to the host computer server. The CC3235 client continuously sends GET requests to check if data on the host computer server has been updated. If updated, it performs corresponding data processing. The host computer connects to the IP address 10.123.45.2, and the CC3235 chip also sends requests to this same address. However, we observed that the server connection would disconnect when the CC3235 continuously sent GET requests. Throughout this process, the CC3235 remained in AP mode.

  • Hi,

    I am sorry, even I read your setup 3x times, I don't understand them.

    Jan

  • This is the code for configuring AP mode:

    static void ruking_ap_config(void)
    {
    int status;
    Display_printf(display, 0, 0, "Start to config AP mode\r\n");
    _u8 Ssid[] = "myWIFI";//Ruking
    status = sl_WlanSet(SL_WLAN_CFG_AP_ID, SL_WLAN_AP_OPT_SSID, strlen(Ssid), Ssid);

    _u8 val = SL_WLAN_SEC_TYPE_WPA_WPA2;
    status = sl_WlanSet(SL_WLAN_CFG_AP_ID, SL_WLAN_AP_OPT_SECURITY_TYPE, 1, (_u8 *)&val);

    _u8 password[] = {"123456789"};
    _u16 len = strlen(password);
    status = sl_WlanSet(SL_WLAN_CFG_AP_ID, SL_WLAN_AP_OPT_PASSWORD, len, (_u8 *)password);
    #if 0
    SlNetCfgIpV4Args_t ipV4;
    ipV4.Ip = (_u32)SL_IPV4_VAL(10,1,1,201); /* IP address */
    ipV4.IpMask = (_u32)SL_IPV4_VAL(255,255,255,0); /* Subnet mask */
    ipV4.IpGateway = (_u32)SL_IPV4_VAL(10,1,1,1); /* Default gateway address */
    ipV4.IpDnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); /* _u32 DNS server address */
    status = sl_NetCfgSet(SL_NETCFG_IPV4_AP_ADDR_MODE,SL_NETCFG_ADDR_STATIC,sizeof(SlNetCfgIpV4Args_t), (_u8 *)&ipV4);
    #endif
    mode = sl_WlanSetMode(ROLE_AP);
    if (mode < 0)
    {
    Display_printf(display, 0, 0,"\n\r[line:%d, error code:%d] %s\n\r", __LINE__, mode, WLAN_ERROR);
    }
    }

  • Hi,

    I am not sure that CC32xx device can route packets outside their own subnet at AP mode. That means yous DNS server setup may not be correct.

    Jan

  • you mean this : ipV4.IpDnsServer = (_u32)SL_IPV4_VAL(8,16,32,64); /* _u32 DNS server address */?

    But this line of code is not executed.

  • Hi,

    OK, I did not noticed that you are provided example of code with useless macros. How do you have set IP parameters for AP mode?

    Jan

  • void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent)
    {
    int32_t status = 0;
    pthread_attr_t pAttrs;
    struct sched_param priParam;

    if(pNetAppEvent == NULL)
    {
    return;
    }

    switch(pNetAppEvent->Id)
    {
    case SL_NETAPP_EVENT_IPV4_ACQUIRED:
    case SL_NETAPP_EVENT_IPV6_ACQUIRED:
    break;
    case SL_NETAPP_EVENT_DHCPV4_LEASED:
    {
    sprintf((char *)gStationIp, "%d.%d.%d.%d",
    SL_IPV4_BYTE(pNetAppEvent->Data.IpLeased.IpAddress,3), SL_IPV4_BYTE(pNetAppEvent->Data.IpLeased.IpAddress,2),
    SL_IPV4_BYTE(pNetAppEvent->Data.IpLeased.IpAddress,1), SL_IPV4_BYTE(pNetAppEvent->Data.IpLeased.IpAddress,0));
    Display_printf(display, 0, 0, "\n\r[NETAPP EVENT] IP Leased to Client: IP=%s \n\r", gStationIp);

    sem_post(&ipEventSyncObj);
    }
    break;
    default:
    break;
    }
    }

  • Hi,

    What do you want to achieve by this handler? It just show IP address leased by the DHCP server inside CC32xx and signalise this by the semaphore, save to gStationIp for later usage.

    Maybe you can check at your computer by Wireshark what is going on. Do you have disabled firewall?

    Jan

  •  Thank you for your advice of Wireshark. And I haven't disabled firewall. Based on the Wireshark logs, does this indicate that the firewall is blocking DNS queries? Additionally, the server port is 80, but the client port for 10.123.45.1 (CC3235) keeps changing. Is this normal, or am I missing a relevant configuration? If it's possible to set a fixed port, is there a related process for doing so?

  • Hi,

    That source port for TCP connection is changing is pretty normal. You don't need to change this. Actually this is way which allows proper function of NAT (if its used at network).

    Your PC (.2) is asking of your CC32xx (.1) for resolving some DNS address. And because CC32xx not knows the answer you response it that.

    Issue with SYN is likely your PC server is not responding. Why? I don't know.

    Jan

  • The image shows the normal operating state. Could the issue be that I didn't disable the firewall, causing the cc32xx to terminate connection requests?

  • Hi,

    Hard to say. But if firewall is enabled incoming connections (SYS packets) are dropped at firewall.

    Jan

  • Hi Aodong,

    Connection refusal (code -111) can definitely be caused by your firewall. Someone in another thread had a similar issue, but they were trying connect to an IPv6 address, maybe it can help you. Here is the thread.

    Best,
    Brandon Liu