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.

CC3220MOD: few questions for AT Commands usage

Part Number: CC3220MOD
Other Parts Discussed in Thread: CC3220S

Hi team,

My customer is using ATCMD library with cc3220mods and the device is controlled by host processor SDX55 through uart interface.

The cc3220 runs as AP and provides TCP socket for hand held device to connect. And the host then can send HTML webpages and pictures through the connected TCP socket to the client.

Here's some questions they got:

  1. Socket created in blocking mode or nonblocking mode, if they use:
    1. In blocking mode, they found sometimes the at+accept cmd does not work well, meaning that even a TCP client requests to connect, the system won’t return from it and make connection.
    2. In nonblocking mode, it wastes time and computing power on polling socket for connection request.
    3. They will go with blocking mode, but they want us provide suggestion for software flow to make socket-handling more reliable.
  2. When receiving data from hand held device, the host will sometimes get garbage data as I mentioned previously. It is probably related to pointers to wrong memory address, or minor bugs in host side. I have asked them to capture the UART waveform by logic analyzer. They can add filter to workaround but want root cause if possible.
  3. At+socket cmd, there’re two type of format, they found in binary format this cmd cannot send out carriage return or line feed (\r or \n). They need our support on this.
    Here’s the example transmitted payload:
    char str="HTTP/1.1 200 Ok\n

    Server: mini_httpd/1.30 26Oct2018\r

    Date: Sun, 06 Jan 1980 01:46:15 GMT

    Content-Type: text/plain; charset=UTF-8

    Content-Length: 1150

    Last-Modified: Tue, 08 Sep 2020 00:32:57 GMT

    Connection: close";
  4. At+send cmd, when sending out massive data, there’s chance that cc32 returns OK but it actually did not send it out. If the data is larger than atcmd buffer (1024B by default), they will divide it into multiple fragmentation and send them out. However some packets are likely missing and cc32 still returns OK.

Thanks!

Kind regards,

Jo

  • Hi Jo,

    I'm not sure about 1 and 2. I will need to look into the code to get better understand. 

    3 is a general problem with AT commands that take arbitrary data in binary format. The parser in the application looks for \r and \n as a terminator and does not account for the length of the message. I have reported this bug to R&D and a fix should be in order for the next SDK but I'm not 100% sure yet. A workaround could be to send the data in base64 but I'm not sure if this is available for all AT cmd. I will need to check this as well.

    I'm also not sure about 4. I know the send command can take up to 32kb data in the argument but maybe the AT cmd interface limits this? I will als have to check the code for this.

    Jesu

  • Hi Jo,

    What SDK version and service pack is the customer using? 

    1a:

    Also, when they use at+accept do they always use at+socket, at+bind and at+listen before using at+accept? If the system does not return from it, it must be because the client is not connecting to it properly according to how the server socket is configured. I have never seen inconsistent behavior with the accept call. Do they always test the connection the same exact way?

    1c: Check figure 6-1 in programmer's guide for recommended TCP socket flow. 

    2. Could you explain the setup here? Are you referring to the interaction between the SDX55 host and the CC3220? What AT command response does the garbage data come from? 

    4. How much data are they trying to send? What is the max they are doing?

    Jesu

  • Hi Jesu,

    Thanks for your help! 

    They are using SDK v4.20, and I'm using v4.30.

    2. I think the garbage data is the asynchronous event message. In my test on EVM I can get correct message. So this issue maybe relate to host side. Can we just disable the async event message? Is there a MACRO to disable it?

    Below is customer's test result, they type in AT+T and then a mobile phone connects to it, the garbage data shows up, after that they input est as a whole command "at+test", the device returns "OK".

    But in my test, as shown below, I didn't see the same thing. Compared to each other, we can speculate that garbage data should be async event msg.

    4. the size of html pages and photos can be up to 100kB, and they will divide it into several 1KB segments before at+send it out.

    As for \r and \n terminators thing, do you think we can release a hot fix for them shortly? My customer is in a hurry and can't wait for next release.

    Here's my atcmd test procedure, please take a look and point it out if I'm doing it wrong, thank you very much!!

    regards,

    Jo

  • EDIT 4:

    Hi Jo,

    2. Are you asking if you can disable the response from the AT commands? I don't think this is possible as the responses are built into the AT command library. If they want they can modify the library and rebuild it but I do not recommend this as it may be a lot of work and it is not a solution it's a workaround. I would recommend whatever UART issues the customer is having on the host side. 

    4. I haven't tested sending more than 1kB with at+send but the code looks like it reads the rest of the data in the residue while loop for any socket send commands:

    while (residue > 0){
    /* read the residue */
    lRetVal = GetRawCmd((char *)&ATCommands_cmdBuffer[offset],residue);...

    I'm not sure what is going on with the "&0[offset]" reference. It looks like it's not actually doing anything with the data but I have to check with a teammate tomorrow. Could you check if this while loop is getting executed when you try to send more than 1kB with at+send?

    I'm not sure where I saw this &0 but I checked again on my work computer today and it's actually not &0. Anyway, it does not appear to me that the code is dividing it into segments. If the intiail GetRawCmd call exceeds the default buffer size then it enteres the while(residue) loop where it reads the rest before sending the AT cmd to the core AT command library. I think the problem is that the customer is trying to send too much data. socket send APIs are limited to roughly 31kB I believe. Do they get issues if they send 30kB of data per at+send call? 

    Jesu

  • Hi Jesu,

    *edited. 

    I was asking about 3Mbps baud rate + DMA enable. I found the answers, please ignore this post.

    Thanks as always,

    Jo

  • Hi Jesu and Jo,

    Thank you very much for your kind help.

    Our goal is that Users can access our device's web GUI and login device via WLAN but the devices don't support WLAN.

    Our solution is that use a cc3220s which work as a AP and provide WIFI for stations to access, cc3220s and the device can transfer data via uart. And cc3220s need forward data from stations to our devices, and forward the data from our devices to WIFI stations.

    Now, we only use socket at command to achieve our goal without any change with cc3220s's SDK,  let me summary the problems while using cc3220s.

    1.  at+accept don't work well in In blocking mode which is already under discussing.

    2.  the data which need cc3220s forward to WIFI stations include '\r' and '\n', so we need use Base64 data format when call at+send.

    3. When station connect and disconnect AP,  at+recv will receive garbage data which is already under discussing. After comparing with Jo's test log, I think the garbage data is Asynchronous Events report.

    4. With the limit of length of at command and the data from our device's is large, the WIFI stations can not finish loading web page.To improve the transmission rate, we increase baud rate of the UART . When the baud rate is increased to 921600,  it become abnormal while  sending at command to cc3220s.

    Please help solve 4 first, and if any questions, please feel free to connect me, our schedule is finish this goal this week.

    Below is the log of my application.  Receive error or no response of AT+SetSockOpt.

    at write: [8]AT+Test
    recv: 14, AT+Test
    OK

    buf[0]:65buf[1]:84buf[2]:43buf[3]:84buf[4]:101buf[5]:115buf[6]:116buf[7]:13buf[8]:10buf[9]:13buf[10]:79buf[11]:75buf[12]:10buf[13]:13
    at write: [26]AT+Socket=INET,STREAM,TCP
    recv: 28, AT+Socket=INET,STREAM,TCP

    buf[0]:65buf[1]:84buf[2]:43buf[3]:83buf[4]:111buf[5]:99buf[6]:107buf[7]:101buf[8]:116buf[9]:61buf[10]:73buf[11]:78buf[12]:69buf[13]:84buf[14]:44buf[15]:83buf[16]:84buf[17]:82buf[18]:69buf[19]:65buf[20]:77buf[21]:44buf[22]:84buf[23]:67buf[24]:80buf[25]:13buf[26]:10buf[27]:13
    recv: 15, +socket:1
    OK

    buf[0]:43buf[1]:115buf[2]:111buf[3]:99buf[4]:107buf[5]:101buf[6]:116buf[7]:58buf[8]:49buf[9]:10buf[10]:13buf[11]:79buf[12]:75buf[13]:10buf[14]:13
    at write: [37]AT+SetSockOpt=1,SOCKET,NONBLOCKING,1
    recv: 51, AT+SetSockOpt=1,NG,1
    ERROR: parse parameters,-4

    buf[0]:65buf[1]:84buf[2]:43buf[3]:83buf[4]:101buf[5]:116buf[6]:83buf[7]:111buf[8]:99buf[9]:107buf[10]:79buf[11]:112buf[12]:116buf[13]:61buf[14]:49buf[15]:44buf[16]:78buf[17]:71buf[18]:44buf[19]:49buf[20]:13buf[21]:10buf[22]:13buf[23]:69buf[24]:82buf[25]:82buf[26]:79buf[27]:82buf[28]:58buf[29]:32buf[30]:112buf[31]:97buf[32]:114buf[33]:115buf[34]:101buf[35]:32buf[36]:112buf[37]:97buf[38]:114buf[39]:97buf[40]:109buf[41]:101buf[42]:116buf[43]:101buf[44]:114buf[45]:115buf[46]:44buf[47]:45buf[48]:52buf[49]:10buf[50]:13
    at write: [11]AT+Close=1
    recv: 13, AT+Close=1

    buf[0]:65buf[1]:84buf[2]:43buf[3]:67buf[4]:108buf[5]:111buf[6]:115buf[7]:101buf[8]:61buf[9]:49buf[10]:13buf[11]:10buf[12]:13
    recv: 14, +close:1
    OK

    buf[0]:43buf[1]:99buf[2]:108buf[3]:111buf[4]:115buf[5]:101buf[6]:58buf[7]:49buf[8]:10buf[9]:13buf[10]:79buf[11]:75buf[12]:10buf[13]:13
    at write: [26]AT+Socket=INET,STREAM,TCP
    recv: 28, AT+Socket=INET,STREAM,TCP

    buf[0]:65buf[1]:84buf[2]:43buf[3]:83buf[4]:111buf[5]:99buf[6]:107buf[7]:101buf[8]:116buf[9]:61buf[10]:73buf[11]:78buf[12]:69buf[13]:84buf[14]:44buf[15]:83buf[16]:84buf[17]:82buf[18]:69buf[19]:65buf[20]:77buf[21]:44buf[22]:84buf[23]:67buf[24]:80buf[25]:13buf[26]:10buf[27]:13
    recv: 15, +socket:2
    OK

    buf[0]:43buf[1]:115buf[2]:111buf[3]:99buf[4]:107buf[5]:101buf[6]:116buf[7]:58buf[8]:50buf[9]:10buf[10]:13buf[11]:79buf[12]:75buf[13]:10buf[14]:13
    at write: [37]AT+SetSockOpt=2,SOCKET,NONBLOCKING,1
    recv: 47, AT+SetSockOpt=2,
    ERROR: parse parameters,-3

    buf[0]:65buf[1]:84buf[2]:43buf[3]:83buf[4]:101buf[5]:116buf[6]:83buf[7]:111buf[8]:99buf[9]:107buf[10]:79buf[11]:112buf[12]:116buf[13]:61buf[14]:50buf[15]:44buf[16]:13buf[17]:10buf[18]:13buf[19]:69buf[20]:82buf[21]:82buf[22]:79buf[23]:82buf[24]:58buf[25]:32buf[26]:112buf[27]:97buf[28]:114buf[29]:115buf[30]:101buf[31]:32buf[32]:112buf[33]:97buf[34]:114buf[35]:97buf[36]:109buf[37]:101buf[38]:116buf[39]:101buf[40]:114buf[41]:115buf[42]:44buf[43]:45buf[44]:51buf[45]:10buf[46]:13
    at write: [11]AT+Close=2
    recv: 13, AT+Close=2

    buf[0]:65buf[1]:84buf[2]:43buf[3]:67buf[4]:108buf[5]:111buf[6]:115buf[7]:101buf[8]:61buf[9]:50buf[10]:13buf[11]:10buf[12]:13
    recv: 14, +close:2
    OK

    buf[0]:43buf[1]:99buf[2]:108buf[3]:111buf[4]:115buf[5]:101buf[6]:58buf[7]:50buf[8]:10buf[9]:13buf[10]:79buf[11]:75buf[12]:10buf[13]:13
    at write: [26]AT+Socket=INET,STREAM,TCP
    recv: 28, AT+Socket=INET,STREAM,TCP

    buf[0]:65buf[1]:84buf[2]:43buf[3]:83buf[4]:111buf[5]:99buf[6]:107buf[7]:101buf[8]:116buf[9]:61buf[10]:73buf[11]:78buf[12]:69buf[13]:84buf[14]:44buf[15]:83buf[16]:84buf[17]:82buf[18]:69buf[19]:65buf[20]:77buf[21]:44buf[22]:84buf[23]:67buf[24]:80buf[25]:13buf[26]:10buf[27]:13
    recv: 15, +socket:3
    OK

    buf[0]:43buf[1]:115buf[2]:111buf[3]:99buf[4]:107buf[5]:101buf[6]:116buf[7]:58buf[8]:51buf[9]:10buf[10]:13buf[11]:79buf[12]:75buf[13]:10buf[14]:13
    at write: [37]AT+SetSockOpt=3,SOCKET,NONBLOCKING,1
    recv: 16, AT+SetSockOpt=3,
    buf[0]:65buf[1]:84buf[2]:43buf[3]:83buf[4]:101buf[5]:116buf[6]:83buf[7]:111buf[8]:99buf[9]:107buf[10]:79buf[11]:112buf[12]:116buf[13]:61buf[14]:51buf[15]:44

    BRs

    Leanshaw Zhao

  • Hi Jesu, Leanshaw,

    Just for record, I am not able to replicate those phenomenon from my side.

    In my test I didn't see the garbage data, so I think Leanshaw can provide captured waveform for further analysis. As for baud rate other than 115200 bps, I am able to work at 1Mbps rate without problem. However 3Mbps seems too aggressive and need further optimization for handling data traffic, I would recommend Leanshaw using 1Mbps and keep the ball rolling.

    As for \r\n delimiter, can we have an update on that? it seems base64 impact customer's system performance a lot, it would be great if we can fix that first. I will work with Leanshaw to fix the baud rate issue in their system.

    Thanks & regards,

    Jo

  • Hi Jo,

    I will submit a ticket internally to the R&D team. I can try to see if we can commit something to the next SDK release. We are currently dealing with some high priority bugs so I cannot make promises. If there is a time urgency the customer can try a workaround of maybe encoding \r and \n to something else and having the client decode it. Just a thought, I'm not sure how this impacts the customer application. 

    Jesus

  • OK, look forward to the update! Thanks for your assistance!

  • Hi Jesus and Jo,

    May I know when the next SDK will be release which AT+Send can transfer binary data including \r and \n ?

    BRs

    Leanshaw Zhao