Simple LED control project using CC3100 as Access Point and socket

Dependencies:   mbed

Fork of cc3100_Test_Demo by David Fletcher

Committer:
dflet
Date:
Tue Feb 10 12:09:29 2015 +0000
Revision:
0:e89ba455dbcf
For test only! Not much has been tested, but the 2 demo apps run ok. Alot more work needs to be done!

Who changed what in which revision?

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