netapp.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. /*****************************************************************************
  2. *
  3. * netapp.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_NETAPP_H__
  36. #define __CC3000_NETAPP_H__
  37. #include "data_types.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. //*****************************************************************************
  48. //
  49. //! \addtogroup netapp_api
  50. //! @{
  51. //
  52. //*****************************************************************************
  53. typedef struct _netapp_dhcp_ret_args_t
  54. {
  55. UINT8 aucIP[4];
  56. UINT8 aucSubnetMask[4];
  57. UINT8 aucDefaultGateway[4];
  58. UINT8 aucDHCPServer[4];
  59. UINT8 aucDNSServer[4];
  60. }tNetappDhcpParams;
  61. typedef struct _netapp_ipconfig_ret_args_t
  62. {
  63. UINT8 aucIP[4];
  64. UINT8 aucSubnetMask[4];
  65. UINT8 aucDefaultGateway[4];
  66. UINT8 aucDHCPServer[4];
  67. UINT8 aucDNSServer[4];
  68. UINT8 uaMacAddr[6];
  69. UINT8 uaSSID[32];
  70. }tNetappIpconfigRetArgs;
  71. /*Ping send report parameters*/
  72. typedef struct _netapp_pingreport_args
  73. {
  74. UINT32 packets_sent;
  75. UINT32 packets_received;
  76. UINT32 min_round_time;
  77. UINT32 max_round_time;
  78. UINT32 avg_round_time;
  79. } netapp_pingreport_args_t;
  80. //*****************************************************************************
  81. //
  82. //! netapp_config_mac_adrress
  83. //!
  84. //! @param mac device mac address, 6 bytes. Saved: yes
  85. //!
  86. //! @return return on success 0, otherwise error.
  87. //!
  88. //! @brief Configure device MAC address and store it in NVMEM.
  89. //! The value of the MAC address configured through the API will
  90. //! be stored in CC3000 non volatile memory, thus preserved
  91. //! over resets.
  92. //
  93. //*****************************************************************************
  94. extern INT32 netapp_config_mac_adrress( UINT8 *mac );
  95. //*****************************************************************************
  96. //
  97. //! netapp_dhcp
  98. //!
  99. //! @param aucIP device mac address, 6 bytes. Saved: yes
  100. //! @param aucSubnetMask device mac address, 6 bytes. Saved: yes
  101. //! @param aucDefaultGateway device mac address, 6 bytes. Saved: yes
  102. //! @param aucDNSServer device mac address, 6 bytes. Saved: yes
  103. //!
  104. //! @return return on success 0, otherwise error.
  105. //!
  106. //! @brief netapp_dhcp is used to configure the network interface,
  107. //! static or dynamic (DHCP).\n In order to activate DHCP mode,
  108. //! aucIP, aucSubnetMask, aucDefaultGateway must be 0.
  109. //! The default mode of CC3000 is DHCP mode.
  110. //! Note that the configuration is saved in non volatile memory
  111. //! and thus preserved over resets.
  112. //!
  113. //! @note If the mode is altered a reset of CC3000 device is required
  114. //! in order to apply changes.\nAlso note that asynchronous event
  115. //! of DHCP_EVENT, which is generated when an IP address is
  116. //! allocated either by the DHCP server or due to static
  117. //! allocation is generated only upon a connection to the
  118. //! AP was established.
  119. //!
  120. //*****************************************************************************
  121. extern INT32 netapp_dhcp(UINT32 *aucIP, UINT32 *aucSubnetMask,UINT32 *aucDefaultGateway, UINT32 *aucDNSServer);
  122. //*****************************************************************************
  123. //
  124. //! netapp_timeout_values
  125. //!
  126. //! @param aucDHCP DHCP lease time request, also impact
  127. //! the DHCP renew timeout. Range: [0-0xffffffff] seconds,
  128. //! 0 or 0xffffffff == infinity lease timeout.
  129. //! Resolution:10 seconds. Influence: only after
  130. //! reconnecting to the AP.
  131. //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 10 seconds.
  132. //! The parameter is saved into the CC3000 NVMEM.
  133. //! The default value on CC3000 is 14400 seconds.
  134. //!
  135. //! @param aucARP ARP refresh timeout, if ARP entry is not updated by
  136. //! incoming packet, the ARP entry will be deleted by
  137. //! the end of the timeout.
  138. //! Range: [0-0xffffffff] seconds, 0 == infinity ARP timeout
  139. //! Resolution: 10 seconds. Influence: on runtime.
  140. //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 10 seconds
  141. //! The parameter is saved into the CC3000 NVMEM.
  142. //! The default value on CC3000 is 3600 seconds.
  143. //!
  144. //! @param aucKeepalive Keepalive event sent by the end of keepalive timeout
  145. //! Range: [0-0xffffffff] seconds, 0 == infinity timeout
  146. //! Resolution: 10 seconds.
  147. //! Influence: on runtime.
  148. //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 10 sec
  149. //! The parameter is saved into the CC3000 NVMEM.
  150. //! The default value on CC3000 is 10 seconds.
  151. //!
  152. //! @param aucInactivity Socket inactivity timeout, socket timeout is
  153. //! refreshed by incoming or outgoing packet, by the
  154. //! end of the socket timeout the socket will be closed
  155. //! Range: [0-0xffffffff] sec, 0 == infinity timeout.
  156. //! Resolution: 10 seconds. Influence: on runtime.
  157. //! Minimal bound value: MIN_TIMER_VAL_SECONDS - 10 sec
  158. //! The parameter is saved into the CC3000 NVMEM.
  159. //! The default value on CC3000 is 60 seconds.
  160. //!
  161. //! @return return on success 0, otherwise error.
  162. //!
  163. //! @brief Set new timeout values. Function set new timeout values for:
  164. //! DHCP lease timeout, ARP refresh timeout, keepalive event
  165. //! timeout and socket inactivity timeout
  166. //!
  167. //! @note If a parameter set to non zero value which is less than 10s,
  168. //! it will be set automatically to 10s.
  169. //!
  170. //*****************************************************************************
  171. #ifndef CC3000_TINY_DRIVER
  172. extern INT32 netapp_timeout_values(UINT32 *aucDHCP, UINT32 *aucARP, UINT32 *aucKeepalive, UINT32 *aucInactivity);
  173. #endif
  174. //*****************************************************************************
  175. //
  176. //! netapp_ping_send
  177. //!
  178. //! @param ip destination IP address
  179. //! @param pingAttempts number of echo requests to send
  180. //! @param pingSize send buffer size which may be up to 1400 bytes
  181. //! @param pingTimeout Time to wait for a response,in milliseconds.
  182. //!
  183. //! @return return on success 0, otherwise error.
  184. //!
  185. //! @brief send ICMP ECHO_REQUEST to network hosts
  186. //!
  187. //! @note If an operation finished successfully asynchronous ping report
  188. //! event will be generated. The report structure is as defined
  189. //! by structure netapp_pingreport_args_t.
  190. //!
  191. //! @warning Calling this function while a previous Ping Requests are in
  192. //! progress will stop the previous ping request.
  193. //*****************************************************************************
  194. #ifndef CC3000_TINY_DRIVER
  195. extern INT32 netapp_ping_send(UINT32 *ip, UINT32 ulPingAttempts, UINT32 ulPingSize, UINT32 ulPingTimeout);
  196. #endif
  197. //*****************************************************************************
  198. //
  199. //! netapp_ping_stop
  200. //!
  201. //! @param none
  202. //!
  203. //! @return On success, zero is returned. On error, -1 is returned.
  204. //!
  205. //! @brief Stop any ping request.
  206. //!
  207. //!
  208. //*****************************************************************************
  209. #ifndef CC3000_TINY_DRIVER
  210. extern INT32 netapp_ping_stop();
  211. #endif
  212. //*****************************************************************************
  213. //
  214. //! netapp_ping_report
  215. //!
  216. //! @param none
  217. //!
  218. //! @return none
  219. //!
  220. //! @brief Request for ping status. This API triggers the CC3000 to send
  221. //! asynchronous events: HCI_EVNT_WLAN_ASYNC_PING_REPORT.
  222. //! This event will carry the report structure:
  223. //! netapp_pingreport_args_t. This structure is filled in with ping
  224. //! results up till point of triggering API.
  225. //! netapp_pingreport_args_t:\n packets_sent - echo sent,
  226. //! packets_received - echo reply, min_round_time - minimum
  227. //! round time, max_round_time - max round time,
  228. //! avg_round_time - average round time
  229. //!
  230. //! @note When a ping operation is not active, the returned structure
  231. //! fields are 0.
  232. //!
  233. //*****************************************************************************
  234. #ifndef CC3000_TINY_DRIVER
  235. extern void netapp_ping_report();
  236. #endif
  237. //*****************************************************************************
  238. //
  239. //! netapp_ipconfig
  240. //!
  241. //! @param[out] ipconfig This argument is a pointer to a
  242. //! tNetappIpconfigRetArgs structure. This structure is
  243. //! filled in with the network interface configuration.
  244. //! tNetappIpconfigRetArgs:\n aucIP - ip address,
  245. //! aucSubnetMask - mask, aucDefaultGateway - default
  246. //! gateway address, aucDHCPServer - dhcp server address
  247. //! aucDNSServer - dns server address, uaMacAddr - mac
  248. //! address, uaSSID - connected AP ssid
  249. //!
  250. //! @return none
  251. //!
  252. //! @brief Obtain the CC3000 Network interface information.
  253. //! Note that the information is available only after the WLAN
  254. //! connection was established. Calling this function before
  255. //! associated, will cause non-defined values to be returned.
  256. //!
  257. //! @note The function is useful for figuring out the IP Configuration of
  258. //! the device when DHCP is used and for figuring out the SSID of
  259. //! the Wireless network the device is associated with.
  260. //!
  261. //*****************************************************************************
  262. extern void netapp_ipconfig( tNetappIpconfigRetArgs * ipconfig );
  263. //*****************************************************************************
  264. //
  265. //! netapp_arp_flush
  266. //!
  267. //! @param none
  268. //!
  269. //! @return none
  270. //!
  271. //! @brief Flushes ARP table
  272. //!
  273. //*****************************************************************************
  274. #ifndef CC3000_TINY_DRIVER
  275. extern INT32 netapp_arp_flush();
  276. #endif
  277. //*****************************************************************************
  278. //
  279. //! netapp_set_debug_level
  280. //!
  281. //! @param[in] level debug level. Bitwise [0-8],
  282. //! 0(disable)or 1(enable).\n Bitwise map: 0 - Critical
  283. //! message, 1 information message, 2 - core messages, 3 -
  284. //! HCI messages, 4 - Network stack messages, 5 - wlan
  285. //! messages, 6 - wlan driver messages, 7 - epprom messages,
  286. //! 8 - general messages. Default: 0x13f. Saved: no
  287. //!
  288. //! @return On success, zero is returned. On error, -1 is returned
  289. //!
  290. //! @brief Debug messages sent via the UART debug channel, this function
  291. //! enable/disable the debug level
  292. //!
  293. //*****************************************************************************
  294. #ifndef CC3000_TINY_DRIVER
  295. INT32 netapp_set_debug_level(UINT32 ulLevel);
  296. #endif
  297. //*****************************************************************************
  298. //
  299. // Close the Doxygen group.
  300. //! @}
  301. //
  302. //*****************************************************************************
  303. //*****************************************************************************
  304. //
  305. // Mark the end of the C bindings section for C++ compilers.
  306. //
  307. //*****************************************************************************
  308. #ifdef __cplusplus
  309. }
  310. #endif // __cplusplus
  311. #endif // __CC3000_NETAPP_H__