wlan.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. /*****************************************************************************
  2. *
  3. * wlan.h - CC3000 Host Driver Implementation.
  4. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. *
  13. * Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the
  16. * distribution.
  17. *
  18. * Neither the name of Texas Instruments Incorporated nor the names of
  19. * its contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  28. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. *****************************************************************************/
  35. #ifndef __CC3000_WLAN_H__
  36. #define __CC3000_WLAN_H__
  37. #include "cc3000_common.h"
  38. //*****************************************************************************
  39. //
  40. // If building with a C++ compiler, make all of the definitions in this header
  41. // have a C binding.
  42. //
  43. //*****************************************************************************
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. #define WLAN_SEC_UNSEC (0)
  48. #define WLAN_SEC_WEP (1)
  49. #define WLAN_SEC_WPA (2)
  50. #define WLAN_SEC_WPA2 (3)
  51. //*****************************************************************************
  52. //
  53. //! \addtogroup wlan_api
  54. //! @{
  55. //
  56. //*****************************************************************************
  57. //*****************************************************************************
  58. //
  59. //! wlan_init
  60. //!
  61. //! @param sWlanCB Asynchronous events callback.
  62. //! 0 no event call back.
  63. //! -call back parameters:
  64. //! 1) event_type: HCI_EVNT_WLAN_UNSOL_CONNECT connect event,
  65. //! HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event,
  66. //! HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE config done,
  67. //! HCI_EVNT_WLAN_UNSOL_DHCP dhcp report,
  68. //! HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report OR
  69. //! HCI_EVNT_WLAN_KEEPALIVE keepalive.
  70. //! 2) data: pointer to extra data that received by the event
  71. //! (NULL no data).
  72. //! 3) length: data length.
  73. //! -Events with extra data:
  74. //! HCI_EVNT_WLAN_UNSOL_DHCP: 4 bytes IP, 4 bytes Mask,
  75. //! 4 bytes default gateway, 4 bytes DHCP server and 4 bytes
  76. //! for DNS server.
  77. //! HCI_EVNT_WLAN_ASYNC_PING_REPORT: 4 bytes Packets sent,
  78. //! 4 bytes Packets received, 4 bytes Min round time,
  79. //! 4 bytes Max round time and 4 bytes for Avg round time.
  80. //!
  81. //! @param sFWPatches 0 no patch or pointer to FW patches
  82. //! @param sDriverPatches 0 no patch or pointer to driver patches
  83. //! @param sBootLoaderPatches 0 no patch or pointer to bootloader patches
  84. //! @param sReadWlanInterruptPin init callback. the callback read wlan
  85. //! interrupt status.
  86. //! @param sWlanInterruptEnable init callback. the callback enable wlan
  87. //! interrupt.
  88. //! @param sWlanInterruptDisable init callback. the callback disable wlan
  89. //! interrupt.
  90. //! @param sWriteWlanPin init callback. the callback write value
  91. //! to device pin.
  92. //!
  93. //! @return none
  94. //!
  95. //! @sa wlan_set_event_mask , wlan_start , wlan_stop
  96. //!
  97. //! @brief Initialize wlan driver
  98. //!
  99. //! @warning This function must be called before ANY other wlan driver function
  100. //
  101. //*****************************************************************************
  102. extern void wlan_init( tWlanCB sWlanCB,
  103. tFWPatches sFWPatches,
  104. tDriverPatches sDriverPatches,
  105. tBootLoaderPatches sBootLoaderPatches,
  106. tWlanReadInteruptPin sReadWlanInterruptPin,
  107. tWlanInterruptEnable sWlanInterruptEnable,
  108. tWlanInterruptDisable sWlanInterruptDisable,
  109. tWriteWlanPin sWriteWlanPin);
  110. //*****************************************************************************
  111. //
  112. //! wlan_start
  113. //!
  114. //! @param usPatchesAvailableAtHost - flag to indicate if patches available
  115. //! from host or from EEPROM. Due to the
  116. //! fact the patches are burn to the EEPROM
  117. //! using the patch programmer utility, the
  118. //! patches will be available from the EEPROM
  119. //! and not from the host.
  120. //!
  121. //! @return none
  122. //!
  123. //! @brief Start WLAN device. This function asserts the enable pin of
  124. //! the device (WLAN_EN), starting the HW initialization process.
  125. //! The function blocked until device Initialization is completed.
  126. //! Function also configure patches (FW, driver or bootloader)
  127. //! and calls appropriate device callbacks.
  128. //!
  129. //! @Note Prior calling the function wlan_init shall be called.
  130. //! @Warning This function must be called after wlan_init and before any
  131. //! other wlan API
  132. //! @sa wlan_init , wlan_stop
  133. //!
  134. //
  135. //*****************************************************************************
  136. extern int wlan_start(UINT16 usPatchesAvailableAtHost);
  137. //*****************************************************************************
  138. //
  139. //! wlan_stop
  140. //!
  141. //! @param none
  142. //!
  143. //! @return none
  144. //!
  145. //! @brief Stop WLAN device by putting it into reset state.
  146. //!
  147. //! @sa wlan_start
  148. //
  149. //*****************************************************************************
  150. extern void wlan_stop(void);
  151. //*****************************************************************************
  152. //
  153. //! wlan_connect
  154. //!
  155. //! @param sec_type security options:
  156. //! WLAN_SEC_UNSEC,
  157. //! WLAN_SEC_WEP (ASCII support only),
  158. //! WLAN_SEC_WPA or WLAN_SEC_WPA2
  159. //! @param ssid up to 32 bytes and is ASCII SSID of the AP
  160. //! @param ssid_len length of the SSID
  161. //! @param bssid 6 bytes specified the AP bssid
  162. //! @param key up to 32 bytes specified the AP security key
  163. //! @param key_len key length
  164. //!
  165. //! @return On success, zero is returned. On error, negative is returned.
  166. //! Note that even though a zero is returned on success to trigger
  167. //! connection operation, it does not mean that CCC3000 is already
  168. //! connected. An asynchronous "Connected" event is generated when
  169. //! actual association process finishes and CC3000 is connected to
  170. //! the AP. If DHCP is set, An asynchronous "DHCP" event is
  171. //! generated when DHCP process is finish.
  172. //!
  173. //!
  174. //! @brief Connect to AP
  175. //! @warning Please Note that when connection to AP configured with security
  176. //! type WEP, please confirm that the key is set as ASCII and not
  177. //! as HEX.
  178. //! @sa wlan_disconnect
  179. //
  180. //*****************************************************************************
  181. #ifndef CC3000_TINY_DRIVER
  182. extern INT32 wlan_connect(UINT32 ulSecType, CHAR *ssid, INT32 ssid_len,
  183. UINT8 *bssid, UINT8 *key, INT32 key_len);
  184. #else
  185. extern INT32 wlan_connect(CHAR *ssid, INT32 ssid_len);
  186. #endif
  187. //*****************************************************************************
  188. //
  189. //! wlan_disconnect
  190. //!
  191. //! @return 0 disconnected done, other CC3000 already disconnected
  192. //!
  193. //! @brief Disconnect connection from AP.
  194. //!
  195. //! @sa wlan_connect
  196. //
  197. //*****************************************************************************
  198. extern INT32 wlan_disconnect(void);
  199. //*****************************************************************************
  200. //
  201. //! wlan_add_profile
  202. //!
  203. //! @param ulSecType WLAN_SEC_UNSEC,WLAN_SEC_WEP,WLAN_SEC_WPA,WLAN_SEC_WPA2
  204. //! @param ucSsid ssid SSID up to 32 bytes
  205. //! @param ulSsidLen ssid length
  206. //! @param ucBssid bssid 6 bytes
  207. //! @param ulPriority ulPriority profile priority. Lowest priority:0.
  208. //! @param ulPairwiseCipher_Or_TxKeyLen key length for WEP security
  209. //! @param ulGroupCipher_TxKeyIndex key index
  210. //! @param ulKeyMgmt KEY management
  211. //! @param ucPf_OrKey security key
  212. //! @param ulPassPhraseLen security key length for WPA\WPA2
  213. //!
  214. //! @return On success, index (1-7) of the stored profile is returned.
  215. //! On error, -1 is returned.
  216. //!
  217. //! @brief When auto start is enabled, the device connects to
  218. //! station from the profiles table. Up to 7 profiles are supported.
  219. //! If several profiles configured the device choose the highest
  220. //! priority profile, within each priority group, device will choose
  221. //! profile based on security policy, signal strength, etc
  222. //! parameters. All the profiles are stored in CC3000 NVMEM.
  223. //!
  224. //! @sa wlan_ioctl_del_profile
  225. //
  226. //*****************************************************************************
  227. extern INT32 wlan_add_profile(UINT32 ulSecType, UINT8* ucSsid,
  228. UINT32 ulSsidLen,
  229. UINT8 *ucBssid,
  230. UINT32 ulPriority,
  231. UINT32 ulPairwiseCipher_Or_Key,
  232. UINT32 ulGroupCipher_TxKeyLen,
  233. UINT32 ulKeyMgmt,
  234. UINT8* ucPf_OrKey,
  235. UINT32 ulPassPhraseLen);
  236. //*****************************************************************************
  237. //
  238. //! wlan_ioctl_del_profile
  239. //!
  240. //! @param index number of profile to delete
  241. //!
  242. //! @return On success, zero is returned. On error, -1 is returned
  243. //!
  244. //! @brief Delete WLAN profile
  245. //!
  246. //! @Note In order to delete all stored profile, set index to 255.
  247. //!
  248. //! @sa wlan_add_profile
  249. //
  250. //*****************************************************************************
  251. extern INT32 wlan_ioctl_del_profile(UINT32 ulIndex);
  252. //*****************************************************************************
  253. //
  254. //! wlan_set_event_mask
  255. //!
  256. //! @param mask mask option:
  257. //! HCI_EVNT_WLAN_UNSOL_CONNECT connect event
  258. //! HCI_EVNT_WLAN_UNSOL_DISCONNECT disconnect event
  259. //! HCI_EVNT_WLAN_ASYNC_SIMPLE_CONFIG_DONE smart config done
  260. //! HCI_EVNT_WLAN_UNSOL_INIT init done
  261. //! HCI_EVNT_WLAN_UNSOL_DHCP dhcp event report
  262. //! HCI_EVNT_WLAN_ASYNC_PING_REPORT ping report
  263. //! HCI_EVNT_WLAN_KEEPALIVE keepalive
  264. //! HCI_EVNT_WLAN_TX_COMPLETE - disable information on end of transmission
  265. //! Saved: no.
  266. //!
  267. //! @return On success, zero is returned. On error, -1 is returned
  268. //!
  269. //! @brief Mask event according to bit mask. In case that event is
  270. //! masked (1), the device will not send the masked event to host.
  271. //
  272. //*****************************************************************************
  273. extern INT32 wlan_set_event_mask(UINT32 ulMask);
  274. //*****************************************************************************
  275. //
  276. //! wlan_ioctl_statusget
  277. //!
  278. //! @param none
  279. //!
  280. //! @return WLAN_STATUS_DISCONNECTED, WLAN_STATUS_SCANING,
  281. //! STATUS_CONNECTING or WLAN_STATUS_CONNECTED
  282. //!
  283. //! @brief get wlan status: disconnected, scanning, connecting or connected
  284. //
  285. //*****************************************************************************
  286. extern INT32 wlan_ioctl_statusget(void);
  287. //*****************************************************************************
  288. //
  289. //! wlan_ioctl_set_connection_policy
  290. //!
  291. //! @param should_connect_to_open_ap enable(1), disable(0) connect to any
  292. //! available AP. This parameter corresponds to the configuration of
  293. //! item # 3 in the brief description.
  294. //! @param should_use_fast_connect enable(1), disable(0). if enabled, tries
  295. //! to connect to the last connected AP. This parameter corresponds
  296. //! to the configuration of item # 1 in the brief description.
  297. //! @param auto_start enable(1), disable(0) auto connect
  298. //! after reset and periodically reconnect if needed. This
  299. //! configuration configures option 2 in the above description.
  300. //!
  301. //! @return On success, zero is returned. On error, -1 is returned
  302. //!
  303. //! @brief When auto is enabled, the device tries to connect according
  304. //! the following policy:
  305. //! 1) If fast connect is enabled and last connection is valid,
  306. //! the device will try to connect to it without the scanning
  307. //! procedure (fast). The last connection will be marked as
  308. //! invalid, due to adding/removing profile.
  309. //! 2) If profile exists, the device will try to connect it
  310. //! (Up to seven profiles).
  311. //! 3) If fast and profiles are not found, and open mode is
  312. //! enabled, the device will try to connect to any AP.
  313. //! * Note that the policy settings are stored in the CC3000 NVMEM.
  314. //!
  315. //! @sa wlan_add_profile , wlan_ioctl_del_profile
  316. //
  317. //*****************************************************************************
  318. extern INT32 wlan_ioctl_set_connection_policy(
  319. UINT32 should_connect_to_open_ap,
  320. UINT32 should_use_fast_connect,
  321. UINT32 ulUseProfiles);
  322. //*****************************************************************************
  323. //
  324. //! wlan_ioctl_get_scan_results
  325. //!
  326. //! @param[in] scan_timeout parameter not supported
  327. //! @param[out] ucResults scan result (_wlan_full_scan_results_args_t)
  328. //!
  329. //! @return On success, zero is returned. On error, -1 is returned
  330. //!
  331. //! @brief Gets entry from scan result table.
  332. //! The scan results are returned one by one, and each entry
  333. //! represents a single AP found in the area. The following is a
  334. //! format of the scan result:
  335. //! - 4 Bytes: number of networks found
  336. //! - 4 Bytes: The status of the scan: 0 - aged results,
  337. //! 1 - results valid, 2 - no results
  338. //! - 42 bytes: Result entry, where the bytes are arranged as follows:
  339. //!
  340. //! - 1 bit isValid - is result valid or not
  341. //! - 7 bits rssi - RSSI value;
  342. //! - 2 bits: securityMode - security mode of the AP:
  343. //! 0 - Open, 1 - WEP, 2 WPA, 3 WPA2
  344. //! - 6 bits: SSID name length
  345. //! - 2 bytes: the time at which the entry has entered into
  346. //! scans result table
  347. //! - 32 bytes: SSID name
  348. //! - 6 bytes: BSSID
  349. //!
  350. //! @Note scan_timeout, is not supported on this version.
  351. //!
  352. //! @sa wlan_ioctl_set_scan_params
  353. //
  354. //*****************************************************************************
  355. extern INT32 wlan_ioctl_get_scan_results(UINT32 ulScanTimeout,
  356. UINT8 *ucResults);
  357. //*****************************************************************************
  358. //
  359. //! wlan_ioctl_set_scan_params
  360. //!
  361. //! @param uiEnable - start/stop application scan:
  362. //! 1 = start scan with default interval value of 10 min.
  363. //! in order to set a different scan interval value apply the value
  364. //! in milliseconds. minimum 1 second. 0=stop). Wlan reset
  365. //! (wlan_stop() wlan_start()) is needed when changing scan interval
  366. //! value. Saved: No
  367. //! @param uiMinDwellTime minimum dwell time value to be used for each
  368. //! channel, in milliseconds. Saved: yes
  369. //! Recommended Value: 100 (Default: 20)
  370. //! @param uiMaxDwellTime maximum dwell time value to be used for each
  371. //! channel, in milliseconds. Saved: yes
  372. //! Recommended Value: 100 (Default: 30)
  373. //! @param uiNumOfProbeRequests max probe request between dwell time.
  374. //! Saved: yes. Recommended Value: 5 (Default:2)
  375. //! @param uiChannelMask bitwise, up to 13 channels (0x1fff).
  376. //! Saved: yes. Default: 0x7ff
  377. //! @param uiRSSIThreshold RSSI threshold. Saved: yes (Default: -80)
  378. //! @param uiSNRThreshold NSR threshold. Saved: yes (Default: 0)
  379. //! @param uiDefaultTxPower probe Tx power. Saved: yes (Default: 205)
  380. //! @param aiIntervalList pointer to array with 16 entries (16 channels)
  381. //! each entry (UINT32) holds timeout between periodic scan
  382. //! (connection scan) - in milliseconds. Saved: yes. Default 2000ms.
  383. //!
  384. //! @return On success, zero is returned. On error, -1 is returned
  385. //!
  386. //! @brief start and stop scan procedure. Set scan parameters.
  387. //!
  388. //! @Note uiDefaultTxPower, is not supported on this version.
  389. //!
  390. //! @sa wlan_ioctl_get_scan_results
  391. //
  392. //*****************************************************************************
  393. extern INT32 wlan_ioctl_set_scan_params(UINT32 uiEnable, UINT32
  394. uiMinDwellTime,UINT32 uiMaxDwellTime,
  395. UINT32 uiNumOfProbeRequests,
  396. UINT32 uiChannelMask,
  397. INT32 iRSSIThreshold,UINT32 uiSNRThreshold,
  398. UINT32 uiDefaultTxPower,
  399. UINT32 *aiIntervalList);
  400. //*****************************************************************************
  401. //
  402. //! wlan_smart_config_start
  403. //!
  404. //! @param algoEncryptedFlag indicates whether the information is encrypted
  405. //!
  406. //! @return On success, zero is returned. On error, -1 is returned
  407. //!
  408. //! @brief Start to acquire device profile. The device acquire its own
  409. //! profile, if profile message is found. The acquired AP information
  410. //! is stored in CC3000 EEPROM only in case AES128 encryption is used.
  411. //! In case AES128 encryption is not used, a profile is created by
  412. //! CC3000 internally.
  413. //!
  414. //! @Note An asynchronous event - Smart Config Done will be generated as soon
  415. //! as the process finishes successfully.
  416. //!
  417. //! @sa wlan_smart_config_set_prefix , wlan_smart_config_stop
  418. //
  419. //*****************************************************************************
  420. extern INT32 wlan_smart_config_start(UINT32 algoEncryptedFlag);
  421. //*****************************************************************************
  422. //
  423. //! wlan_smart_config_stop
  424. //!
  425. //! @param algoEncryptedFlag indicates whether the information is encrypted
  426. //!
  427. //! @return On success, zero is returned. On error, -1 is returned
  428. //!
  429. //! @brief Stop the acquire profile procedure
  430. //!
  431. //! @sa wlan_smart_config_start , wlan_smart_config_set_prefix
  432. //
  433. //*****************************************************************************
  434. extern INT32 wlan_smart_config_stop(void);
  435. //*****************************************************************************
  436. //
  437. //! wlan_smart_config_set_prefix
  438. //!
  439. //! @param newPrefix 3 bytes identify the SSID prefix for the Smart Config.
  440. //!
  441. //! @return On success, zero is returned. On error, -1 is returned
  442. //!
  443. //! @brief Configure station ssid prefix. The prefix is used internally
  444. //! in CC3000. It should always be TTT.
  445. //!
  446. //! @Note The prefix is stored in CC3000 NVMEM
  447. //!
  448. //! @sa wlan_smart_config_start , wlan_smart_config_stop
  449. //
  450. //*****************************************************************************
  451. extern INT32 wlan_smart_config_set_prefix(CHAR* cNewPrefix);
  452. //*****************************************************************************
  453. //
  454. //! wlan_smart_config_process
  455. //!
  456. //! @param none
  457. //!
  458. //! @return On success, zero is returned. On error, -1 is returned
  459. //!
  460. //! @brief process the acquired data and store it as a profile. The acquired
  461. //! AP information is stored in CC3000 EEPROM encrypted.
  462. //! The encrypted data is decrypted and stored as a profile.
  463. //! behavior is as defined by connection policy.
  464. //
  465. //*****************************************************************************
  466. extern INT32 wlan_smart_config_process(void);
  467. //*****************************************************************************
  468. //
  469. // Close the Doxygen group.
  470. //! @}
  471. //
  472. //*****************************************************************************
  473. //*****************************************************************************
  474. //
  475. // Mark the end of the C bindings section for C++ compilers.
  476. //
  477. //*****************************************************************************
  478. #ifdef __cplusplus
  479. }
  480. #endif // __cplusplus
  481. #endif // __CC3000_WLAN_H__