Staging:CC3220 Serial Wifi (Texas Instruments NDA restrictions applicable)

Overview
Serial WiFi is a capability designed to provide easy, self-contained terminal access behavior, over UART interface. This provides a ‘driver-less’ solution and allows out-of-the box operation based on ASCII character set interpretation. This application runs over the UART interface and behaves as a command line interpreter. Leveraging the complete network stack integration it allows secure, robust end-to-end communication.

Application details
The serial WiFi application supports the following features: 1. Support to connect to ENT/Personal network 2. Auto discovery of available peer using mDNS 3. All communication is secure using the Secure Sockets 4. Once configured to a network, auto connect to the AP on every boot 5. Provision to override default mnemonic strings 6. Local/Remote Control modes, to issue commands to the locally/remotely connected simplelink device.

The Serial WiFi application basically operates in 3 modes: 1. Terminal/Interpreter mode: In this case the interpreter mode behaves as pure point-to-point cable replacement. This is the most common and obvious use in which a serial cable formerly used to carry information is replaced by SimpleLink devices on both end of the line. 2. Local control mode: In this mode it is possible to issue commands to the locally connected device. These commands encompass a close set of options to control the SimpleLink device while guaranteeing sandbox restrictions. The mode is entered using a predefined escape sequence (//&lt;) 3. Remote control mode: This allows issuing commands to the remotely connected device. These commands encompass the same set of options to control the remote SimpleLink as the local device, while guaranteeing sandbox restrictions. The mode is entered using a predefined escape sequence(//&gt;)

Caution: Current time must be set in the device. This time is used to validate the certificate. If the date is beyond the validity period of Certificate, sl_connect will return error. Please update the below macros in the serial_wifi.h file to change date.


 * 1) define DATE               18    /* Current Date */
 * 2) define MONTH              1     /* Month 1-12 */
 * 3) define YEAR               2016  /* Current year */
 * 4) define HOUR               12    /* Time - hours */
 * 5) define MINUTE             32    /* Time - minutes */
 * 6) define SECOND             0     /* Time - seconds */

Source Files briefly explained

 * main.c - creates to 2 tasks, Task 1: the interpreter task to opertate the serial wifi functionality, Task 2: The UART task to receive data from the UART.
 * serial_wifi.c - All the functionality of the serial wifi is implemented.
 * uart_config.c - Configures the UART and the task to send and receive chars over the UART.
 * conversions.c - All conversion utility API into different number formats.
 * pinmux.c - Pinmux configurations as required by the application.
 * cc_launchpad.c - Initializes peripherals.
 * network_if.c - Functions for network interface.
 * timer_if.c - Functions to control timer.
 * uart_if.c - Functions to display information on UART.
 * startup_*.c - IDE specific startup functions (not required when working with TI-RTOS).

Usage
1. Flash the serial wifi code onto both the devices. 2. Upon Reset, the device connects to the stored AP by the AUTO connect policy.If the device doesn't connect to an AP in 6secs, the application prompts the user to connect to a known AP using the Local control mode. User can use the below command to connect to an AP

wlan_connect [ssid] [type] [Sec] [User] [key] in the local control mode.

3. If this is the first boot after an SFALSH erase, one of the devices need to be configured for as mDNS server. This can be done by using the below command in local control mode.

mDNS 0  &lt;0-server, 1-client&gt; in the local control mode.

4. The client device automatically connects to the advertiser.

5. The communication is based on secure sockets. So, the server key, server certificate, client certificate need to be flashed in the SFLASH at file IDs 129,130,131 respectively. Please refer the Generating SSL certificates section for generating certificates using OpenSSL. For flashing the certificates using Image Creator:(For detailed instructions about using Image Creator, refer Image Creator User Guide.) 1. Click "add file" 2. Rename the newly created file to "/cert/129.der" 3. In the Url field mention the local path to the Server key certificate. 4. Repeat the above steps for "/cert/130.der" and "/cert/131.der" for server key and client certificate respectively. 5. Check the Erase and Update check boxes and "program" 6. Now the devices are connected in Interpreter mode. 7. ‘//&lt;’ command is used to enter the local control mode, mode in which we control the local CC3220 device. 8. ‘//&gt;’ command is used to enter the remote control mode, mode to control the remote CC3220 device. 9. Commands supported in the control modes are:

10. All communication is secure using the Secure sockets, Security method :SSLV3 and Cipher : RSA WITH RC4 128 SHA.



Generating certificates using OpenSSL
The following are the steps for generating certificates using OpenSSL tool. Install OpenSSl and run the following commands: Generate a CA 1)   openssl req -out ca.pem -new -x509  -generates CA file "ca.pem" and CA key "privkey.pem"

Generate server certificate/key pair  2)   openssl genrsa -out server.key 1024  3)    openssl req -key server.key -new -out server.req 4)   openssl x509 -req -in server.req -CA CA.pem -CAkey privkey.pem -CAserial file.srl -out server.pem  -contents of "file.srl" is a two digit number.  eg. "00"  5)    Convert the certificates and key generated to DER format. For certificates openssl x509 -in  -inform PEM –out  -outform DER For key rsa -in input.key -inform PEM -out output.key -outform DER 6) Flash the server key and the server certificate at /cert/129.der and /cert/130.der respectively. 7) Flash the CA certificate at /cert/131.der.

Limitations/Known Issues
None.