TI's CC3100 host driver and demo. Experimental and a work in progress.

Dependencies:   mbed

Committer:
dflet
Date:
Mon Nov 17 19:38:34 2014 +0000
Revision:
0:bbe98578d4c0
Experimental and a work in progress. Mostly left as TI C code. Does compile and run, but I have seen a few glitches. cc3100_sl_common.h will need your ssid and pass key at line 82.....

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 0:bbe98578d4c0 1 /*
dflet 0:bbe98578d4c0 2 * simplelink.h - CC31xx/CC32xx Host Driver Implementation
dflet 0:bbe98578d4c0 3 *
dflet 0:bbe98578d4c0 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 0:bbe98578d4c0 5 *
dflet 0:bbe98578d4c0 6 *
dflet 0:bbe98578d4c0 7 * Redistribution and use in source and binary forms, with or without
dflet 0:bbe98578d4c0 8 * modification, are permitted provided that the following conditions
dflet 0:bbe98578d4c0 9 * are met:
dflet 0:bbe98578d4c0 10 *
dflet 0:bbe98578d4c0 11 * Redistributions of source code must retain the above copyright
dflet 0:bbe98578d4c0 12 * notice, this list of conditions and the following disclaimer.
dflet 0:bbe98578d4c0 13 *
dflet 0:bbe98578d4c0 14 * Redistributions in binary form must reproduce the above copyright
dflet 0:bbe98578d4c0 15 * notice, this list of conditions and the following disclaimer in the
dflet 0:bbe98578d4c0 16 * documentation and/or other materials provided with the
dflet 0:bbe98578d4c0 17 * distribution.
dflet 0:bbe98578d4c0 18 *
dflet 0:bbe98578d4c0 19 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 0:bbe98578d4c0 20 * its contributors may be used to endorse or promote products derived
dflet 0:bbe98578d4c0 21 * from this software without specific prior written permission.
dflet 0:bbe98578d4c0 22 *
dflet 0:bbe98578d4c0 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 0:bbe98578d4c0 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 0:bbe98578d4c0 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 0:bbe98578d4c0 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 0:bbe98578d4c0 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 0:bbe98578d4c0 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 0:bbe98578d4c0 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 0:bbe98578d4c0 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 0:bbe98578d4c0 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 0:bbe98578d4c0 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 0:bbe98578d4c0 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 0:bbe98578d4c0 34 *
dflet 0:bbe98578d4c0 35 */
dflet 0:bbe98578d4c0 36
dflet 0:bbe98578d4c0 37
dflet 0:bbe98578d4c0 38 /*!
dflet 0:bbe98578d4c0 39 \mainpage SimpleLink Driver
dflet 0:bbe98578d4c0 40
dflet 0:bbe98578d4c0 41 \section intro_sec Introduction
dflet 0:bbe98578d4c0 42
dflet 0:bbe98578d4c0 43 The SimpleLink CC31xx/CC2xx family allows to add Wi-Fi and networking capabilities
dflet 0:bbe98578d4c0 44 to low-cost embedded products without having prior Wi-Fi, RF or networking expertise.
dflet 0:bbe98578d4c0 45 The CC31xx/CC32xx is an ideal solution for microcontroller-based sensor and control
dflet 0:bbe98578d4c0 46 applications such as home appliances, home automation and smart metering.
dflet 0:bbe98578d4c0 47 The CC31xx/CC32xx has integrated a comprehensive TCP/IP network stack, Wi-Fi driver and
dflet 0:bbe98578d4c0 48 security supplicant leading to easier portability to microcontrollers, to an
dflet 0:bbe98578d4c0 49 ultra-low memory footprint, all without compromising the capabilities and robustness
dflet 0:bbe98578d4c0 50 of the final application.
dflet 0:bbe98578d4c0 51
dflet 0:bbe98578d4c0 52
dflet 0:bbe98578d4c0 53
dflet 0:bbe98578d4c0 54 \section modules_sec Module Names
dflet 0:bbe98578d4c0 55 To make it simple, TI's SimpleLink CC31xx/CC32xx platform capabilities were divided into modules by topic (Silo).
dflet 0:bbe98578d4c0 56 These capabilities range from basic device management through wireless
dflet 0:bbe98578d4c0 57 network configuration, standard BSD socket and much more.
dflet 0:bbe98578d4c0 58 Listed below are the various modules in the SimpleLink CC31xx/CC32xx driver:
dflet 0:bbe98578d4c0 59 -# \ref device - controls the behaviour of the CC31xx/CC32xx device (start/stop, events masking and obtaining specific device status)
dflet 0:bbe98578d4c0 60 -# \ref wlan - controls the use of the WiFi WLAN module including:
dflet 0:bbe98578d4c0 61 - Connection features, such as: profiles, policies, SmartConfig�
dflet 0:bbe98578d4c0 62 - Advanced WLAN features, such as: scans, rx filters and rx statistics collection
dflet 0:bbe98578d4c0 63 -# \ref socket - controls standard client/server sockets programming options and capabilities
dflet 0:bbe98578d4c0 64 -# \ref netapp - activates networking applications, such as: HTTP Server, DHCP Server, Ping, DNS and mDNS.
dflet 0:bbe98578d4c0 65 -# \ref netcfg - controls the configuration of the device addresses (i.e. IP and MAC addresses)
dflet 0:bbe98578d4c0 66 -# \ref FileSystem - provides file system capabilities to TI's CC31XX that can be used by both the CC31XX device and the user.
dflet 0:bbe98578d4c0 67
dflet 0:bbe98578d4c0 68
dflet 0:bbe98578d4c0 69 \section proting_sec Porting Guide
dflet 0:bbe98578d4c0 70
dflet 0:bbe98578d4c0 71 The porting of the SimpleLink driver to any new platform is based on few simple steps.
dflet 0:bbe98578d4c0 72 This guide takes you through this process step by step. Please follow the instructions
dflet 0:bbe98578d4c0 73 carefully to avoid any problems during this process and to enable efficient and proper
dflet 0:bbe98578d4c0 74 work with the device.
dflet 0:bbe98578d4c0 75 Please notice that all modifications and porting adjustments of the driver should be
dflet 0:bbe98578d4c0 76 made in the user.h header file only.
dflet 0:bbe98578d4c0 77 Keep making any of the changes only in this file will ensure smoothly transaction to
dflet 0:bbe98578d4c0 78 new versions of the driver at the future!
dflet 0:bbe98578d4c0 79
dflet 0:bbe98578d4c0 80
dflet 0:bbe98578d4c0 81 \subsection porting_step1 Step 1 - Create your own user.h file
dflet 0:bbe98578d4c0 82
dflet 0:bbe98578d4c0 83 The first step is to create a user.h file that will include your configurations and
dflet 0:bbe98578d4c0 84 adjustments. You can use the empty template provided as part of this driver or
dflet 0:bbe98578d4c0 85 you can choose to base your file on file from one of the wide range of examples
dflet 0:bbe98578d4c0 86 applications provided by Texas Instruments
dflet 0:bbe98578d4c0 87
dflet 0:bbe98578d4c0 88
dflet 0:bbe98578d4c0 89 \subsection porting_step2 Step 2 - Select the capabilities set required for your application
dflet 0:bbe98578d4c0 90
dflet 0:bbe98578d4c0 91 Texas Instruments made a lot of efforts to build set of predefined capability sets that would
dflet 0:bbe98578d4c0 92 fit most of the target application.
dflet 0:bbe98578d4c0 93 It is recommended to try and choose one of this predefined capabilities set before going to
dflet 0:bbe98578d4c0 94 build your own customized set. If you find compatible set you can skip the rest of this step.
dflet 0:bbe98578d4c0 95
dflet 0:bbe98578d4c0 96 The available sets are:
dflet 0:bbe98578d4c0 97 -# SL_TINY - Compatible to be used on platforms with very limited resources. Provides
dflet 0:bbe98578d4c0 98 the best in class foot print in terms of Code and Data consumption.
dflet 0:bbe98578d4c0 99 -# SL_SMALL - Compatible to most common networking applications. Provide the most
dflet 0:bbe98578d4c0 100 common APIs with decent balance between code size, data size, functionality
dflet 0:bbe98578d4c0 101 and performances
dflet 0:bbe98578d4c0 102 -# SL_FULL - Provide access to all SimpleLink functionalities
dflet 0:bbe98578d4c0 103
dflet 0:bbe98578d4c0 104
dflet 0:bbe98578d4c0 105 \subsection porting_step3 Step 3 - Bind the device enable/disable output line
dflet 0:bbe98578d4c0 106
dflet 0:bbe98578d4c0 107 The enable/disable line (nHib) provide mechanism to enter the device into the least current
dflet 0:bbe98578d4c0 108 consumption mode. This mode could be used when no traffic is required (tx/rx).
dflet 0:bbe98578d4c0 109 when this line is not connected to any IO of the host this define should be left empty.
dflet 0:bbe98578d4c0 110 Not connecting this line results in ability to start the driver only once.
dflet 0:bbe98578d4c0 111
dflet 0:bbe98578d4c0 112
dflet 0:bbe98578d4c0 113 \subsection porting_step4 Step 4 - Writing your interface communication driver
dflet 0:bbe98578d4c0 114
dflet 0:bbe98578d4c0 115 The SimpleLink device support several standard communication protocol among SPI and
dflet 0:bbe98578d4c0 116 UART. Depending on your needs and your hardware design, you should choose the
dflet 0:bbe98578d4c0 117 communication channel type.
dflet 0:bbe98578d4c0 118 The interface for this communication channel should include 4 simple access functions:
dflet 0:bbe98578d4c0 119 -# open
dflet 0:bbe98578d4c0 120 -# close
dflet 0:bbe98578d4c0 121 -# read
dflet 0:bbe98578d4c0 122 -# write
dflet 0:bbe98578d4c0 123
dflet 0:bbe98578d4c0 124 The way this driver would be implemented is directly effecting the efficiency and
dflet 0:bbe98578d4c0 125 the performances of the SimpleLink device on this platform.
dflet 0:bbe98578d4c0 126 If your system has DMA you should consider to use it in order to increase the utilization
dflet 0:bbe98578d4c0 127 of the communication channel
dflet 0:bbe98578d4c0 128 If you have enough memory resources you should consider using a buffer to increase the
dflet 0:bbe98578d4c0 129 efficiency of the write operations.
dflet 0:bbe98578d4c0 130
dflet 0:bbe98578d4c0 131
dflet 0:bbe98578d4c0 132 \subsection porting_step5 Step 5 - Choose your memory management model
dflet 0:bbe98578d4c0 133
dflet 0:bbe98578d4c0 134 The SimpleLink driver support two memory models:
dflet 0:bbe98578d4c0 135 -# Static (default)
dflet 0:bbe98578d4c0 136 -# Dynamic
dflet 0:bbe98578d4c0 137
dflet 0:bbe98578d4c0 138 If you choose to work in dynamic model you will have to provide alloc and free functions
dflet 0:bbe98578d4c0 139 to be used by the Simple Link driver otherwise nothing need to be done.
dflet 0:bbe98578d4c0 140
dflet 0:bbe98578d4c0 141
dflet 0:bbe98578d4c0 142 \subsection porting_step6 Step 6 - OS adaptation
dflet 0:bbe98578d4c0 143
dflet 0:bbe98578d4c0 144 The SimpleLink driver could run on two kind of platforms:
dflet 0:bbe98578d4c0 145 -# Non-Os / Single Threaded (default)
dflet 0:bbe98578d4c0 146 -# Multi-Threaded
dflet 0:bbe98578d4c0 147
dflet 0:bbe98578d4c0 148 If you choose to work in multi-threaded environment under operating system you will have to
dflet 0:bbe98578d4c0 149 provide some basic adaptation routines to allow the driver to protect access to resources
dflet 0:bbe98578d4c0 150 for different threads (locking object) and to allow synchronization between threads (sync objects).
dflet 0:bbe98578d4c0 151 In additional the driver support running without dedicated thread allocated solely to the simple
dflet 0:bbe98578d4c0 152 link driver. If you choose to work in this mode, you should also supply a spawn method that
dflet 0:bbe98578d4c0 153 will enable to run function on a temporary context.
dflet 0:bbe98578d4c0 154
dflet 0:bbe98578d4c0 155
dflet 0:bbe98578d4c0 156 \subsection porting_step7 Step 7 - Set your asynchronous event handlers routines
dflet 0:bbe98578d4c0 157
dflet 0:bbe98578d4c0 158 The SimpleLink device generate asynchronous events in several situations.
dflet 0:bbe98578d4c0 159 These asynchronous events could be masked.
dflet 0:bbe98578d4c0 160 In order to catch these events you have to provide handler routines.
dflet 0:bbe98578d4c0 161 Please notice that if you not provide a handler routine and the event is received,
dflet 0:bbe98578d4c0 162 the driver will drop this event without any indication of this drop.
dflet 0:bbe98578d4c0 163
dflet 0:bbe98578d4c0 164
dflet 0:bbe98578d4c0 165 \subsection porting_step8 Step 8 - Run diagnostic tools to validate the correctness of your porting
dflet 0:bbe98578d4c0 166
dflet 0:bbe98578d4c0 167 The driver is delivered with some porting diagnostic tools to simplify the porting validation process
dflet 0:bbe98578d4c0 168 and to reduce issues latter. It is very important to follow carefully this process.
dflet 0:bbe98578d4c0 169
dflet 0:bbe98578d4c0 170 The diagnostic process include:
dflet 0:bbe98578d4c0 171 -# Validating Interface Communication Driver
dflet 0:bbe98578d4c0 172 -# Validating OS adaptation layer
dflet 0:bbe98578d4c0 173 -# Validating HW integrity
dflet 0:bbe98578d4c0 174 -# Validating basic work with the device
dflet 0:bbe98578d4c0 175
dflet 0:bbe98578d4c0 176
dflet 0:bbe98578d4c0 177 \section sw_license License
dflet 0:bbe98578d4c0 178
dflet 0:bbe98578d4c0 179 *
dflet 0:bbe98578d4c0 180 *
dflet 0:bbe98578d4c0 181 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 0:bbe98578d4c0 182 *
dflet 0:bbe98578d4c0 183 *
dflet 0:bbe98578d4c0 184 * Redistribution and use in source and binary forms, with or without
dflet 0:bbe98578d4c0 185 * modification, are permitted provided that the following conditions
dflet 0:bbe98578d4c0 186 * are met:
dflet 0:bbe98578d4c0 187 *
dflet 0:bbe98578d4c0 188 * Redistributions of source code must retain the above copyright
dflet 0:bbe98578d4c0 189 * notice, this list of conditions and the following disclaimer.
dflet 0:bbe98578d4c0 190 *
dflet 0:bbe98578d4c0 191 * Redistributions in binary form must reproduce the above copyright
dflet 0:bbe98578d4c0 192 * notice, this list of conditions and the following disclaimer in the
dflet 0:bbe98578d4c0 193 * documentation and/or other materials provided with the
dflet 0:bbe98578d4c0 194 * distribution.
dflet 0:bbe98578d4c0 195 *
dflet 0:bbe98578d4c0 196 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 0:bbe98578d4c0 197 * its contributors may be used to endorse or promote products derived
dflet 0:bbe98578d4c0 198 * from this software without specific prior written permission.
dflet 0:bbe98578d4c0 199 *
dflet 0:bbe98578d4c0 200 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 0:bbe98578d4c0 201 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 0:bbe98578d4c0 202 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 0:bbe98578d4c0 203 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 0:bbe98578d4c0 204 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 0:bbe98578d4c0 205 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 0:bbe98578d4c0 206 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 0:bbe98578d4c0 207 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 0:bbe98578d4c0 208 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 0:bbe98578d4c0 209 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 0:bbe98578d4c0 210 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 0:bbe98578d4c0 211 *
dflet 0:bbe98578d4c0 212 */
dflet 0:bbe98578d4c0 213
dflet 0:bbe98578d4c0 214
dflet 0:bbe98578d4c0 215
dflet 0:bbe98578d4c0 216 #ifndef __SIMPLELINK_H__
dflet 0:bbe98578d4c0 217 #define __SIMPLELINK_H__
dflet 0:bbe98578d4c0 218
dflet 0:bbe98578d4c0 219 #include "cc3100_user.h"
dflet 0:bbe98578d4c0 220
dflet 0:bbe98578d4c0 221 #ifdef __cplusplus
dflet 0:bbe98578d4c0 222 extern "C"
dflet 0:bbe98578d4c0 223 {
dflet 0:bbe98578d4c0 224 #endif
dflet 0:bbe98578d4c0 225
dflet 0:bbe98578d4c0 226
dflet 0:bbe98578d4c0 227 /*! \attention Async event activation notes
dflet 0:bbe98578d4c0 228 Function prototypes for event callback handlers
dflet 0:bbe98578d4c0 229 Event handler function names should be defined in the user.h file
dflet 0:bbe98578d4c0 230 e.g.
dflet 0:bbe98578d4c0 231 "#define sl_WlanEvtHdlr SLWlanEventHandler"
dflet 0:bbe98578d4c0 232 Indicates all WLAN events are handled by User func "SLWlanEventHandler"
dflet 0:bbe98578d4c0 233 Important notes:
dflet 0:bbe98578d4c0 234 1. Event handlers cannot activate another SimpleLink API from the event's context
dflet 0:bbe98578d4c0 235 2. Event's data is valid during event's context. Any application data
dflet 0:bbe98578d4c0 236 which is required for the user application should be copied or marked
dflet 0:bbe98578d4c0 237 into user's variables
dflet 0:bbe98578d4c0 238 3. It is not recommended to delay the execution of the event callback handler
dflet 0:bbe98578d4c0 239
dflet 0:bbe98578d4c0 240 */
dflet 0:bbe98578d4c0 241
dflet 0:bbe98578d4c0 242 /*!
dflet 0:bbe98578d4c0 243
dflet 0:bbe98578d4c0 244 \addtogroup UserEvents
dflet 0:bbe98578d4c0 245 @{
dflet 0:bbe98578d4c0 246
dflet 0:bbe98578d4c0 247 */
dflet 0:bbe98578d4c0 248
dflet 0:bbe98578d4c0 249
dflet 0:bbe98578d4c0 250 /*****************************************************************************/
dflet 0:bbe98578d4c0 251 /* Macro declarations for Host Driver version */
dflet 0:bbe98578d4c0 252 /*****************************************************************************/
dflet 0:bbe98578d4c0 253 #define SL_DRIVER_VERSION "1.0.0.1"
dflet 0:bbe98578d4c0 254 #define SL_MAJOR_VERSION_NUM 1L
dflet 0:bbe98578d4c0 255 #define SL_MINOR_VERSION_NUM 0L
dflet 0:bbe98578d4c0 256 #define SL_VERSION_NUM 0L
dflet 0:bbe98578d4c0 257 #define SL_SUB_VERSION_NUM 1L
dflet 0:bbe98578d4c0 258
dflet 0:bbe98578d4c0 259
dflet 0:bbe98578d4c0 260 /*****************************************************************************/
dflet 0:bbe98578d4c0 261 /* Macro declarations for predefined configurations */
dflet 0:bbe98578d4c0 262 /*****************************************************************************/
dflet 0:bbe98578d4c0 263
dflet 0:bbe98578d4c0 264 #ifdef SL_TINY
dflet 0:bbe98578d4c0 265 #undef SL_INC_ARG_CHECK
dflet 0:bbe98578d4c0 266 #undef SL_INC_EXT_API
dflet 0:bbe98578d4c0 267 #undef SL_INC_SOCK_CLIENT_SIDE_API
dflet 0:bbe98578d4c0 268 #undef SL_INC_SOCK_SEND_API
dflet 0:bbe98578d4c0 269 #undef SL_INC_WLAN_PKG
dflet 0:bbe98578d4c0 270 #undef SL_INC_NET_APP_PKG
dflet 0:bbe98578d4c0 271 #undef SL_INC_NET_CFG_PKG
dflet 0:bbe98578d4c0 272 #undef SL_INC_FS_PKG
dflet 0:bbe98578d4c0 273 #define SL_INC_SOCK_SERVER_SIDE_API
dflet 0:bbe98578d4c0 274 #define SL_INC_SOCK_RECV_API
dflet 0:bbe98578d4c0 275 #define SL_INC_SOCKET_PKG
dflet 0:bbe98578d4c0 276 #endif
dflet 0:bbe98578d4c0 277
dflet 0:bbe98578d4c0 278 #ifdef SL_SMALL
dflet 0:bbe98578d4c0 279 #undef SL_INC_EXT_API
dflet 0:bbe98578d4c0 280 #undef SL_INC_NET_APP_PKG
dflet 0:bbe98578d4c0 281 #undef SL_INC_NET_CFG_PKG
dflet 0:bbe98578d4c0 282 #undef SL_INC_FS_PKG
dflet 0:bbe98578d4c0 283 #define SL_INC_ARG_CHECK
dflet 0:bbe98578d4c0 284 #define SL_INC_WLAN_PKG
dflet 0:bbe98578d4c0 285 #define SL_INC_SOCKET_PKG
dflet 0:bbe98578d4c0 286 #define SL_INC_SOCK_CLIENT_SIDE_API
dflet 0:bbe98578d4c0 287 #define SL_INC_SOCK_SERVER_SIDE_API
dflet 0:bbe98578d4c0 288 #define SL_INC_SOCK_RECV_API
dflet 0:bbe98578d4c0 289 #define SL_INC_SOCK_SEND_API
dflet 0:bbe98578d4c0 290 #endif
dflet 0:bbe98578d4c0 291
dflet 0:bbe98578d4c0 292 #ifdef SL_FULL
dflet 0:bbe98578d4c0 293 #define SL_INC_EXT_API
dflet 0:bbe98578d4c0 294 #define SL_INC_NET_APP_PKG
dflet 0:bbe98578d4c0 295 #define SL_INC_NET_CFG_PKG
dflet 0:bbe98578d4c0 296 #define SL_INC_FS_PKG
dflet 0:bbe98578d4c0 297 #define SL_INC_ARG_CHECK
dflet 0:bbe98578d4c0 298 #define SL_INC_WLAN_PKG
dflet 0:bbe98578d4c0 299 #define SL_INC_SOCKET_PKG
dflet 0:bbe98578d4c0 300 #define SL_INC_SOCK_CLIENT_SIDE_API
dflet 0:bbe98578d4c0 301 #define SL_INC_SOCK_SERVER_SIDE_API
dflet 0:bbe98578d4c0 302 #define SL_INC_SOCK_RECV_API
dflet 0:bbe98578d4c0 303 #define SL_INC_SOCK_SEND_API
dflet 0:bbe98578d4c0 304 #endif
dflet 0:bbe98578d4c0 305
dflet 0:bbe98578d4c0 306 #define SL_RET_CODE_OK (0)
dflet 0:bbe98578d4c0 307 #define SL_RET_CODE_INVALID_INPUT (-2)
dflet 0:bbe98578d4c0 308 #define SL_RET_CODE_SELF_ERROR (-3)
dflet 0:bbe98578d4c0 309 #define SL_RET_CODE_NWP_IF_ERROR (-4)
dflet 0:bbe98578d4c0 310 #define SL_RET_CODE_MALLOC_ERROR (-5)
dflet 0:bbe98578d4c0 311
dflet 0:bbe98578d4c0 312 #define sl_Memcpy memcpy
dflet 0:bbe98578d4c0 313 #define sl_Memset memset
dflet 0:bbe98578d4c0 314
dflet 0:bbe98578d4c0 315 #define sl_SyncObjClear(pObj) sl_SyncObjWait(pObj,SL_OS_NO_WAIT)
dflet 0:bbe98578d4c0 316
dflet 0:bbe98578d4c0 317 #define SL_MAX_SOCKETS (8)
dflet 0:bbe98578d4c0 318
dflet 0:bbe98578d4c0 319
dflet 0:bbe98578d4c0 320 /*****************************************************************************/
dflet 0:bbe98578d4c0 321 /* Types definitions */
dflet 0:bbe98578d4c0 322 /*****************************************************************************/
dflet 0:bbe98578d4c0 323 typedef void (*_SlSpawnEntryFunc_t)(void* pValue);
dflet 0:bbe98578d4c0 324
dflet 0:bbe98578d4c0 325 #ifndef NULL
dflet 0:bbe98578d4c0 326 #define NULL (0)
dflet 0:bbe98578d4c0 327 #endif
dflet 0:bbe98578d4c0 328
dflet 0:bbe98578d4c0 329 #ifndef FALSE
dflet 0:bbe98578d4c0 330 #define FALSE (0)
dflet 0:bbe98578d4c0 331 #endif
dflet 0:bbe98578d4c0 332
dflet 0:bbe98578d4c0 333 #ifndef TRUE
dflet 0:bbe98578d4c0 334 #define TRUE (!FALSE)
dflet 0:bbe98578d4c0 335 #endif
dflet 0:bbe98578d4c0 336
dflet 0:bbe98578d4c0 337 #ifndef OK
dflet 0:bbe98578d4c0 338 #define OK (0)
dflet 0:bbe98578d4c0 339 #endif
dflet 0:bbe98578d4c0 340
dflet 0:bbe98578d4c0 341 #ifndef _SL_USER_TYPES
dflet 0:bbe98578d4c0 342 #define _u8 unsigned char
dflet 0:bbe98578d4c0 343 #define _i8 signed char
dflet 0:bbe98578d4c0 344
dflet 0:bbe98578d4c0 345 #define _u16 unsigned short
dflet 0:bbe98578d4c0 346 #define _i16 signed short
dflet 0:bbe98578d4c0 347
dflet 0:bbe98578d4c0 348 #define _u32 unsigned long
dflet 0:bbe98578d4c0 349 #define _i32 signed long
dflet 0:bbe98578d4c0 350 #define _volatile volatile
dflet 0:bbe98578d4c0 351 #define _const const
dflet 0:bbe98578d4c0 352 #endif
dflet 0:bbe98578d4c0 353
dflet 0:bbe98578d4c0 354 typedef _u16 _SlOpcode_t;
dflet 0:bbe98578d4c0 355 typedef _u8 _SlArgSize_t;
dflet 0:bbe98578d4c0 356 typedef _i16 _SlDataSize_t;
dflet 0:bbe98578d4c0 357 typedef _i16 _SlReturnVal_t;
dflet 0:bbe98578d4c0 358
dflet 0:bbe98578d4c0 359 #ifdef __cplusplus
dflet 0:bbe98578d4c0 360 }
dflet 0:bbe98578d4c0 361 #endif /* __cplusplus */
dflet 0:bbe98578d4c0 362
dflet 0:bbe98578d4c0 363
dflet 0:bbe98578d4c0 364
dflet 0:bbe98578d4c0 365 /*****************************************************************************/
dflet 0:bbe98578d4c0 366 /* Include files */
dflet 0:bbe98578d4c0 367 /*****************************************************************************/
dflet 0:bbe98578d4c0 368
dflet 0:bbe98578d4c0 369 #ifdef SL_PLATFORM_MULTI_THREADED
dflet 0:bbe98578d4c0 370 #include "cc3100_spawn.h"
dflet 0:bbe98578d4c0 371 #else
dflet 0:bbe98578d4c0 372 #include "cc3100_nonos.h"
dflet 0:bbe98578d4c0 373 #endif
dflet 0:bbe98578d4c0 374
dflet 0:bbe98578d4c0 375
dflet 0:bbe98578d4c0 376 /*
dflet 0:bbe98578d4c0 377 objInclusion.h and user.h must be included before all api header files
dflet 0:bbe98578d4c0 378 objInclusion.h must be the last arrangement just before including the API header files
dflet 0:bbe98578d4c0 379 since it based on the other configurations to decide which object should be included
dflet 0:bbe98578d4c0 380 */
dflet 0:bbe98578d4c0 381 #include "cc3100_objInclusion.h"
dflet 0:bbe98578d4c0 382 #include "cc3100_trace.h"
dflet 0:bbe98578d4c0 383 #include "cc3100_fs.h"
dflet 0:bbe98578d4c0 384 #include "cc3100_socket.h"
dflet 0:bbe98578d4c0 385 #include "cc3100_netapp.h"
dflet 0:bbe98578d4c0 386 #include "cc3100_wlan.h"
dflet 0:bbe98578d4c0 387 #include "cc3100_device.h"
dflet 0:bbe98578d4c0 388 #include "cc3100_netcfg.h"
dflet 0:bbe98578d4c0 389 #include "cc3100_wlan_rx_filters.h"
dflet 0:bbe98578d4c0 390
dflet 0:bbe98578d4c0 391 #ifdef __cplusplus
dflet 0:bbe98578d4c0 392 extern "C" {
dflet 0:bbe98578d4c0 393 #endif
dflet 0:bbe98578d4c0 394
dflet 0:bbe98578d4c0 395
dflet 0:bbe98578d4c0 396
dflet 0:bbe98578d4c0 397 /* Async functions description*/
dflet 0:bbe98578d4c0 398
dflet 0:bbe98578d4c0 399 /*!
dflet 0:bbe98578d4c0 400 \brief General async event for inspecting general events
dflet 0:bbe98578d4c0 401
dflet 0:bbe98578d4c0 402 \param[out] pSlDeviceEvent pointer to SlDeviceEvent_t
dflet 0:bbe98578d4c0 403
dflet 0:bbe98578d4c0 404 \par
dflet 0:bbe98578d4c0 405 Parameters: \n
dflet 0:bbe98578d4c0 406 <b>pSlDeviceEvent->Event = SL_DEVICE_FATAL_ERROR_EVENT </b>
dflet 0:bbe98578d4c0 407 - pSlDeviceEvent->EventData.deviceEvent fields:
dflet 0:bbe98578d4c0 408 - status: An error code indication from the device
dflet 0:bbe98578d4c0 409 - sender: The sender originator which is based on SlErrorSender_e enum
dflet 0:bbe98578d4c0 410
dflet 0:bbe98578d4c0 411 \par Example:
dflet 0:bbe98578d4c0 412 \code
dflet 0:bbe98578d4c0 413 printf(General Event Handler - ID=%d Sender=%d\n\n",
dflet 0:bbe98578d4c0 414 pSlDeviceEvent->EventData.deviceEvent.status, // status of the general event
dflet 0:bbe98578d4c0 415 pSlDeviceEvent->EventData.deviceEvent.sender); // sender type
dflet 0:bbe98578d4c0 416 \endcode
dflet 0:bbe98578d4c0 417 */
dflet 0:bbe98578d4c0 418 #if (defined(sl_GeneralEvtHdlr))
dflet 0:bbe98578d4c0 419 extern void sl_GeneralEvtHdlr(SlDeviceEvent_t *pSlDeviceEvent);
dflet 0:bbe98578d4c0 420 #endif
dflet 0:bbe98578d4c0 421
dflet 0:bbe98578d4c0 422
dflet 0:bbe98578d4c0 423 /*!
dflet 0:bbe98578d4c0 424 \brief WLAN Async event handler
dflet 0:bbe98578d4c0 425
dflet 0:bbe98578d4c0 426 \param[out] pSlWlanEvent pointer to SlWlanEvent_t data
dflet 0:bbe98578d4c0 427
dflet 0:bbe98578d4c0 428 \par
dflet 0:bbe98578d4c0 429 Parameters:
dflet 0:bbe98578d4c0 430
dflet 0:bbe98578d4c0 431 - <b>pSlWlanEvent->Event = SL_WLAN_CONNECT_EVENT </b>, STA or P2P client connection indication event
dflet 0:bbe98578d4c0 432 - pSlWlanEvent->EventData.STAandP2PModeWlanConnected main fields:
dflet 0:bbe98578d4c0 433 - ssid_name
dflet 0:bbe98578d4c0 434 - ssid_len
dflet 0:bbe98578d4c0 435 - bssid
dflet 0:bbe98578d4c0 436 - go_peer_device_name
dflet 0:bbe98578d4c0 437 - go_peer_device_name_len
dflet 0:bbe98578d4c0 438
dflet 0:bbe98578d4c0 439 - <b>pSlWlanEvent->Event = SL_WLAN_DISCONNECT_EVENT </b>, STA or P2P client disconnection event
dflet 0:bbe98578d4c0 440 - pSlWlanEvent->EventData.STAandP2PModeDisconnected main fields:
dflet 0:bbe98578d4c0 441 - ssid_name
dflet 0:bbe98578d4c0 442 - ssid_len
dflet 0:bbe98578d4c0 443 - reason_code
dflet 0:bbe98578d4c0 444
dflet 0:bbe98578d4c0 445 - <b>pSlWlanEvent->Event = SL_WLAN_STA_CONNECTED_EVENT </b>, AP/P2P(Go) connected STA/P2P(Client)
dflet 0:bbe98578d4c0 446 - pSlWlanEvent->EventData.APModeStaConnected fields:
dflet 0:bbe98578d4c0 447 - go_peer_device_name
dflet 0:bbe98578d4c0 448 - mac
dflet 0:bbe98578d4c0 449 - go_peer_device_name_len
dflet 0:bbe98578d4c0 450 - wps_dev_password_id
dflet 0:bbe98578d4c0 451 - own_ssid: relevant for event sta-connected only
dflet 0:bbe98578d4c0 452 - own_ssid_len: relevant for event sta-connected only
dflet 0:bbe98578d4c0 453
dflet 0:bbe98578d4c0 454 - <b>pSlWlanEvent->Event = SL_WLAN_STA_DISCONNECTED_EVENT </b>, AP/P2P(Go) disconnected STA/P2P(Client)
dflet 0:bbe98578d4c0 455 - pSlWlanEvent->EventData.APModestaDisconnected fields:
dflet 0:bbe98578d4c0 456 - go_peer_device_name
dflet 0:bbe98578d4c0 457 - mac
dflet 0:bbe98578d4c0 458 - go_peer_device_name_len
dflet 0:bbe98578d4c0 459 - wps_dev_password_id
dflet 0:bbe98578d4c0 460 - own_ssid: relevant for event sta-connected only
dflet 0:bbe98578d4c0 461 - own_ssid_len: relevant for event sta-connected only
dflet 0:bbe98578d4c0 462
dflet 0:bbe98578d4c0 463 - <b>pSlWlanEvent->Event = SL_WLAN_SMART_CONFIG_COMPLETE_EVENT </b>
dflet 0:bbe98578d4c0 464 - pSlWlanEvent->EventData.smartConfigStartResponse fields:
dflet 0:bbe98578d4c0 465 - status
dflet 0:bbe98578d4c0 466 - ssid_len
dflet 0:bbe98578d4c0 467 - ssid
dflet 0:bbe98578d4c0 468 - private_token_len
dflet 0:bbe98578d4c0 469 - private_token
dflet 0:bbe98578d4c0 470
dflet 0:bbe98578d4c0 471 - <b>pSlWlanEvent->Event = SL_WLAN_SMART_CONFIG_STOP_EVENT </b>
dflet 0:bbe98578d4c0 472 - pSlWlanEvent->EventData.smartConfigStopResponse fields:
dflet 0:bbe98578d4c0 473 - status
dflet 0:bbe98578d4c0 474
dflet 0:bbe98578d4c0 475 - <b>pSlWlanEvent->Event = SL_WLAN_P2P_DEV_FOUND_EVENT </b>
dflet 0:bbe98578d4c0 476 - pSlWlanEvent->EventData.P2PModeDevFound fields:
dflet 0:bbe98578d4c0 477 - go_peer_device_name
dflet 0:bbe98578d4c0 478 - mac
dflet 0:bbe98578d4c0 479 - go_peer_device_name_len
dflet 0:bbe98578d4c0 480 - wps_dev_password_id
dflet 0:bbe98578d4c0 481 - own_ssid: relevant for event sta-connected only
dflet 0:bbe98578d4c0 482 - own_ssid_len: relevant for event sta-connected only
dflet 0:bbe98578d4c0 483
dflet 0:bbe98578d4c0 484 - <b>pSlWlanEvent->Event = SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT </b>
dflet 0:bbe98578d4c0 485 - pSlWlanEvent->EventData.P2PModeNegReqReceived fields
dflet 0:bbe98578d4c0 486 - go_peer_device_name
dflet 0:bbe98578d4c0 487 - mac
dflet 0:bbe98578d4c0 488 - go_peer_device_name_len
dflet 0:bbe98578d4c0 489 - wps_dev_password_id
dflet 0:bbe98578d4c0 490 - own_ssid: relevant for event sta-connected only
dflet 0:bbe98578d4c0 491
dflet 0:bbe98578d4c0 492 - <b>pSlWlanEvent->Event = SL_WLAN_CONNECTION_FAILED_EVENT </b>, P2P only
dflet 0:bbe98578d4c0 493 - pSlWlanEvent->EventData.P2PModewlanConnectionFailure fields:
dflet 0:bbe98578d4c0 494 - status
dflet 0:bbe98578d4c0 495 */
dflet 0:bbe98578d4c0 496 #if (defined(sl_WlanEvtHdlr))
dflet 0:bbe98578d4c0 497 extern void sl_WlanEvtHdlr(SlWlanEvent_t *pSlWlanEvent);
dflet 0:bbe98578d4c0 498 #endif
dflet 0:bbe98578d4c0 499
dflet 0:bbe98578d4c0 500
dflet 0:bbe98578d4c0 501 /*!
dflet 0:bbe98578d4c0 502 \brief NETAPP Async event handler
dflet 0:bbe98578d4c0 503
dflet 0:bbe98578d4c0 504 \param[out] pSlNetApp pointer to SlNetAppEvent_t data
dflet 0:bbe98578d4c0 505
dflet 0:bbe98578d4c0 506 \par
dflet 0:bbe98578d4c0 507 Parameters:
dflet 0:bbe98578d4c0 508 - <b>pSlWlanEvent->Event = SL_NETAPP_IPV4_IPACQUIRED_EVENT</b>, IPV4 acquired event
dflet 0:bbe98578d4c0 509 - pSlWlanEvent->EventData.ipAcquiredV4 fields:
dflet 0:bbe98578d4c0 510 - ip
dflet 0:bbe98578d4c0 511 - gateway
dflet 0:bbe98578d4c0 512 - dns
dflet 0:bbe98578d4c0 513
dflet 0:bbe98578d4c0 514 - <b>pSlWlanEvent->Event = SL_NETAPP_IP_LEASED_EVENT</b>, AP or P2P go dhcp lease event
dflet 0:bbe98578d4c0 515 - pSlWlanEvent->EventData.ipLeased fields:
dflet 0:bbe98578d4c0 516 - ip_address
dflet 0:bbe98578d4c0 517 - lease_time
dflet 0:bbe98578d4c0 518 - mac
dflet 0:bbe98578d4c0 519
dflet 0:bbe98578d4c0 520 - <b>pSlWlanEvent->Event = SL_NETAPP_IP_RELEASED_EVENT</b>, AP or P2P go dhcp ip release event
dflet 0:bbe98578d4c0 521 - pSlWlanEvent->EventData.ipReleased fields
dflet 0:bbe98578d4c0 522 - ip_address
dflet 0:bbe98578d4c0 523 - mac
dflet 0:bbe98578d4c0 524 - reason
dflet 0:bbe98578d4c0 525
dflet 0:bbe98578d4c0 526 */
dflet 0:bbe98578d4c0 527 #if (defined(sl_NetAppEvtHdlr))
dflet 0:bbe98578d4c0 528 extern void sl_NetAppEvtHdlr(SlNetAppEvent_t *pSlNetApp);
dflet 0:bbe98578d4c0 529 #endif
dflet 0:bbe98578d4c0 530
dflet 0:bbe98578d4c0 531 /*!
dflet 0:bbe98578d4c0 532 \brief Socket Async event handler
dflet 0:bbe98578d4c0 533
dflet 0:bbe98578d4c0 534 \param[out] pSlSockEvent pointer to SlSockEvent_t data
dflet 0:bbe98578d4c0 535
dflet 0:bbe98578d4c0 536 \par
dflet 0:bbe98578d4c0 537 Parameters:\n
dflet 0:bbe98578d4c0 538 - <b>pSlSockEvent->Event = SL_SOCKET_TX_FAILED_EVENT</b>
dflet 0:bbe98578d4c0 539 - pSlSockEvent->EventData fields:
dflet 0:bbe98578d4c0 540 - sd
dflet 0:bbe98578d4c0 541 - status
dflet 0:bbe98578d4c0 542 - <b>pSlSockEvent->Event = SL_SOCKET_ASYNC_EVENT</b>
dflet 0:bbe98578d4c0 543 - pSlSockEvent->EventData fields:
dflet 0:bbe98578d4c0 544 - sd
dflet 0:bbe98578d4c0 545 - type: SSL_ACCEPT or RX_FRAGMENTATION_TOO_BIG or OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED
dflet 0:bbe98578d4c0 546 - val
dflet 0:bbe98578d4c0 547
dflet 0:bbe98578d4c0 548 */
dflet 0:bbe98578d4c0 549 #if (defined(sl_SockEvtHdlr))
dflet 0:bbe98578d4c0 550 extern void sl_SockEvtHdlr(SlSockEvent_t *pSlSockEvent);
dflet 0:bbe98578d4c0 551 #endif
dflet 0:bbe98578d4c0 552
dflet 0:bbe98578d4c0 553 /*!
dflet 0:bbe98578d4c0 554 \brief HTTP server async event
dflet 0:bbe98578d4c0 555
dflet 0:bbe98578d4c0 556 \param[out] pSlHttpServerEvent pointer to SlHttpServerEvent_t
dflet 0:bbe98578d4c0 557 \param[in] pSlHttpServerResponse pointer to SlHttpServerResponse_t
dflet 0:bbe98578d4c0 558
dflet 0:bbe98578d4c0 559 \par
dflet 0:bbe98578d4c0 560 Parameters: \n
dflet 0:bbe98578d4c0 561
dflet 0:bbe98578d4c0 562 - <b>pSlHttpServerEvent->Event = SL_NETAPP_HTTPGETTOKENVALUE_EVENT</b>
dflet 0:bbe98578d4c0 563 - pSlHttpServerEvent->EventData fields:
dflet 0:bbe98578d4c0 564 - httpTokenName
dflet 0:bbe98578d4c0 565 - data
dflet 0:bbe98578d4c0 566 - len
dflet 0:bbe98578d4c0 567 - pSlHttpServerResponse->ResponseData fields:
dflet 0:bbe98578d4c0 568 - data
dflet 0:bbe98578d4c0 569 - len
dflet 0:bbe98578d4c0 570
dflet 0:bbe98578d4c0 571 - <b>pSlHttpServerEvent->Event = SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT</b>
dflet 0:bbe98578d4c0 572 - pSlHttpServerEvent->EventData.httpPostData fields:
dflet 0:bbe98578d4c0 573 - action
dflet 0:bbe98578d4c0 574 - token_name
dflet 0:bbe98578d4c0 575 - token_value
dflet 0:bbe98578d4c0 576 - pSlHttpServerResponse->ResponseData fields:
dflet 0:bbe98578d4c0 577 - data
dflet 0:bbe98578d4c0 578 - len
dflet 0:bbe98578d4c0 579
dflet 0:bbe98578d4c0 580 */
dflet 0:bbe98578d4c0 581 #if (defined(sl_HttpServerCallback))
dflet 0:bbe98578d4c0 582 extern void sl_HttpServerCallback(SlHttpServerEvent_t *pSlHttpServerEvent, SlHttpServerResponse_t *pSlHttpServerResponse);
dflet 0:bbe98578d4c0 583 #endif
dflet 0:bbe98578d4c0 584 /*!
dflet 0:bbe98578d4c0 585
dflet 0:bbe98578d4c0 586 Close the Doxygen group.
dflet 0:bbe98578d4c0 587 @}
dflet 0:bbe98578d4c0 588
dflet 0:bbe98578d4c0 589 */
dflet 0:bbe98578d4c0 590
dflet 0:bbe98578d4c0 591 #ifdef __cplusplus
dflet 0:bbe98578d4c0 592 }
dflet 0:bbe98578d4c0 593 #endif /* __cplusplus */
dflet 0:bbe98578d4c0 594
dflet 0:bbe98578d4c0 595 #endif /* __SIMPLELINK_H__ */
dflet 0:bbe98578d4c0 596
dflet 0:bbe98578d4c0 597