simplelink.h 35 KB

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