HAL_AWSS_linux.c 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. #ifdef DEV_BIND_ENABLED
  2. #include "infra_config.h"
  3. #include <string.h>
  4. #include "infra_defs.h"
  5. #include "dev_bind_wrapper.h"
  6. #endif
  7. #if defined(WIFI_PROVISION_ENABLED)
  8. /*
  9. * Copyright (C) 2015-2018 Alibaba Group Holding Limited
  10. */
  11. #include "iot_import_awss.h"
  12. /**
  13. * @brief 获取配网服务(`AWSS`)的超时时间长度, 单位是毫秒
  14. *
  15. * @return 超时时长, 单位是毫秒
  16. * @note 推荐时长是60,0000毫秒
  17. */
  18. int HAL_Awss_Get_Timeout_Interval_Ms(void)
  19. {
  20. return 30 * 60 * 1000;
  21. }
  22. /**
  23. * @brief 获取在每个信道(`channel`)上扫描的时间长度, 单位是毫秒
  24. *
  25. * @return 时间长度, 单位是毫秒
  26. * @note 推荐时长是200毫秒到400毫秒
  27. */
  28. int HAL_Awss_Get_Channelscan_Interval_Ms(void)
  29. {
  30. return 250;
  31. }
  32. /**
  33. * @brief 设置Wi-Fi网卡工作在监听(Monitor)模式, 并在收到802.11帧的时候调用被传入的回调函数
  34. *
  35. * @param[in] cb @n A function pointer, called back when wifi receive a frame.
  36. */
  37. void HAL_Awss_Open_Monitor(_IN_ awss_recv_80211_frame_cb_t cb)
  38. {
  39. }
  40. /**
  41. * @brief 设置Wi-Fi网卡离开监听(Monitor)模式, 并开始以站点(Station)模式工作
  42. */
  43. void HAL_Awss_Close_Monitor(void)
  44. {
  45. }
  46. /**
  47. * @brief 设置Wi-Fi网卡切换到指定的信道(channel)上
  48. *
  49. * @param[in] primary_channel @n Primary channel.
  50. * @param[in] secondary_channel @n Auxiliary channel if 40Mhz channel is supported, currently
  51. * this param is always 0.
  52. * @param[in] bssid @n A pointer to wifi BSSID on which awss lock the channel, most HAL
  53. * may ignore it.
  54. */
  55. void HAL_Awss_Switch_Channel(
  56. _IN_ char primary_channel,
  57. _IN_OPT_ char secondary_channel,
  58. _IN_OPT_ uint8_t bssid[ETH_ALEN])
  59. {
  60. }
  61. /**
  62. * @brief 要求Wi-Fi网卡连接指定热点(Access Point)的函数
  63. *
  64. * @param[in] connection_timeout_ms @n AP connection timeout in ms or HAL_WAIT_INFINITE
  65. * @param[in] ssid @n AP ssid
  66. * @param[in] passwd @n AP passwd
  67. * @param[in] auth @n optional(AWSS_AUTH_TYPE_INVALID), AP auth info
  68. * @param[in] encry @n optional(AWSS_ENC_TYPE_INVALID), AP encry info
  69. * @param[in] bssid @n optional(NULL or zero mac address), AP bssid info
  70. * @param[in] channel @n optional, AP channel info
  71. * @return
  72. @verbatim
  73. = 0: connect AP & DHCP success
  74. = -1: connect AP or DHCP fail/timeout
  75. @endverbatim
  76. * @see None.
  77. * @note
  78. * If the STA connects the old AP, HAL should disconnect from the old AP firstly.
  79. * If bssid specifies the dest AP, HAL should use bssid to connect dest AP.
  80. */
  81. int HAL_Awss_Connect_Ap(
  82. _IN_ uint32_t connection_timeout_ms,
  83. _IN_ char ssid[HAL_MAX_SSID_LEN],
  84. _IN_ char passwd[HAL_MAX_PASSWD_LEN],
  85. _IN_OPT_ enum AWSS_AUTH_TYPE auth,
  86. _IN_OPT_ enum AWSS_ENC_TYPE encry,
  87. _IN_OPT_ uint8_t bssid[ETH_ALEN],
  88. _IN_OPT_ uint8_t channel)
  89. {
  90. return 0;
  91. }
  92. /**
  93. * @brief check system network is ready(get ip address) or not.
  94. *
  95. * @param None.
  96. * @return 0, net is not ready; 1, net is ready.
  97. * @see None.
  98. * @note None.
  99. */
  100. int HAL_Sys_Net_Is_Ready()
  101. {
  102. return 0;
  103. }
  104. /**
  105. * @brief 在当前信道(channel)上以基本数据速率(1Mbps)发送裸的802.11帧(raw 802.11 frame)
  106. *
  107. * @param[in] type @n see enum HAL_Awss_frame_type, currently only FRAME_BEACON
  108. * FRAME_PROBE_REQ is used
  109. * @param[in] buffer @n 80211 raw frame, include complete mac header & FCS field
  110. * @param[in] len @n 80211 raw frame length
  111. * @return
  112. @verbatim
  113. = 0, send success.
  114. = -1, send failure.
  115. = -2, unsupported.
  116. @endverbatim
  117. * @see None.
  118. * @note awss use this API send raw frame in wifi monitor mode & station mode
  119. */
  120. int HAL_Wifi_Send_80211_Raw_Frame(_IN_ enum HAL_Awss_Frame_Type type,
  121. _IN_ uint8_t *buffer, _IN_ int len)
  122. {
  123. return 0;
  124. }
  125. /**
  126. * @brief 在站点(Station)模式下使能或禁用对管理帧的过滤
  127. *
  128. * @param[in] filter_mask @n see mask macro in enum HAL_Awss_frame_type,
  129. * currently only FRAME_PROBE_REQ_MASK & FRAME_BEACON_MASK is used
  130. * @param[in] vendor_oui @n oui can be used for precise frame match, optional
  131. * @param[in] callback @n see awss_wifi_mgmt_frame_cb_t, passing 80211
  132. * frame or ie to callback. when callback is NULL
  133. * disable sniffer feature, otherwise enable it.
  134. * @return
  135. @verbatim
  136. = 0, success
  137. = -1, fail
  138. = -2, unsupported.
  139. @endverbatim
  140. * @see None.
  141. * @note awss use this API to filter specific mgnt frame in wifi station mode
  142. */
  143. int HAL_Wifi_Enable_Mgmt_Frame_Filter(
  144. _IN_ uint32_t filter_mask,
  145. _IN_OPT_ uint8_t vendor_oui[3],
  146. _IN_ awss_wifi_mgmt_frame_cb_t callback)
  147. {
  148. return 0;
  149. }
  150. /**
  151. * @brief 启动一次Wi-Fi的空中扫描(Scan)
  152. *
  153. * @param[in] cb @n pass ssid info(scan result) to this callback one by one
  154. * @return 0 for wifi scan is done, otherwise return -1
  155. * @see None.
  156. * @note
  157. * This API should NOT exit before the invoking for cb is finished.
  158. * This rule is something like the following :
  159. * HAL_Wifi_Scan() is invoked...
  160. * ...
  161. * for (ap = first_ap; ap <= last_ap; ap = next_ap){
  162. * cb(ap)
  163. * }
  164. * ...
  165. * HAL_Wifi_Scan() exit...
  166. */
  167. int HAL_Wifi_Scan(awss_wifi_scan_result_cb_t cb)
  168. {
  169. return 0;
  170. }
  171. /**
  172. * @brief 获取所连接的热点(Access Point)的信息
  173. *
  174. * @param[out] ssid: array to store ap ssid. It will be null if ssid is not required.
  175. * @param[out] passwd: array to store ap password. It will be null if ap password is not required.
  176. * @param[out] bssid: array to store ap bssid. It will be null if bssid is not required.
  177. * @return
  178. @verbatim
  179. = 0: succeeded
  180. = -1: failed
  181. @endverbatim
  182. * @see None.
  183. * @note
  184. * If the STA dosen't connect AP successfully, HAL should return -1 and not touch the ssid/passwd/bssid buffer.
  185. */
  186. int HAL_Wifi_Get_Ap_Info(
  187. _OU_ char ssid[HAL_MAX_SSID_LEN],
  188. _OU_ char passwd[HAL_MAX_PASSWD_LEN],
  189. _OU_ uint8_t bssid[ETH_ALEN])
  190. {
  191. return 0;
  192. }
  193. /* @brief 打开当前设备热点,并把设备由SoftAP模式切换到AP模式
  194. */
  195. int HAL_Awss_Open_Ap(const char *ssid, const char *passwd, int beacon_interval, int hide)
  196. {
  197. return 0;
  198. }
  199. /* @brief 关闭当前设备热点,并把设备由SoftAP模式切换到Station模式
  200. */
  201. int HAL_Awss_Close_Ap()
  202. {
  203. return 0;
  204. }
  205. #endif /* #if defined(HAL_AWSS) */
  206. #ifdef DEV_BIND_ENABLED
  207. /**
  208. * @brief 获取Wi-Fi网口的MAC地址, 格式应当是"XX:XX:XX:XX:XX:XX"
  209. *
  210. * @param mac_str : 用于存放MAC地址字符串的缓冲区数组
  211. * @return 指向缓冲区数组起始位置的字符指针
  212. */
  213. char *HAL_Wifi_Get_Mac(_OU_ char mac_str[HAL_MAC_LEN])
  214. {
  215. strcpy(mac_str, "18:FE:34:12:33:44");
  216. return mac_str;
  217. }
  218. #endif