SimpleLink CC3100/CC3200 Host Driver  Version 1.0.1.6
Simplifies the implementation of Internet connectivity
device.h
1 /*
2  * device.h - CC31xx/CC32xx Host Driver Implementation
3  *
4  * Copyright (C) 2015 Texas Instruments Incorporated - https://www.ti.com/
5  *
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  *
14  * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in the
16  * documentation and/or other materials provided with the
17  * distribution.
18  *
19  * Neither the name of Texas Instruments Incorporated nor the names of
20  * its contributors may be used to endorse or promote products derived
21  * from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  *
35 */
36 
37 /*****************************************************************************/
38 /* Include files */
39 /*****************************************************************************/
40 #include "simplelink.h"
41 
42 #ifndef __DEVICE_H__
43 #define __DEVICE_H__
44 
45 
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
51 
52 
60 /*****************************************************************************/
61 /* Macro declarations */
62 /*****************************************************************************/
63 
64 
65 /* SL internal Error codes */
66 
67 /* Receive this error in case there are no resources to issue the command
68  If possible, increase the number of MAX_CUNCURENT_ACTIONS (result in memory increase)
69  If not, try again later */
70 #define SL_POOL_IS_EMPTY (-2000)
71 
72 /* Receive this error in case a given length for RX buffer was too small.
73  Receive payload was bigger than the given buffer size. Therefore, payload is cut according to receive size
74  Recommend to increase buffer size */
75 #define SL_ESMALLBUF (-2001)
76 
77 /* Receive this error in case zero length is supplied to a "get" API
78  Recommend to supply length according to requested information (view options defines for help) */
79 #define SL_EZEROLEN (-2002)
80 
81 /* User supplied invalid parameter */
82 #define SL_INVALPARAM (-2003)
83 
84 
85 /* Failed to open interface */
86 #define SL_BAD_INTERFACE (-2004)
87 
88 /* API has been aborted due to an error detected by host driver */
89 #define SL_API_ABORTED (-100)
90 
91 /* End of SL internal Error codes */
92 
93 
94 
95 /*****************************************************************************/
96 /* Errors returned from the general error async event */
97 /*****************************************************************************/
98 
99 /* Send types */
100 typedef enum
101 {
102  SL_ERR_SENDER_HEALTH_MON,
103  SL_ERR_SENDER_CLI_UART,
104  SL_ERR_SENDER_SUPPLICANT,
105  SL_ERR_SENDER_NETWORK_STACK,
106  SL_ERR_SENDER_WLAN_DRV_IF,
107  SL_ERR_SENDER_WILINK,
108  SL_ERR_SENDER_INIT_APP,
109  SL_ERR_SENDER_NETX,
110  SL_ERR_SENDER_HOST_APD,
111  SL_ERR_SENDER_MDNS,
112  SL_ERR_SENDER_HTTP_SERVER,
113  SL_ERR_SENDER_DHCP_SERVER,
114  SL_ERR_SENDER_DHCP_CLIENT,
115  SL_ERR_DISPATCHER,
116  SL_ERR_NUM_SENDER_LAST=0xFF
117 }SlErrorSender_e;
118 
119 
120 typedef enum
121 {
122  SL_DRIVER_API_DEVICE_SL_START = 0,
123  SL_DRIVER_API_DEVICE_SL_STOP,
124  SL_DRIVER_API_NETAPP_PING_START,
125  SL_DRIVER_API_SOCKET_CONNECT,
126  SL_DRIVER_API_SOCKET_ACCEPT,
127  SL_DRIVER_API_SOCKET_SELECT,
128  SL_DRIVER_API_SOCKET_RECV,
129  SL_DRIVER_API_SOCKET_RECVFROM
130 
131 } SlDriverAPIWithTimeout_e;
132 
133 
134 /* Error codes */
135 #define SL_ERROR_STATIC_ADDR_SUBNET_ERROR (-60) /* network stack error*/
136 #define SL_ERROR_ILLEGAL_CHANNEL (-61) /* supplicant error */
137 #define SL_ERROR_SUPPLICANT_ERROR (-72) /* init error code */
138 #define SL_ERROR_HOSTAPD_INIT_FAIL (-73) /* init error code */
139 #define SL_ERROR_HOSTAPD_INIT_IF_FAIL (-74) /* init error code */
140 #define SL_ERROR_WLAN_DRV_INIT_FAIL (-75) /* init error code */
141 #define SL_ERROR_WLAN_DRV_START_FAIL (-76) /* wlan start error */
142 #define SL_ERROR_FS_FILE_TABLE_LOAD_FAILED (-77) /* init file system failed */
143 #define SL_ERROR_PREFERRED_NETWORKS_FILE_LOAD_FAILED (-78) /* init file system failed */
144 #define SL_ERROR_HOSTAPD_BSSID_VALIDATION_ERROR (-79) /* Ap configurations BSSID error */
145 #define SL_ERROR_HOSTAPD_FAILED_TO_SETUP_INTERFACE (-80) /* Ap configurations interface error */
146 #define SL_ERROR_MDNS_ENABLE_FAIL (-81) /* mDNS enable failed */
147 #define SL_ERROR_HTTP_SERVER_ENABLE_FAILED (-82) /* HTTP server enable failed */
148 #define SL_ERROR_DHCP_SERVER_ENABLE_FAILED (-83) /* DHCP server enable failed */
149 #define SL_ERROR_PREFERRED_NETWORK_LIST_FULL (-93) /* supplicant error */
150 #define SL_ERROR_PREFERRED_NETWORKS_FILE_WRITE_FAILED (-94) /* supplicant error */
151 #define SL_ERROR_DHCP_CLIENT_RENEW_FAILED (-100) /* DHCP client error */
152 /* WLAN Connection management status */
153 #define SL_GENERAL_ERROR_CON_MGMT_STATUS_UNSPECIFIED (-102)
154 #define SL_GENERAL_ERROR_CON_MGMT_STATUS_AUTH_REJECT (-103)
155 #define SL_GENERAL_ERROR_CON_MGMT_STATUS_ASSOC_REJECT (-104)
156 #define SL_GENERAL_ERROR_CON_MGMT_STATUS_SECURITY_FAILURE (-105)
157 #define SL_GENERAL_ERROR_CON_MGMT_STATUS_AP_DEAUTHENTICATE (-106)
158 #define SL_GENERAL_ERROR_CON_MGMT_STATUS_AP_DISASSOCIATE (-107)
159 #define SL_GENERAL_ERROR_CON_MGMT_STATUS_ROAMING_TRIGGER (-108)
160 #define SL_GENERAL_ERROR_CON_MGMT_STATUS_DISCONNECT_DURING_CONNECT (-109)
161 #define SL_GENERAL_ERROR_CON_MGMT_STATUS_SG_RESELECT (-110)
162 #define SL_GENERAL_ERROR_CON_MGMT_STATUS_ROC_FAILURE (-111)
163 #define SL_GENERAL_ERROR_CON_MGMT_STATUS_MIC_FAILURE (-112)
164 /* end of WLAN connection management error statuses */
165 #define SL_ERROR_WAKELOCK_ERROR_PREFIX (-115) /* Wake lock expired */
166 #define SL_ERROR_LENGTH_ERROR_PREFIX (-116) /* Uart header length error */
167 #define SL_ERROR_MDNS_CREATE_FAIL (-121) /* mDNS create failed */
168 #define SL_ERROR_GENERAL_ERROR (-127)
169 
170 
171 
172 #define SL_DEVICE_GENERAL_CONFIGURATION (1)
173 #define SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME (11)
174 #define SL_DEVICE_GENERAL_VERSION (12)
175 #define SL_DEVICE_STATUS (2)
176 
177 /*
178  Declare the different event group classifications
179  The SimpleLink device send asynchronous events. Each event has a group
180  classification according to its nature.
181 */
182 
183 /* SL_EVENT_CLASS_WLAN connection user events */
184 #define SL_WLAN_CONNECT_EVENT (1)
185 #define SL_WLAN_DISCONNECT_EVENT (2)
186 /* WLAN Smart Config user events */
187 #define SL_WLAN_SMART_CONFIG_COMPLETE_EVENT (3)
188 #define SL_WLAN_SMART_CONFIG_STOP_EVENT (4)
189 /* WLAN AP user events */
190 #define SL_WLAN_STA_CONNECTED_EVENT (5)
191 #define SL_WLAN_STA_DISCONNECTED_EVENT (6)
192 /* WLAN P2P user events */
193 #define SL_WLAN_P2P_DEV_FOUND_EVENT (7)
194 #define SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT (8)
195 #define SL_WLAN_CONNECTION_FAILED_EVENT (9)
196 
197 typedef enum
198 {
199  SL_DEVICE_GENERAL_ERROR_EVENT = 1,
200  SL_DEVICE_ABORT_ERROR_EVENT,
201  SL_DEVICE_DRIVER_ASSERT_ERROR_EVENT,
202  SL_DEVICE_DRIVER_TIMEOUT_CMD_COMPLETE,
203  SL_DEVICE_DRIVER_TIMEOUT_SYNC_PATTERN,
204  SL_DEVICE_DRIVER_TIMEOUT_ASYNC_EVENT,
205  SL_DEVICE_ERROR_MAX
206 }
207 SlDeviceDriverError_e;
208 
209 /* SL_EVENT_CLASS_BSD user events */
210 #define SL_SOCKET_TX_FAILED_EVENT (1)
211 #define SL_SOCKET_ASYNC_EVENT (2)
212 /* SL_EVENT_CLASS_NETAPP user events */
213 #define SL_NETAPP_IPV4_IPACQUIRED_EVENT (1)
214 #define SL_NETAPP_IPV6_IPACQUIRED_EVENT (2)
215 #define SL_NETAPP_IP_LEASED_EVENT (3)
216 #define SL_NETAPP_IP_RELEASED_EVENT (4)
217 
218 /* Server Events */
219 #define SL_NETAPP_HTTPGETTOKENVALUE_EVENT (1)
220 #define SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT (2)
221 
222 
223 /*
224  Declare the different event group classifications for sl_DevGet
225  for getting status indications
226  */
227 
228 /* Events list to mask/unmask*/
229 #define SL_EVENT_CLASS_GLOBAL (0)
230 #define SL_EVENT_CLASS_DEVICE (1)
231 #define SL_EVENT_CLASS_WLAN (2)
232 #define SL_EVENT_CLASS_BSD (3)
233 #define SL_EVENT_CLASS_NETAPP (4)
234 #define SL_EVENT_CLASS_NETCFG (5)
235 #define SL_EVENT_CLASS_FS (6)
236 
237 
238 /****************** DEVICE CLASS status ****************/
239 #define EVENT_DROPPED_DEVICE_ASYNC_GENERAL_ERROR (0x00000001L)
240 #define STATUS_DEVICE_SMART_CONFIG_ACTIVE (0x80000000L)
241 
242 /****************** WLAN CLASS status ****************/
243 #define EVENT_DROPPED_WLAN_WLANASYNCONNECTEDRESPONSE (0x00000001L)
244 #define EVENT_DROPPED_WLAN_WLANASYNCDISCONNECTEDRESPONSE (0x00000002L)
245 #define EVENT_DROPPED_WLAN_STA_CONNECTED (0x00000004L)
246 #define EVENT_DROPPED_WLAN_STA_DISCONNECTED (0x00000008L)
247 #define STATUS_WLAN_STA_CONNECTED (0x80000000L)
248 
249 /****************** NETAPP CLASS status ****************/
250 #define EVENT_DROPPED_NETAPP_IPACQUIRED (0x00000001L)
251 #define EVENT_DROPPED_NETAPP_IPACQUIRED_V6 (0x00000002L)
252 #define EVENT_DROPPED_NETAPP_IP_LEASED (0x00000004L)
253 #define EVENT_DROPPED_NETAPP_IP_RELEASED (0x00000008L)
254 
255 /****************** BSD CLASS status ****************/
256 #define EVENT_DROPPED_SOCKET_TXFAILEDASYNCRESPONSE (0x00000001L)
257 
258 /****************** FS CLASS ****************/
259 
260 
261 
262 
263 /********************************************
264 For backward compatability (version 1.0.0.10)
265 *********************************************/
266 #define SL_ERROR_CON_MGMT_STATUS_UNSPECIFIED SL_GENERAL_ERROR_CON_MGMT_STATUS_UNSPECIFIED
267 #define SL_ERROR_CON_MGMT_STATUS_AUTH_REJECT SL_GENERAL_ERROR_CON_MGMT_STATUS_AUTH_REJECT
268 #define SL_ERROR_CON_MGMT_STATUS_ASSOC_REJECT SL_GENERAL_ERROR_CON_MGMT_STATUS_ASSOC_REJECT
269 #define SL_ERROR_CON_MGMT_STATUS_SECURITY_FAILURE SL_GENERAL_ERROR_CON_MGMT_STATUS_SECURITY_FAILURE
270 #define SL_ERROR_CON_MGMT_STATUS_AP_DEAUTHENTICATE SL_GENERAL_ERROR_CON_MGMT_STATUS_AP_DEAUTHENTICATE
271 #define SL_ERROR_CON_MGMT_STATUS_AP_DISASSOCIATE SL_GENERAL_ERROR_CON_MGMT_STATUS_AP_DISASSOCIATE
272 #define SL_ERROR_CON_MGMT_STATUS_ROAMING_TRIGGER SL_GENERAL_ERROR_CON_MGMT_STATUS_ROAMING_TRIGGER
273 #define SL_ERROR_CON_MGMT_STATUS_DISCONNECT_DURING_CONNECT SL_GENERAL_ERROR_CON_MGMT_STATUS_DISCONNECT_DURING_CONNECT
274 #define SL_ERROR_CON_MGMT_STATUS_SG_RESELECT SL_GENERAL_ERROR_CON_MGMT_STATUS_SG_RESELECT
275 #define SL_ERROR_CON_MGMT_STATUS_ROC_FAILURE SL_GENERAL_ERROR_CON_MGMT_STATUS_ROC_FAILURE
276 #define SL_ERROR_CON_MGMT_STATUS_MIC_FAILURE SL_GENERAL_ERROR_CON_MGMT_STATUS_MIC_FAILURE
277 #define SL_DEVICE_FATAL_ERROR_EVENT SL_DEVICE_GENERAL_ERROR_EVENT
278 
279 
280 /*****************************************************************************/
281 /* Structure/Enum declarations */
282 /*****************************************************************************/
283 
284 
285 #ifdef SL_IF_TYPE_UART
286 typedef struct
287 {
288  _u32 BaudRate;
289  _u8 FlowControlEnable;
290  _u8 CommPort;
292 #endif
293 
294 typedef struct
295 {
296  _u32 ChipId;
297  _u32 FwVersion[4];
298  _u8 PhyVersion[4];
300 
301 typedef struct
302 {
303  _SlPartialVersion ChipFwAndPhyVersion;
304  _u32 NwpVersion[4];
305  _u16 RomVersion;
306  _u16 Padding;
308 
309 typedef struct
310 {
311  _u32 AbortType;
312  _u32 AbortData;
314 
315 
316 typedef struct
317 {
318  _i8 status;
319  SlErrorSender_e sender;
321 
322 typedef struct
323 {
324  _u32 info;
326 typedef union
327 {
328  sl_DeviceReport deviceEvent;
329  sl_DeviceReportAbort deviceReport;
330  sl_DeviceDriverErrorReport deviceDriverReport;
332 
333 typedef struct
334 {
335  SlDeviceDriverError_e Event;
336  SlDeviceEventData_u EventData;
338 
339 typedef struct
340 {
341  /* time */
342  _u32 sl_tm_sec;
343  _u32 sl_tm_min;
344  _u32 sl_tm_hour;
345  /* date */
346  _u32 sl_tm_day; /* 1-31 */
347  _u32 sl_tm_mon; /* 1-12 */
348  _u32 sl_tm_year; /* YYYY 4 digits */
349  _u32 sl_tm_week_day; /* not required */
350  _u32 sl_tm_year_day; /* not required */
351  _u32 reserved[3];
352 }SlDateTime_t;
353 
354 /******************************************************************************/
355 /* Type declarations */
356 /******************************************************************************/
357 typedef void (*P_INIT_CALLBACK)(_u32 Status);
358 
359 /*****************************************************************************/
360 /* Function prototypes */
361 /*****************************************************************************/
362 
412 #if _SL_INCLUDE_FUNC(sl_Start)
413 _i16 sl_Start(const void* pIfHdl, _i8* pDevName, const P_INIT_CALLBACK pInitCallBack);
414 #endif
415 
444 #if _SL_INCLUDE_FUNC(sl_Stop)
445 _i16 sl_Stop(const _u16 timeout);
446 #endif
447 
448 
481 #if _SL_INCLUDE_FUNC(sl_DevSet)
482 _i32 sl_DevSet(const _u8 DeviceSetId ,const _u8 Option,const _u8 ConfigLen,const _u8 *pValues);
483 #endif
484 
545 #if _SL_INCLUDE_FUNC(sl_DevGet)
546 _i32 sl_DevGet(const _u8 DeviceGetId,_u8 *pOption,_u8 *pConfigLen, _u8 *pValues);
547 #endif
548 
549 
597 #if _SL_INCLUDE_FUNC(sl_EventMaskSet)
598 _i16 sl_EventMaskSet(const _u8 EventClass ,const _u32 Mask);
599 #endif
600 
637 #if _SL_INCLUDE_FUNC(sl_EventMaskGet)
638 _i16 sl_EventMaskGet(const _u8 EventClass,_u32 *pMask);
639 #endif
640 
641 
662 #if _SL_INCLUDE_FUNC(sl_Task)
663 void sl_Task(void);
664 #endif
665 
666 
683 #ifdef SL_IF_TYPE_UART
684 #if _SL_INCLUDE_FUNC(sl_UartSetMode)
685 _i16 sl_UartSetMode(const SlUartIfParams_t* pUartParams);
686 #endif
687 #endif
688 
697 #ifdef __cplusplus
698 }
699 #endif /* __cplusplus */
700 
701 #endif /* __DEVICE_H__ */
702 
703 
_i16 sl_EventMaskGet(const _u8 EventClass, _u32 *pMask)
Get current event mask of the device.
_i16 sl_Start(const void *pIfHdl, _i8 *pDevName, const P_INIT_CALLBACK pInitCallBack)
Start the SimpleLink device.
_i16 sl_EventMaskSet(const _u8 EventClass, const _u32 Mask)
Set asynchronous event mask.
_i16 sl_UartSetMode(const SlUartIfParams_t *pUartParams)
Setting the internal uart mode.
void sl_Task(void)
the simple link task entry
_i16 sl_Stop(const _u16 timeout)
Stop the SimpleLink device.
_i32 sl_DevGet(const _u8 DeviceGetId, _u8 *pOption, _u8 *pConfigLen, _u8 *pValues)
Internal function for getting device configurations.
_i32 sl_DevSet(const _u8 DeviceSetId, const _u8 Option, const _u8 ConfigLen, const _u8 *pValues)
Internal function for setting device configurations.