Staging:CC32xx Email Demo Application Provisioning Addon

The E-mail Setup
The email application on the CC3200 sends emails using SMTP (Simple Mail Transfer Protocol). The email application sends a preconfigured email at the push of a button or a user-configured email through the CLI (Command Line Interface).

Figure 1 Sample Setup showcasing the Simple Email Application CC3200 Connects to the SMTP Server via WIFI Access Point which is connected to Internet. CC3200 sends the email to SMTP Server which then forwards it to the recipient Email Server. Recipient receives Email from the Email Server using IMAP/POP3 and other proprietary protocol.

Receiving Email is not in the scope of this Application.

System Overview
Figure 2 CC3200 System Overview CC3200 Simple Email Application


 * SMTP Server Connection


 * - TCP Connection(Unsecure/Secure) with Google/Yahoo SMTP Server


 * SMTP Protocol


 * - Authentication with SMTP Server
 * - Form SMTP packet with Source Email, Recipient Email, Subject, Message etc
 * - Send SMTP packet to Server


 * LED Control


 * - Controls LEDs to display Device Status


 * UART Command Handler


 * - Receive Command from UART Terminal and Send Response


 * Interrupt Handler


 * - Handles Push Button Interrupt to Trigger Email
 * - Handles Push Button Interrupt to Start AP provisioning procedure

Source Files briefly explained

 * main - Simple Application demonstrating Email Client Functionalities.
 * button_if - Interface file to handle button click events.
 * gpio_if - GPIO interface file which handles all LED events.
 * network_if - Network interface file which handles all network connection events.
 * pinmux - Pinmux file to configure GPIO & UART
 * timer_if - Interface file to handle all Timer events
 * uart_if - Interface file which receives command from UART and output Logging Information on UART Terminal


 * netapps\smtp\client- libemail is Platform Indepedent Library and can be Integrated to any Email Client Software using below APIs
 * sl_NetAppEmailSet - Configure SMTP Server, Login Information, Recipient Email Id, Email Subject etc
 * sl_NetAppEmailConnect- Connect to SMTP Server
 * sl_NetAppEmailSend- Send Email

Email Application Sequence
Email/SMTP library is available under '\netapps\smtp\client\' folder.

Figure 3 Normal operation sequence flow
 * 1) Client makes TCP Connection with SMTP Server.
 * 2) SMTP Server responds with Response code and Greeting Message containing FQDN
 * 3) HELO/EHLO – Client sends Hello Message to the Server. ESMTP accepts EHLO
 * 4) The SMTP Server replies with Code 250 and Hello Message. ESMTP Server replies with SMTP extensions it supports such as Email maximum Size, authentication etc.
 * 5) If SMTP Server requires authentication, The Client Sends “auth login” followed by “Username” and “Password” encoded with proper encryption accepted by SMTP Server.


 * auth login
 * 334 VXNlcm5hbWU6

6. Client Sends Username Encoded with Proper encryption accepted by SMTP Server


 * a2F1c2hmmdmdmdmhbGt1a2thckBnhfjdhfdjjsksbWFpbC5jb20

7. Client Sends Password Encoded with Proper encryption accepted by SMTP Server


 * 334 UGFzc3dvcmQ6
 * Mlklkdldldl21haWxhYjskjdkskjss2Mzc3M=

8. SMTP Server replies with Authentication Success/Failure.


 * 535 Incorrect authentication data/ 235 Authentication Successful

9. SMTP Client sends From Address


 * MAIL FROM: xyz@abc.com

10. SMTP Client sends TO Address


 * RCPT TO: abc@ti.com

11. SMTP Client sends DATA command


 * DATA

12. SMTP Client sends email data.

13. SMTP Server responds with the acknowledgement

Prerequisites
* Hardware


 * o CC3200 Launch Pad

* Software


 * o Terminal Application such as Tera Term, Hyperterminal etc
 * o CC3200 Email Application
 * o TI WiFi Starter Pro Application

Use your own email-id & password in source code by modifying few MACROs in demo_config.h file and build the project before running the application. This example can be used either on TI-RTOS or FreeRTOS.
 * 1) define USER                   "" //Set Sender/Source Email Address
 * 2) define USER_RFC               "" //Set Sender/Source Email Address
 * 3) define PASS                   " "              //Set Sender/Source Email Password
 * 4) define RCPT_RFC               "" //Set Recipient Email Address

For the application to work with TI-RTOS, oslib project and ti_rtos_config project need to be imported into the application workspace. These projects can be found in CC3200-SDK under oslib and ti_rtos folder. Please follow this link for CC3200 TI-RTOS usage CC3200 TI-RTOS

Getting the Setup Ready

 * 1) Run the reference application (Flashing the bin/IAR/CCS)
 * 2) *Open the Project in IAR/CCS IDE.
 * 3) *Email Demo Application on CCS runs on TI RTOS which requires additional tools to be Installed. Refer to CC3200 TI-RTOS for more information.
 * 4) *Build and download the application to the board.
 * 5) For better understanding of the Hardware Setup, please see the image below



Working
a. Send Email from UART Terminal


 * Open UART terminal application such as HyperTerminal/Tera term etc. Select the USB Serial port named with 'CC3200LP' from all the ports listed under device manager.
 * Select Baud Rate to be 115200 and Connect.
 * Once device turns ON successfully, Green LED will turn ON.
 * UART Terminal application should show Below output

Note – Option 02 is reserved for Source Email Configuration in next SDK release
 * Connection to AP - Follow one of the below method
 * Connection to Preconfigured AP
 * An Access Point (AP) with SSID as “cc3200demo” is required as it is hard coded in the bin files. Also the AP Security type is Set to “Open”
 * Enter 01 to give Connect command
 * Connect using AP Provisioning
 * Enter 06 from UART Terminal
 * User needs to provision the device using AP provisioning. The procedure is a little different for Android and iOS, where additional steps are required for iOS. To provision the device using iOS, the following steps need to be followed:
 * Connect your Smartphone to the selected AP.
 * Launch TI WiFi Starter Pro Application. [[Image:provisioning main page.png|center|300px|provisioning main page.png]]
 * Click the Device to configure and follow the pop up message to direct you to the WiFi Settings. Choose your device SSID starting with mysimplelink- and concatenated with a portion of the MAC address. [[Image:provisioning choose device to configure.png|center|300px|provisioning choose device to configure.png]]
 * If the name of the network for provisioning is not automatically shown in WiFi Network field, click the drop down and pick the desired network from the list. Enter the Network Password in case it is a secured network. For open network, leave the 'Password' field blank. [[Image:provisioning fill credentials.png|center|300px|provisioning fill credentials.png]]
 * The name of the device is filled automatically but can be modified. This will be used to identify your device.
 * Press START CONFIGURATION button to start the procedure.
 * Once the provisioning process is completed, a pop-up windows shows up to indicate that the new device is connected to the network. [[Image:provisioning successful.png|center|300px|provisioning successful.png]]
 * Once provisioning is Successful, CC3200 device will connect to the AP and print its IP address on UART Terminal as shown below. Also note the messages indicating the start and finish points for the provisioning.


 * Red LED will start blinking and will turn ON once connection is successful. Usually it will take 1-10 seconds for the AP connection. If LED keeps blinking, Please check AP SSID name and Security Settings.
 * When Terminal Shows IP Address, Send Command 03 to Set Recipient Email Address and Subject
 * When Terminal Shows OK, Send Command 04 to Set Email Content
 * When Terminal Shows OK, Send 05 to Send Email
 * If Email is Sent Successful Orange LED will blink 5 times and Terminal will show Message “Message Sent”
 * Terminal may show “Server Connection Error”, “Authentication Failed” etc. If “Server Connection Error”, Please Send 05 again.




 * Open an Email Application and check Email. You Will receive an Email from cc32xx.apps@gmail.com

b. Trigger Email from Push Button


 * Turn on the Device
 * Once device turns ON successfully, Green LED will turn ON.
 * Configuration of AP - Follow one of the below method
 * Preconfigured AP
 * An Access Point (AP) with SSID as “cc3200demo” is required as it is hard coded in the bin files. Also the AP Security type is Set to “Open”
 * AP Provisioning
 * Press Push Button S2
 * Start TI WiFi Starter Pro application and start provisioning
 * Wait till Red LED turns ON
 * Press Push Button S3 to send Email.
 * If Connection is successful, Email will be sent to cc32xx.apps@gmail.com . If user wishes to change this address, it can be changed in Email source code demo_config.h.
 * If Email is Sent Successfully Orange LED will blink 5 times
 * Open an Email Application and check Email. You Will receive an Email from cc32xx.apps@gmail.com as below


 * Hello from Simplelink! The CC32xx connects new devices to the internet!”
 * Hello from Simplelink! The CC32xx brings Wi-Fi to battery operated devices!”
 * Hello from Simplelink! The CC32xx enables creating IOT products FAST!”

= Limitations/Known Issues =

It only implements a limited set of functionality and has some limitations.


 * 1) Email is sent to only 1 recipient.
 * 2) Only plain text Email is Supported