Sunteți pe pagina 1din 29

SimpleLink™ Wi-Fi® Gen2

CC3220/CC3120 - Hands On Session


Raising the Bar

LOW POWER SECURTY TIME TO MARKET

TI Information - Selective Disclosure


Labs

1. CC3220 – Network Terminal example – Creating,


Building the Project& Flashing
2. CC3220 Portable + Wi-Fi
3. CC3220 Wi-Fi Secure Sockets

Sources: IHS Markit and Bain & Company

TI Information - Selective Disclosure

2
Prerequisites

Software:
1. Code Compose Studio v7.3 or higher
2. SimpleLink Wi-Fi CC3220 software development kit (SDK) v1.50.00.06 or later
3. Uniflash v4.2 or later
4. Terminal emulator program such as TeraTerm or PuTTY

Hardware:
1. CC3220S or CC3220SF LaunchPads (CC3220S-LAUNCHXL or CC3220SF-
LAUNCHXL)
2. Micro-USB cable (included with LaunchPad/BoosterPack)
3. Smartphone

TI Information - Selective Disclosure


3
Lab 1 – Network Terminal

In this lab, we are going to Create a project, Build and Program the
device using the Uniflash tool.

TI Information - Selective Disclosure


4
Lab 1 –Network Terminal – Creating and Building the Project

1. In CCS Open Project-> Import CCS Projects


2. Select (Browse to the
C:\ti\simplelink_cc32xx_sdk_1_50_00_06\examples\rtos\CC3220SF_LAUNCHXL\demos\network_terminal\tirtos\ccs)
network_terminal->ccs -> Click Ok, Click Finish, Build network_terminal_CC3220S_LAUNCHXL_tirtos_ccs
1 2 3 4

TI Information - Selective Disclosure


5
Lab 1 – Network Terminal – Programming using Uniflash

1. Connect the CC3220 Launchpad using


the micro USB cable to PC
2. Open Uniflash
3. Now the Device should get detected with
Uniflash.
4. Click on start
5. Select New Project
6. Provide suitable Project name and
Description
7. Select Device Type as CC3220SF
8. Click on Create Project

TI Information - Selective Disclosure


6
Lab 1 – Network Terminal – Programming using Uniflash…
1. In Files Section Click on User Files
1
2. Add the following file
(Path:C:\ti\simplelink_cc32xx_sdk_1_50_00_06\tools\cc32xx_tools\certificate-
playground/dummy-root-ca-cert) and click Write.
3. In the Actions menu, Select MCU Image, then click Browse.
Browse to the .bin we built earlier and open you should see the below screen
4. Next, we will need add the Private Key File that signs the MCU Image. We
saw in the User Files that we have the dummy-root-ca-cert already loaded in
this ImageCreator project. The key for this Root CA is provided in the
2
certificate playground in the SimpleLink CC3220 SDK. Browse to
C:/ti/simplelink_cc32xx_sdk_x_xx_xx_xx/tools/cc32xx_tools/certificate_playgr
ound/dummy-root-ca-cert-key and open.
5.Below, select the dummy-root-ca-cert as the Certification File Name. Once
your completed screen looks like the one below, press Write.(See Picture 2)
6. Select Service pack from Files Section -> Browse and Open from
C:\ti\simplelink_cc32xx_sdk_1_50_00_06\tools\cc32xx_tools\servicepack-
cc3x20\sp_3.5.0.0_2.0.0.0_2.2.0.5.bin
7. Select Trusted Root-Certficate Catalog from Files and Uncheck ‘Use Default
3
Trusted Root-Certficate Catalog’ box and then Browse and Open Source File
and Signature Source File respectively from
C:\ti\simplelink_cc32xx_sdk_1_50_00_06\tools\cc32xx_tools\certificate-
playground

TI Information - Selective Disclosure


7
Lab 1 – Network Terminal – Programming using Uniflash…
8. You can see the mcuflashimg.bin was added! Now, select Generate
Image on the right-hand menu.
9. Select Connect to initiate the connection with your LaunchPad
(anything holding the device COM port, such as a terminal window, will
need to be closed). Then, select Program Image.
10. You should see the programming complete dialog after success.

TI Information - Selective Disclosure


8
Lab 2 – Portable + Wi-Fi

In this lab, we are going to add HTTP server functionality to the Portable
project so users can read the temperature from a webpage hosted by
the SimpleLink™ Wi-Fi® CC3220 device.

The purpose of this lab is to demonstrate the portability of SimpleLink


MCU Platform. The Portable project exists as a common example
across all platforms, and we can implement Wi-Fi functionality by adding
functions to this baseline example.

TI Information - Selective Disclosure


9
Lab 2 – Portable + Wi-Fi… Task 1 – Import Portable Example
1. In CCS click on Projects tab and Click on Import CCS Projects
2. Browse under
C:\ti\simplelink_cc32xx_sdk_1_50_00_06\examples\rtos\CC3220SF_LAUNCHXL\demos\portable\tirt
os\ccs and select portable see below:
3. Build the project

TI Information - Selective Disclosure


10
Lab 2 – Portable + Wi-Fi… Task 2 - Set up the Portable example for Wi-Fi

1. Right-click on the Portable project name and select Properties


→ Build → ARM Linker → File Search Path
2. Click the document icon with the green plus next to "Include
library file...“
3 .Browse to your SimpleLink CC3220 SDK installation, then
source/ti/drivers/net/wifi/ccs/rtos/ and select simplelink.a. Select
OK. This is the pre-built SimpleLink Wi-Fi library.
3. Add the provided uart_term.h and uart_term.c files to your
Portable project. This code allows us to print format specifiers to
the UART terminal.

TI Information - Selective Disclosure


11
Lab 2 – Portable + Wi-Fi… Task 3 - Add the event handlers for the HTTP
Server

1. Add the provided httpserver.c and httpserver.h files to your Portable project. Please see Task 1, Step 3 of this training.

These files contain a shell for the HTTP server functionality. We are going to add to these files to finish the implementation.

2. Open httpserver.c and scroll down to the Callback Functions section (~line 430)

3. Take a look at the event handlers added for you:

• SimpleLinkWlanEventHandler(): Handles all incoming WLAN events by updating our control block for use elsewhere in the application.
An example of a WLAN event is a station (such as your mobile device) connecting to our Access Point (CC3220 LaunchPad).
• SimpleLinkFatalErrorEventHandler(): Alerts the user to a fatal error passed by the network processor.
• SimpleLinkNetAppEventHandler(): Handles network events such as IP acquired, IP leased, IP released, etc.
• SimpleLinkNetAppRequestEventHandler(): Handles all NetApp requests. It prepares incoming requests and passes them to the
message queue we use in the HTTP server thread. This callback is required for the functionality of the HTTP server.

TI Information - Selective Disclosure


12
Lab 2 – Portable + Wi-Fi… Task 4 - Customize the HTTP Server

case TempIdx_C:

pthread_mutex_lock(&temperatur
eMutex);
value = (int)temperatureC;

pthread_mutex_unlock(&temperat
ureMutex);

break;

case TempIdx_F:

pthread_mutex_lock(&temperatur
eMutex);
value = (int)temperatureF;

pthread_mutex_unlock(&temperat
ureMutex);

break;

TI Information - Selective Disclosure


13
Lab 2 – Portable + Wi-Fi… Task 4 - Customize the HTTP Server…

case LedValues_Off:
ledState = Board_LED_OFF;

break;

case LedValues_On:
ledState = Board_LED_ON;

break;

TI Information - Selective Disclosure


14
Lab 2 – Portable + Wi-Fi… Task 4 - Customize the HTTP Server…

{0, SL_NETAPP_REQUEST_HTTP_GET,
"/light", {{NULL}}, NULL}, {1,
SL_NETAPP_REQUEST_HTTP_POST,
"/light", {{NULL}}, NULL}, {2,
SL_NETAPP_REQUEST_HTTP_GET,
"/temp", {{NULL}}, NULL},

TI Information - Selective Disclosure


15
Lab 2 – Portable + Wi-Fi… Task 4 - Customize the HTTP Server…

httpRequest[0].charValues[0].characteristic = "redled";
httpRequest[0].charValues[0].value[0] = "off";
httpRequest[0].charValues[0].value[1] = "on";
httpRequest[0].charValues[0].value[2] = "toggle";
httpRequest[0].serviceCallback = lightGetCallback;
httpRequest[1].charValues[0].characteristic = "redled";
httpRequest[1].charValues[0].value[0] = "off";
httpRequest[1].charValues[0].value[1] = "on";
httpRequest[1].charValues[0].value[2] = "toggle";
httpRequest[1].serviceCallback = lightPostCallback;
httpRequest[2].charValues[0].characteristic = "tempc";
httpRequest[2].charValues[1].characteristic = "tempf";
httpRequest[2].serviceCallback = tempGetCallback;

TI Information - Selective Disclosure


16
Lab 2 – Portable + Wi-Fi… Task 5 - Start the HTTP Server

TI Information - Selective Disclosure


17
Lab 2 – Portable + Wi-Fi… Task 6 - Add TI-RTOS threads

#include <ti/drivers/net/wifi/simplelink.h>
#include <uart_term.h>

extern void *httpserverThread(void *arg0);

#define HTTP_STACK_SIZE (3072)


#define SL_TASK_STACK_SIZE (2048)

pthread_t spawnThread;
pthread_attr_t attrs_spawn;

SPI_init();
InitTerm();

TI Information - Selective Disclosure


18
Lab 2 – Portable + Wi-Fi… Task 6 - Add TI-RTOS threads…

/* 5 .Console thread */
// retc = pthread_create(&thread, &attrs,
consoleThread, NULL);
// if (retc != 0) {
// /* pthread_create() failed */
// while (1);
// }

/* 6. create the sl_Task */


pthread_attr_init(&attrs_spawn);
priParam.sched_priority = 9;
retc =
pthread_attr_setschedparam(&attrs_spawn,
&priParam);
retc |= pthread_attr_setstacksize(&attrs_spawn,
SL_TASK_STACK_SIZE);

retc = pthread_create(&spawnThread,
&attrs_spawn, sl_Task, NULL);
if(retc)
{
/* Handle Error */
UART_PRINT("Unable to create sl_Task
thread \n");
while(1);
}
TI Information - Selective Disclosure
19
Lab 2 – Portable + Wi-Fi… Task 6 - Add TI-RTOS threads…

/* HTTP Server thread */


priParam.sched_priority = 3;

pthread_attr_setschedparam(&attr
s, &priParam);
retc |=
pthread_attr_setstacksize(&attrs,
HTTP_STACK_SIZE);

retc = pthread_create(&thread,
&attrs, httpserverThread, NULL);
if (retc != 0) {
/* pthread_create() failed */
while (1);
}

TI Information - Selective Disclosure


20
Lab 2 – Portable + Wi-Fi… Task 7 – Program the device

TI Information - Selective Disclosure


21
Lab 2 – Portable + Wi-Fi… Task 7 – Program the device…

TI Information - Selective Disclosure


22
Lab 2 – Portable + Wi-Fi… Task 7 – Program the device…

TI Information - Selective Disclosure


23
Lab 2 – Portable + Wi-Fi… Task 8 – Test the demo!

TI Information - Selective Disclosure


24
Lab 3 – Wi-Fi Secure Sockets

SimpleLink supports sockets through BSD API. Secured sockets use TLS
or SSL cryptographic protocols. For simplicity, the TLS/SSL protocol is
embedded in the BSD layer. In this lab you can see the demonstration of
creating the non-secured and secured sockets and testing.

TI Information - Selective Disclosure


25
Lab 3 – Wi-Fi Secure Sockets … Task 1 - Testing unsecured TCP socket

1. Using the Uniflash Image Creator that was built in the Lab 1 program the device
2. For this lab please pair with your neighbor to run server/client

TI Information - Selective Disclosure


26
Lab 3 – Wi-Fi Secure Sockets … Task 1 - Testing unsecured TCP socket

TI Information - Selective Disclosure


27
Lab 3 – Wi-Fi Secure Sockets … Task 2 – Adding Security to the TCP Socket

TI Information - Selective Disclosure


28
Lab 3 – Wi-Fi Secure Sockets … Task 2 – Adding Security to the TCP Socket..

TI Information - Selective Disclosure


29

S-ar putea să vă placă și