SimpleLink Host Driver  1.0.0.1
 All Data Structures Functions Variables Groups Pages
device.h
1 /*
2  * device.h - CC31xx/CC32xx Host Driver Implementation
3  *
4  * Copyright (C) 2014 Texas Instruments Incorporated - http://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 #ifndef __DEVICE_H__
38 #define __DEVICE_H__
39 
40 /*****************************************************************************/
41 /* Include files */
42 /*****************************************************************************/
43 #include "simplelink.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 
50 
58 /*****************************************************************************/
59 /* Macro declarations */
60 /*****************************************************************************/
61 
62 
63 /* SL internal Error codes */
64 
65 /* Receive this error in case there are no resources to issue the command
66  If possible, increase the number of MAX_CUNCURENT_ACTIONS (result in memory increase)
67  If not, try again later */
68 #define SL_POOL_IS_EMPTY (-2000)
69 
70 /* Receive this error in case a given length for RX buffer was too small.
71  Receive payload was bigger than the given buffer size. Therefore, payload is cut according to receive size
72  Recommend to increase buffer size */
73 #define SL_ESMALLBUF (-2001)
74 
75 /* Receive this error in case zero length is supplied to a "get" API
76  Recommend to supply length according to requested information (view options defines for help) */
77 #define SL_EZEROLEN (-2002)
78 
79 /* User supplied invalid parameter */
80 #define SL_INVALPARAM (-2003)
81 
82 /* End of SL internal Error codes */
83 
84 
85 
86 /*****************************************************************************/
87 /* Errors returned from the general error async event */
88 /*****************************************************************************/
89 
90 /* Send types */
91 typedef enum
92 {
93  SL_ERR_SENDER_HEALTH_MON,
94  SL_ERR_SENDER_CLI_UART,
95  SL_ERR_SENDER_SUPPLICANT,
96  SL_ERR_SENDER_NETWORK_STACK,
97  SL_ERR_SENDER_WLAN_DRV_IF,
98  SL_ERR_SENDER_WILINK,
99  SL_ERR_SENDER_INIT_APP,
100  SL_ERR_SENDER_NETX,
101  SL_ERR_SENDER_HOST_APD,
102  SL_ERR_SENDER_MDNS,
103  SL_ERR_SENDER_HTTP_SERVER,
104  SL_ERR_SENDER_DHCP_SERVER,
105  SL_ERR_SENDER_DHCP_CLIENT,
106  SL_ERR_DISPATCHER,
107  SL_ERR_NUM_SENDER_LAST=0xFF
108 }SlErrorSender_e;
109 
110 
111 /* Error codes */
112 #define SL_ERROR_STATIC_ADDR_SUBNET_ERROR (-60) /* network stack error*/
113 #define SL_ERROR_ILLEGAL_CHANNEL (-61) /* supplicant error */
114 #define SL_ERROR_SUPPLICANT_ERROR (-72) /* init error code */
115 #define SL_ERROR_HOSTAPD_INIT_FAIL (-73) /* init error code */
116 #define SL_ERROR_HOSTAPD_INIT_IF_FAIL (-74) /* init error code */
117 #define SL_ERROR_WLAN_DRV_INIT_FAIL (-75) /* init error code */
118 #define SL_ERROR_WLAN_DRV_START_FAIL (-76) /* wlan start error */
119 #define SL_ERROR_FS_FILE_TABLE_LOAD_FAILED (-77) /* init file system failed */
120 #define SL_ERROR_PREFERRED_NETWORKS_FILE_LOAD_FAILED (-78) /* init file system failed */
121 #define SL_ERROR_HOSTAPD_BSSID_VALIDATION_ERROR (-79) /* Ap configurations BSSID error */
122 #define SL_ERROR_HOSTAPD_FAILED_TO_SETUP_INTERFACE (-80) /* Ap configurations interface error */
123 #define SL_ERROR_MDNS_ENABLE_FAIL (-81) /* mDNS enable failed */
124 #define SL_ERROR_HTTP_SERVER_ENABLE_FAILED (-82) /* HTTP server enable failed */
125 #define SL_ERROR_DHCP_SERVER_ENABLE_FAILED (-83) /* DHCP server enable failed */
126 #define SL_ERROR_PREFERRED_NETWORK_LIST_FULL (-93) /* supplicant error */
127 #define SL_ERROR_PREFERRED_NETWORKS_FILE_WRITE_FAILED (-94) /* supplicant error */
128 #define SL_ERROR_DHCP_CLIENT_RENEW_FAILED (-100) /* DHCP client error */
129 /* WLAN Connection management status */
130 #define SL_ERROR_CON_MGMT_STATUS_UNSPECIFIED (-102)
131 #define SL_ERROR_CON_MGMT_STATUS_AUTH_REJECT (-103)
132 #define SL_ERROR_CON_MGMT_STATUS_ASSOC_REJECT (-104)
133 #define SL_ERROR_CON_MGMT_STATUS_SECURITY_FAILURE (-105)
134 #define SL_ERROR_CON_MGMT_STATUS_AP_DEAUTHENTICATE (-106)
135 #define SL_ERROR_CON_MGMT_STATUS_AP_DISASSOCIATE (-107)
136 #define SL_ERROR_CON_MGMT_STATUS_ROAMING_TRIGGER (-108)
137 #define SL_ERROR_CON_MGMT_STATUS_DISCONNECT_DURING_CONNECT (-109)
138 #define SL_ERROR_CON_MGMT_STATUS_SG_RESELECT (-110)
139 #define SL_ERROR_CON_MGMT_STATUS_ROC_FAILURE (-111)
140 #define SL_ERROR_CON_MGMT_STATUS_MIC_FAILURE (-112)
141 /* end of WLAN connection management error statuses */
142 #define SL_ERROR_WAKELOCK_ERROR_PREFIX (-115) /* Wake lock expired */
143 #define SL_ERROR_LENGTH_ERROR_PREFIX (-116) /* Uart header length error */
144 #define SL_ERROR_MDNS_CREATE_FAIL (-121) /* mDNS create failed */
145 #define SL_ERROR_GENERAL_ERROR (-127)
146 
147 
148 
149 #define SL_DEVICE_GENERAL_CONFIGURATION (1)
150 #define SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME (11)
151 #define SL_DEVICE_GENERAL_VERSION (12)
152 #define SL_DEVICE_STATUS (2)
153 
154 /*
155  Declare the different event group classifications
156  The SimpleLink device send asynchronous events. Each event has a group
157  classification according to its nature.
158 */
159 /* SL_EVENT_CLASS_WLAN connection user events */
160 #define SL_WLAN_CONNECT_EVENT (1)
161 #define SL_WLAN_DISCONNECT_EVENT (2)
162 /* WLAN Smart Config user events */
163 #define SL_WLAN_SMART_CONFIG_COMPLETE_EVENT (3)
164 #define SL_WLAN_SMART_CONFIG_STOP_EVENT (4)
165 /* WLAN AP user events */
166 #define SL_WLAN_STA_CONNECTED_EVENT (5)
167 #define SL_WLAN_STA_DISCONNECTED_EVENT (6)
168 /* WLAN P2P user events */
169 #define SL_WLAN_P2P_DEV_FOUND_EVENT (7)
170 #define SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT (8)
171 #define SL_WLAN_CONNECTION_FAILED_EVENT (9)
172 /* SL_EVENT_CLASS_DEVICE user events */
173 #define SL_DEVICE_FATAL_ERROR_EVENT (1)
174 /* SL_EVENT_CLASS_BSD user events */
175 #define SL_SOCKET_TX_FAILED_EVENT (1)
176 #define SL_SOCKET_ASYNC_EVENT (2)
177 /* SL_EVENT_CLASS_NETAPP user events */
178 #define SL_NETAPP_IPV4_IPACQUIRED_EVENT (1)
179 #define SL_NETAPP_IPV6_IPACQUIRED_EVENT (2)
180 #define SL_NETAPP_IP_LEASED_EVENT (3)
181 #define SL_NETAPP_IP_RELEASED_EVENT (4)
182 
183 /* Server Events */
184 #define SL_NETAPP_HTTPGETTOKENVALUE_EVENT (1)
185 #define SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT (2)
186 
187 
188 /*
189  Declare the different event group classifications for sl_DevGet
190  for getting status indications
191  */
192 
193 /* Events list to mask/unmask*/
194 #define SL_EVENT_CLASS_GLOBAL (0)
195 #define SL_EVENT_CLASS_DEVICE (1)
196 #define SL_EVENT_CLASS_WLAN (2)
197 #define SL_EVENT_CLASS_BSD (3)
198 #define SL_EVENT_CLASS_NETAPP (4)
199 #define SL_EVENT_CLASS_NETCFG (5)
200 #define SL_EVENT_CLASS_FS (6)
201 
202 
203 /****************** DEVICE CLASS status ****************/
204 #define EVENT_DROPPED_DEVICE_ASYNC_GENERAL_ERROR (0x00000001L)
205 #define STATUS_DEVICE_SMART_CONFIG_ACTIVE (0x80000000L)
206 
207 /****************** WLAN CLASS status ****************/
208 #define EVENT_DROPPED_WLAN_WLANASYNCONNECTEDRESPONSE (0x00000001L)
209 #define EVENT_DROPPED_WLAN_WLANASYNCDISCONNECTEDRESPONSE (0x00000002L)
210 #define EVENT_DROPPED_WLAN_STA_CONNECTED (0x00000004L)
211 #define EVENT_DROPPED_WLAN_STA_DISCONNECTED (0x00000008L)
212 #define STATUS_WLAN_STA_CONNECTED (0x80000000L)
213 
214 /****************** NETAPP CLASS status ****************/
215 #define EVENT_DROPPED_NETAPP_IPACQUIRED (0x00000001L)
216 #define EVENT_DROPPED_NETAPP_IPACQUIRED_V6 (0x00000002L)
217 #define EVENT_DROPPED_NETAPP_IP_LEASED (0x00000004L)
218 #define EVENT_DROPPED_NETAPP_IP_RELEASED (0x00000008L)
219 
220 /****************** BSD CLASS status ****************/
221 #define EVENT_DROPPED_SOCKET_TXFAILEDASYNCRESPONSE (0x00000001L)
222 
223 /****************** FS CLASS ****************/
224 
225 
226 
227 /*****************************************************************************/
228 /* Structure/Enum declarations */
229 /*****************************************************************************/
230 
231 #ifdef SL_IF_TYPE_UART
232 typedef struct
233 {
234  _u32 BaudRate;
235  _u8 FlowControlEnable;
236  _u8 CommPort;
237 } SlUartIfParams_t;
238 #endif
239 
240 typedef struct
241 {
242  _u32 ChipId;
243  _u32 FwVersion[4];
244  _u8 PhyVersion[4];
246 
247 typedef struct
248 {
249  _SlPartialVersion ChipFwAndPhyVersion;
250  _u32 NwpVersion[4];
251  _u16 RomVersion;
252  _u16 Padding;
254 
255 typedef struct
256 {
257  _i8 status;
258  SlErrorSender_e sender;
260 
261 typedef union
262 {
263  sl_DeviceReport deviceEvent;
265 
266 typedef struct
267 {
268  _u32 Event;
269  _SlDeviceEventData_u EventData;
271 
272 typedef struct
273 {
274  /* time */
275  _u32 sl_tm_sec;
276  _u32 sl_tm_min;
277  _u32 sl_tm_hour;
278  /* date */
279  _u32 sl_tm_day; /* 1-31 */
280  _u32 sl_tm_mon; /* 1-12 */
281  _u32 sl_tm_year; /* YYYY 4 digits */
282  _u32 sl_tm_week_day; /* not required */
283  _u32 sl_tm_year_day; /* not required */
284  _u32 reserved[3];
285 }SlDateTime_t;
286 
287 
288 /******************************************************************************/
289 /* Type declarations */
290 /******************************************************************************/
291 typedef void (*P_INIT_CALLBACK)(_u32 Status);
292 
293 /*****************************************************************************/
294 /* Function prototypes */
295 /*****************************************************************************/
296 
346 #if _SL_INCLUDE_FUNC(sl_Start)
347 _i16 sl_Start(const void* pIfHdl, _i8* pDevName, const P_INIT_CALLBACK pInitCallBack);
348 #endif
349 
378 #if _SL_INCLUDE_FUNC(sl_Stop)
379 _i16 sl_Stop(_u16 timeout);
380 #endif
381 
382 
415 #if _SL_INCLUDE_FUNC(sl_DevSet)
416 _i32 sl_DevSet(_u8 DeviceSetId ,_u8 Option,_u8 ConfigLen, _u8 *pValues);
417 #endif
418 
477 #if _SL_INCLUDE_FUNC(sl_DevGet)
478 _i32 sl_DevGet(_u8 DeviceGetId, _u8 *pOption,_u8 *pConfigLen, _u8 *pValues);
479 #endif
480 
481 
529 #if _SL_INCLUDE_FUNC(sl_EventMaskSet)
530 _i16 sl_EventMaskSet(_u8 EventClass , _u32 Mask);
531 #endif
532 
569 #if _SL_INCLUDE_FUNC(sl_EventMaskGet)
570 _i16 sl_EventMaskGet(_u8 EventClass, _u32 *pMask);
571 #endif
572 
573 
594 #if _SL_INCLUDE_FUNC(sl_Task)
595 void sl_Task(void);
596 #endif
597 
598 
615 #ifdef SL_IF_TYPE_UART
616 #if _SL_INCLUDE_FUNC(sl_UartSetMode)
617 _i16 sl_UartSetMode(const SlUartIfParams_t* pUartParams);
618 #endif
619 #endif
620 
629 #ifdef __cplusplus
630 }
631 #endif /* __cplusplus */
632 
633 #endif /* __DEVICE_H__ */
634 
635 
_i16 sl_Start(const void *pIfHdl, _i8 *pDevName, const P_INIT_CALLBACK pInitCallBack)
Start the SimpleLink device.
Definition: device.h:266
Definition: device.h:240
_i16 sl_Stop(_u16 timeout)
Stop the SimpleLink device.
Definition: device.h:255
void sl_Task(void)
Internal function for setting device configurations.
Definition: device.h:261
Definition: device.h:272
Definition: device.h:247