Documente Academic
Documente Profesional
Documente Cultură
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
In this lab, we are going to Create a project, Build and Program the
device using the Uniflash tool.
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.
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)
• 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.
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;
case LedValues_Off:
ledState = Board_LED_OFF;
break;
case LedValues_On:
ledState = Board_LED_ON;
break;
{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},
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;
#include <ti/drivers/net/wifi/simplelink.h>
#include <uart_term.h>
pthread_t spawnThread;
pthread_attr_t attrs_spawn;
SPI_init();
InitTerm();
/* 5 .Console thread */
// retc = pthread_create(&thread, &attrs,
consoleThread, NULL);
// if (retc != 0) {
// /* pthread_create() failed */
// while (1);
// }
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…
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);
}
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.
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