Other Parts Discussed in Thread: CC3135, CC3120
Hi All,
What is the difference between calling network API compare to at command?
When should I call AT Command?
Best Regards
nilezt
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.
Hi All,
What is the difference between calling network API compare to at command?
When should I call AT Command?
Best Regards
nilezt
Hi Nilezt,
The SimpleLink host driver APIs provides a native mechanism to interface with the CC3220 network processor (NWP) at a low level. That being said, you will need to write your application to use those networking APIs in a way that will be useful to your use case.
For example, if you wanted to simply send the string "Hello Server" to google.com, the following code will be what you'd write:
sl_Start(0,0,0);
SlSockAddrIn_t Addr;
unsigned int uiIP;
int iSockID;
SlSecParams_t secParams = {0};
secParams.Key = “password123”;
secParams.KeyLen = 11;
secParams.Type = SL_SEC_TYPE_WPA2;
sl_WlanConnect(“MyAPName”, 8, 0, &secParams, 0);
while((!IS_CONNECTED(g_ulStatus)) || (!IS_IP_ACQUIRED(g_ulStatus))) sl_Task();
sl_NetAppDnsGetHostByName(“www.google.com”, 14, (unsigned long*)&uiIP, SL_AF_INET);
Addr.sin_family = SL_AF_INET;
Addr.sin_port = sl_Htons(80);
Addr.sin_addr.s_addr = sl_Htonl(uiIP);
iSockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
sl_Connect(iSockID, ( SlSockAddr_t *)&Addr, sizeof(SlSockAddrIn_t));
sl_Send(iSockID, “Hello server.”, 14, 0 );
That code starts the NWP, connects the device to an AP, gets the IP address of www.google.com, and then opens a TCP socket and sends over the "Hello server" message.
This networking code is simple to write, but one challenge that users run into is how to handle receiving and executing networking functions in response to the inputs from another device. For example, if you have the CC3220 connected to a main processor, you will need to write application code to handle the low-level serial interface, input parsing, state machine, etc.
That is where the AT command library comes in. It is designed to allow for the CC3220 to be dropped into a system where there is already a main processor/MCU, and have an easy-to-use, standard interface over serial that makes for much more straightforward programming of the CC3220 to handle interaction with the main MCU.
Of course, the AT command library is just a pre-written abstraction layer and application that in the end is implemented in network APIs. But if you want to drop in a CC3220 and have that premade interface, it could be useful for that purpose.
Do note that if you wanted to use the CC3220 strictly as a Wi-Fi coprocessor, there is also the CC3120 and CC3135 products. Those devices are NWP-only devices which would be more suited to that use case.
Let me know if you need more clarification or have further questions on the CC3220 interface options.
Regards,
Michael