ql_api_bt.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907
  1. /** @file
  2. ql_api_bt.h
  3. @brief
  4. This file is used to define bt api for different Quectel Project.
  5. */
  6. /*================================================================
  7. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  8. Quectel Wireless Solution Proprietary and Confidential.
  9. =================================================================*/
  10. /*=================================================================
  11. EDIT HISTORY FOR MODULE
  12. This section contains comments describing changes made to the module.
  13. Notice that changes are listed in reverse chronological order.
  14. WHEN WHO WHAT, WHERE, WHY
  15. ------------ ------- -------------------------------------------------------------------------------
  16. =================================================================*/
  17. #ifndef QL_API_BT_H
  18. #define QL_API_BT_H
  19. #include "ql_api_common.h"
  20. #include "ql_api_bt_common.h"
  21. #include "ql_api_osi.h"
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /*========================================================================
  26. * Variable Definition
  27. *========================================================================*/
  28. typedef unsigned int QL_BT_STATUS;
  29. #define QL_BT_STATUS_SUCCESS 0
  30. #define QL_BT_STATUS_ERROR 1
  31. #define QL_BT_DEVICE_NAME_SIZE 41
  32. #define QL_BT_SPP_SEND_SIZE 128
  33. #define QL_BLE_VERSION_SIZE 128
  34. #define QL_BLE_SEND_DATA_MAX_SIZE 512
  35. #define QL_BLE_UPDATE_CONN_MIN_INTERVAL 60
  36. #define QL_BLE_UPDATE_CONN_MAX_INTERVAL 80
  37. #define QL_BLE_UPDATE_CONN_LATENCY 0
  38. #define QL_BLE_UPDATE_CONN_TIMEOUT 500
  39. #define QL_BLEADV_REAL_DATA_LEN 254 //256 - 2
  40. #define QL_BLESCAN_MAX_REMOTE_NAME_LEN 32
  41. #define QL_BLE_ADV_MIN_ADV 0x300
  42. #define QL_BLE_ADV_MAX_ADV 0x320
  43. #define QL_BLE_ADV_MAP 0x07
  44. #define QL_BLEADV_ADV_MAX 0x4000
  45. #define QL_BLEADV_ADV_MIN 0x20
  46. #define QL_BLE_SCAN_INTERVAL 0x100
  47. #define QL_BLE_SCAN_WINDOW 0x50
  48. #define QL_BLESCAN_SCAN_MAX 0x4000
  49. #define QL_BLESCAN_SCAN_MIN 0x4
  50. #define QL_BLE_WHITELIST_NUM_MAX 30 //8850 白名单上限
  51. #define QL_BLE_UPDATE_INTERVAL_MAX 3200
  52. #define QL_BLE_UPDATE_INTERVAL_MIN 6
  53. #define QL_BLE_UPDATE_LATENCY_MAX 499
  54. #define QL_BLE_UPDATE_LATENCY_MIN 0
  55. #define QL_BLE_UPDATE_TIMEOUT_MIN 10
  56. #define QL_BLE_UPDATE_TIMEOUT_MAX 3200
  57. #define QUEC_BT_RSSI_VALUE_MIN 0
  58. #define QUEC_BT_RSSI_VALUE_MAX 255
  59. typedef enum
  60. {
  61. QL_BT_NO_FILTER = 0,
  62. QL_BT_RSSI_FILTER = 1,
  63. QL_BT_NAME_FILTER = 2,
  64. QL_BT_SAME_DEV_FILTER = 3,
  65. }ql_bt_filter_type_e;
  66. typedef enum
  67. {
  68. QL_BT_NO_NAME_FILTER = 0,
  69. QL_BT_FULLNAME_FILTER = 1,
  70. QL_BT_PARTNAME_FILTER = 2,
  71. }ql_bt_namefilter_type_e;
  72. typedef enum
  73. {
  74. QL_BT_SAME_DEV_FILTER_ON = 0,
  75. QL_BT_SAME_DEV_FILTER_OFF = 1,
  76. }ql_bt_same_dev_filter_switch_e;
  77. typedef struct
  78. {
  79. UINT8 quec_bt_rssi_value;
  80. unsigned char quec_bt_keyword[QL_BLESCAN_MAX_REMOTE_NAME_LEN + 1];
  81. ql_bt_namefilter_type_e quec_bt_filter_type;
  82. ql_bt_same_dev_filter_switch_e quec_bt_same_dev_filter_switch;
  83. } quec_bt_filter_info_s;
  84. typedef enum
  85. {
  86. QL_BT_STOPED = 0, //bt/ble is stoped
  87. QL_BT_STARTED = 1, //bt/ble is started
  88. }ql_bt_state_e;
  89. typedef struct
  90. {
  91. unsigned short name[QL_BT_DEVICE_NAME_SIZE]; //bt name
  92. ql_bt_addr_s addr; //bt address
  93. unsigned int dev_class; //clasee level
  94. unsigned int rssi; //rssi
  95. }ql_bt_info_s;
  96. typedef enum
  97. {
  98. QL_BT_NONE_ENABLE = 0, //can't be discovered and connectable
  99. QL_BT_INQUIRY_ENABLE, //can be discovered,but can't be connected
  100. QL_BT_PAGE_ENABLE, //can't be discovered,but can be connected
  101. QL_BT_PAGE_AND_INQUIRY_ENABLE, //can be discovered and connected
  102. }ql_bt_visible_mode_e;
  103. typedef enum
  104. {
  105. QL_BT_SERVICE_NONE = 0,
  106. QL_BT_SERVICE_HANDFREE,
  107. QL_BT_SERVICE_HANDSET,
  108. QL_BT_SERVICE_OPP,
  109. QL_BT_SERVICE_FTP,
  110. QL_BT_SERVICE_A2DP,
  111. QL_BT_SERVICE_AVRCP,
  112. QL_BT_SERVICE_SPP,
  113. QL_BT_SERVICE_A2DP_SRC,
  114. QL_BT_SERVICE_AVRCP_TG,
  115. QL_BT_SERVICE_MAP_SERVER,
  116. QL_BT_SERVICE_PBAP_SERVER,
  117. QL_BT_SERVICE_HANDFREE_GATEWAY,
  118. QL_BT_SERVICE_HEADSET_GATEWAY,
  119. QL_BT_SERVICE_BLE_HID,
  120. QL_BT_SERVICE_ALL,
  121. }ql_bt_inquiry_type_e;
  122. typedef enum
  123. {
  124. QL_BLE_PUBLIC_ADDRESS = 0, //public address
  125. QL_BLE_RANDOM_ADDRESS = 1, //random address
  126. }ql_ble_address_mode_e;
  127. //ble whitelist information
  128. typedef struct
  129. {
  130. ql_ble_address_mode_e mode; //地址模式,0-公共地址,1-随机地址
  131. ql_bt_addr_s addr; //BLE地址
  132. }ql_ble_whitelist_info_s;
  133. typedef enum
  134. {
  135. QL_BLE_ADV_NONE_STATE = 0x00, //不处于广播状态
  136. QL_BLE_ADV_STATE, //处于广播状态
  137. }ql_ble_adv_state_e;
  138. typedef enum
  139. {
  140. QL_BLEADV_INV = 0, //可连接的非定向广播,默认选择
  141. QL_BLEADV_HDCDA = 1, //可连接高占空比的定向广播
  142. QL_BLEADV_SCAN_IND = 2, //可扫描的非定向广播
  143. QL_BLEADV_NONCONN_IND = 3, //不可连接的非定向广播
  144. QL_BLEADV_LDCDA = 4, //可连接低占空比的定向广播
  145. }ql_bleadv_type_info_e;
  146. typedef enum
  147. {
  148. QL_BLEADV_FILTER_0 = 0, //处理所有设备的扫描和连接请求
  149. QL_BLEADV_FILTER_1 = 1, //处理所有设备的连接请求和只处理白名单设备的扫描请求
  150. QL_BLEADV_FILTER_2 = 2, //处理所有设备的扫描请求和只处理白名单设备的连接请求
  151. QL_BLEADV_FILTER_3 = 3, //只处理白名单设备的连接和扫描请求
  152. }ql_bleadv_fliter_info_e;
  153. typedef struct
  154. {
  155. unsigned int max_adv; //广播最大间隔:范围0x0020-0x4000。gap 0.625ms, 20ms-10.24s
  156. unsigned int min_adv; //广播最小间隔:范围0x0020-0x4000。gap 0.625ms, 20ms-10.24s
  157. ql_bleadv_type_info_e adv_type; //广播类型
  158. unsigned char own_addr_type; //本地地址类型。0-公共地址,1-随机地址
  159. ql_ble_address_mode_e direct_address_mode; //定向地址类型:0 public address, 1 random address
  160. ql_bt_addr_s direct_addr; //定向地址
  161. unsigned char channel_map; //广播通道。bit0-37,bit1-38,bit2-39。默认3个信道都选择
  162. ql_bleadv_fliter_info_e filter; //广播过滤策略
  163. unsigned char discov_mode; //发现模式,GAP协议使用,默认为1(普通发现模式)
  164. unsigned char no_br_edr; //不用BR/EDR,默认为1
  165. unsigned char enable_adv; //使能广播,默认为1
  166. }ql_bleadv_typical_addr_param_s;
  167. typedef struct
  168. {
  169. unsigned int max_adv; //广播最大间隔:范围0x0020-0x4000。gap 0.625ms, 20ms-10.24s
  170. unsigned int min_adv; //广播最小间隔:范围0x0020-0x4000。gap 0.625ms, 20ms-10.24s
  171. ql_bleadv_type_info_e adv_type; //广播类型
  172. unsigned char own_addr_type; //本地地址类型。0-公共地址,1-随机地址
  173. unsigned char channel_map; //广播通道。bit0-37,bit1-38,bit2-39。默认3个信道都选择
  174. ql_bleadv_fliter_info_e filter; //广播过滤策略
  175. unsigned char discov_mode; //发现模式,GAP协议使用,默认为1(普通发现模式)
  176. unsigned char no_br_edr; //不用BR/EDR,默认为1
  177. unsigned char enable_adv; //使能广播,默认为1
  178. }ql_bleadv_param_s;
  179. typedef struct
  180. {
  181. unsigned char date_len; //广播数据长度,不超过31个字节
  182. unsigned char data[QL_BLE_ADV_SCAN_DATA_SIZE]; //广播数据
  183. }ql_bleadv_set_data_s;
  184. typedef struct
  185. {
  186. unsigned char date_len; //扩展广播数据长度,不超过255个字节
  187. unsigned char data[QL_BLE_EXP_ADV_SCAN_DATA_SIZE]; //扩展广播数据
  188. }ql_ble_expadv_set_data_s;
  189. typedef enum
  190. {
  191. QL_BLE_SCAN_NONE_STATE = 0x00, //不处于扫描状态
  192. QL_BLE_SCAN_STATE, //处于扫描状态
  193. }ql_ble_scan_state_e;
  194. typedef enum
  195. {
  196. QL_BLESCAN_PASSIVE = 0, //消极扫描
  197. QL_BLESCAN_ACTIVE = 1, //积极扫描,广播端设置的扫描回复数据才会有意义
  198. }ql_blescan_scan_mode_e;
  199. typedef enum
  200. {
  201. QL_BLESCAN_FILTER_0 = 0, //除了不是本设备的定向广播,其他所有的广播包
  202. QL_BLESCAN_FILTER_1 = 1, //除了不是本设备的定向广播,白名单设备的广播包
  203. QL_BLESCAN_FILTER_2 = 2, //非定向广播,指向本设备的定向广播或使用Resolvable private address的定向广播
  204. QL_BLESCAN_FILTER_3 = 3, //白名单设备非定向广播,指向本设备的定向广播或使用Resolvable private address的定向广播
  205. }ql_blescan_fliter_e;
  206. typedef struct
  207. {
  208. ql_blescan_scan_mode_e scan_mode; //默认为积极扫描
  209. unsigned int interval; //扫描间隔。范围:0x0004-0x4000,gap 0.625ms, 2.5ms-10.24s
  210. unsigned int window; //扫描时间。范围:0x0004-0x4000,gap 0.625ms, 2.5ms-10.24s
  211. ql_blescan_fliter_e filter; //扫描过滤策略,默认为0
  212. unsigned char own_addr_type; //本地地址类型,0-公共地址,1-随机地址
  213. }ql_blescan_scan_s;
  214. /*========================================================================
  215. * function Definition
  216. *========================================================================*/
  217. typedef void (*ql_bt_callback)(void *ind_msg_buf, void *ctx);
  218. //以下API为BT/BLE 共有
  219. /*****************************************************************
  220. * Function: ql_bt_start
  221. *
  222. * Description:
  223. * 开启BT/BLE
  224. *
  225. * Parameters:
  226. *
  227. * Return:ql_errcode_bt_e
  228. *
  229. *****************************************************************/
  230. ql_errcode_bt_e ql_bt_start();
  231. /*****************************************************************
  232. * Function: ql_bt_stop
  233. *
  234. * Description:
  235. * 关闭BT/BLE
  236. *
  237. * Parameters:
  238. *
  239. * Return:ql_errcode_bt_e
  240. *
  241. *****************************************************************/
  242. ql_errcode_bt_e ql_bt_stop();
  243. /*****************************************************************
  244. * Function: ql_bt_get_state
  245. *
  246. * Description:
  247. * 获取BT/BLE的开启状态
  248. *
  249. * Parameters:
  250. * bt_state [out] BT/BLE开启状态
  251. *
  252. * Return:ql_errcode_bt_e
  253. *
  254. *****************************************************************/
  255. ql_errcode_bt_e ql_bt_get_state(ql_bt_state_e *bt_state);
  256. /*****************************************************************
  257. * Function: ql_bt_ble_get_localname
  258. *
  259. * Description:
  260. * 从NVM获取BT/BLE名称
  261. *
  262. * Parameters:
  263. * local_name [out] BT名称
  264. *
  265. * Return:ql_errcode_bt_e
  266. *
  267. *****************************************************************/
  268. ql_errcode_bt_e ql_bt_ble_get_localname(ql_bt_ble_local_name_s *local_name);
  269. /*****************************************************************
  270. * Function: ql_bt_ble_set_localname
  271. *
  272. * Description:
  273. * 设置BT/BLE名称到NVM,如果已经使能蓝牙,将BT/BLE名称设置到蓝牙协议栈中
  274. *
  275. * Parameters:
  276. * local_name [in] BT名称
  277. *
  278. * Return:ql_errcode_bt_e
  279. *
  280. *****************************************************************/
  281. ql_errcode_bt_e ql_bt_ble_set_localname(ql_bt_ble_local_name_s local_name);
  282. /*****************************************************************
  283. * Function: ql_bt_ble_get_nv_addr
  284. *
  285. * Description:
  286. * get bt/ble mac address from nv
  287. *
  288. * Parameters:
  289. * mac_addr [out] bt/ble mac addresss
  290. *
  291. * Return:ql_errcode_bt_e
  292. *
  293. *****************************************************************/
  294. ql_errcode_bt_e ql_bt_ble_get_nv_addr(ql_bt_addr_s * mac_addr);
  295. //以下API用于BLE
  296. /*****************************************************************
  297. * Function: ql_ble_get_version
  298. *
  299. * Description:
  300. * BLE 获取版本
  301. *
  302. * Parameters:
  303. * version [out] 版本数据
  304. * get_version_len [in] 读取版本的最大长度
  305. *
  306. * Return:ql_errcode_bt_e
  307. *
  308. *****************************************************************/
  309. ql_errcode_bt_e ql_ble_get_version(char *version, unsigned int get_version_len);
  310. /*****************************************************************
  311. * Function: ql_ble_get_public_addr
  312. *
  313. * Description:
  314. * 获取BLE公共地址(与BT mac地址一致)
  315. *
  316. * Parameters:
  317. * public_addr [out] 公共地址
  318. *
  319. * Return:ql_errcode_bt_e
  320. *
  321. *****************************************************************/
  322. ql_errcode_bt_e ql_ble_get_public_addr(ql_bt_addr_s * public_addr);
  323. /*****************************************************************
  324. * Function: ql_ble_get_random_addr
  325. *
  326. * Description:
  327. * 获取BLE随机地址
  328. *
  329. * Parameters:
  330. * random_addr [out] 随机地址
  331. *
  332. * Return:ql_errcode_bt_e
  333. *
  334. *****************************************************************/
  335. ql_errcode_bt_e ql_ble_get_random_addr(ql_bt_addr_s *random_addr);
  336. /*****************************************************************
  337. * Function: ql_ble_add_public_whitelist
  338. *
  339. * Description:
  340. * 增加一条白名单
  341. *
  342. * Parameters:
  343. * public_addr [in] 公共地址
  344. *
  345. * Return:ql_errcode_bt_e
  346. *
  347. *****************************************************************/
  348. ql_errcode_bt_e ql_ble_add_public_whitelist(ql_bt_addr_s public_addr);
  349. /*****************************************************************
  350. * Function: ql_ble_add_random_whitelist
  351. *
  352. * Description:
  353. * 增加一条白名单
  354. *
  355. * Parameters:
  356. * random_addr [in] 随机地址
  357. *
  358. * Return:ql_errcode_bt_e
  359. *
  360. *****************************************************************/
  361. ql_errcode_bt_e ql_ble_add_random_whitelist(ql_bt_addr_s random_addr);
  362. /*****************************************************************
  363. * Function: ql_ble_get_whitelist_info
  364. *
  365. * Description:
  366. * 获取白名单信息,白名单最多只有30个
  367. *
  368. * Parameters:
  369. * whitelist_count [in] 期望获得白名单个数
  370. * real_whitelist_count [in] 实际获得白名单个数
  371. * whitelist [in] 白名单信息
  372. *
  373. * Return:ql_errcode_bt_e
  374. *
  375. *****************************************************************/
  376. ql_errcode_bt_e ql_ble_get_whitelist_info(unsigned char whitelist_count,unsigned char *real_whitelist_count,ql_ble_whitelist_info_s whitelist[]);
  377. /*****************************************************************
  378. * Function: ql_ble_remove_whitelist
  379. *
  380. * Description:
  381. * 删除一条白名单
  382. *
  383. * Parameters:
  384. * whitelist [in] 白名单信息
  385. *
  386. * Return:ql_errcode_bt_e
  387. *
  388. *****************************************************************/
  389. ql_errcode_bt_e ql_ble_remove_whitelist(ql_ble_whitelist_info_s whitelist);
  390. /*****************************************************************
  391. * Function: ql_ble_clean_whitelist
  392. *
  393. * Description:
  394. * 删除所有的白名单
  395. *
  396. * Parameters:
  397. *
  398. * Return:ql_errcode_bt_e
  399. *
  400. *****************************************************************/
  401. ql_errcode_bt_e ql_ble_clean_whitelist();
  402. /*****************************************************************
  403. * Function: ql_ble_conncet_public_addr
  404. *
  405. * Description:
  406. * 建立连接
  407. *
  408. * Parameters:
  409. * public_addr [in] 公共地址
  410. *
  411. * Return:ql_errcode_bt_e
  412. *
  413. *****************************************************************/
  414. ql_errcode_bt_e ql_ble_conncet_public_addr(ql_bt_addr_s public_addr);
  415. /*****************************************************************
  416. * Function: ql_ble_conncet_random_addr
  417. *
  418. * Description:
  419. * 建立连接
  420. *
  421. * Parameters:
  422. * random_addr [in] 随机地址
  423. *
  424. * Return:ql_errcode_bt_e
  425. *
  426. *****************************************************************/
  427. ql_errcode_bt_e ql_ble_conncet_random_addr(ql_bt_addr_s random_addr);
  428. /*****************************************************************
  429. * Function: ql_ble_cancel_connect
  430. *
  431. * Description:
  432. * 取消正在建立的连接
  433. *
  434. * Parameters:
  435. * addr [in] 建立连接时使用的地址
  436. *
  437. * Return:ql_errcode_bt_e
  438. *
  439. *****************************************************************/
  440. ql_errcode_bt_e ql_ble_cancel_connect(ql_bt_addr_s addr);
  441. /*****************************************************************
  442. * Function: ql_ble_cancel_connect
  443. *
  444. * Description:
  445. * 断开已建立的连接
  446. *
  447. * Parameters:
  448. * conn_id [in] 连接ID,建立连接时得到的连接ID
  449. *
  450. * Return:ql_errcode_bt_e
  451. *
  452. *****************************************************************/
  453. ql_errcode_bt_e ql_ble_disconnect(unsigned short conn_id);
  454. /*****************************************************************
  455. * Function: ql_ble_get_connection_state
  456. *
  457. * Description:
  458. * 获取指定地址的连接状态
  459. *
  460. * Parameters:
  461. * addr [in] BLE地址
  462. * state [out] BLE地址
  463. * Return:ql_errcode_bt_e
  464. *
  465. *****************************************************************/
  466. ql_errcode_bt_e ql_ble_get_connection_state(ql_bt_addr_s addr, ql_bt_ble_connection_state_e *state);
  467. /*****************************************************************
  468. * Function: ql_ble_update_conn_param
  469. *
  470. * Description:
  471. * 更新连接参数
  472. *
  473. * Parameters:
  474. * conn_param [in] 连接参数
  475. *
  476. * Return:ql_errcode_bt_e
  477. *
  478. *****************************************************************/
  479. ql_errcode_bt_e ql_ble_update_conn_param(ql_ble_update_conn_infos_s conn_param);
  480. /*****************************************************************
  481. * Function: ql_ble_update_conn_param
  482. *
  483. * Description:
  484. * 请求交互MTU,主机和从机都是取最小的MTU,最大为247
  485. *
  486. * Parameters:
  487. * conn_id [in] 连接ID,建立连接时得到的连接ID
  488. * mtu [in] MTU
  489. *
  490. * Return:ql_errcode_bt_e
  491. *
  492. *****************************************************************/
  493. ql_errcode_bt_e ql_ble_exchange_mtu(unsigned short conn_id, unsigned short mtu);
  494. //以下为BLE广播的API
  495. /*****************************************************************
  496. * Function: ql_bleadv_set_typical_addr_param
  497. *
  498. * Description:
  499. * 设置定向广播参数
  500. *
  501. * Parameters:
  502. * adv_param [in] 定向广播参数
  503. *
  504. * Return:ql_errcode_bt_e
  505. *
  506. *****************************************************************/
  507. ql_errcode_bt_e ql_bleadv_set_typical_addr_param(ql_bleadv_typical_addr_param_s adv_param);
  508. /*****************************************************************
  509. * Function: ql_bleadv_get_typical_addr_param
  510. *
  511. * Description:
  512. * 获取定向广播参数
  513. *
  514. * Parameters:
  515. * adv_param [out] 定向广播参数
  516. *
  517. * Return:ql_errcode_bt_e
  518. *
  519. *****************************************************************/
  520. ql_errcode_bt_e ql_bleadv_get_typical_addr_param(ql_bleadv_typical_addr_param_s *adv_param);
  521. /*****************************************************************
  522. * Function: ql_bleadv_set_param
  523. *
  524. * Description:
  525. * 设置广播参数
  526. *
  527. * Parameters:
  528. * adv_param [in] 广播参数
  529. *
  530. * Return:ql_errcode_bt_e
  531. *
  532. *****************************************************************/
  533. ql_errcode_bt_e ql_bleadv_set_param(ql_bleadv_param_s adv_param);
  534. /*****************************************************************
  535. * Function: ql_bleadv_get_param
  536. *
  537. * Description:
  538. * 获取广播参数
  539. *
  540. * Parameters:
  541. * adv_param [out] 广播参数
  542. *
  543. * Return:ql_errcode_bt_e
  544. *
  545. *****************************************************************/
  546. ql_errcode_bt_e ql_bleadv_get_param(ql_bleadv_param_s *adv_param);
  547. /*****************************************************************
  548. * Function: ql_bleadv_set_data
  549. *
  550. * Description:
  551. * 设置广播数据,广播数据最长不超过31个字节
  552. *
  553. * Parameters:
  554. * avd_data [in] 广播数据
  555. *
  556. * Return:ql_errcode_bt_e
  557. *
  558. *****************************************************************/
  559. ql_errcode_bt_e ql_bleadv_set_data(ql_bleadv_set_data_s avd_data);
  560. /*****************************************************************
  561. * Function: ql_bleadv_set_data
  562. *
  563. * Description:
  564. * 设置扩展广播数据,广播数据最长不超过255个字节
  565. *
  566. * Parameters:
  567. * avd_data [in] 广播数据
  568. *
  569. * Return:ql_errcode_bt_e
  570. *
  571. *****************************************************************/
  572. ql_errcode_bt_e ql_ble_expadv_set_data(ql_ble_expadv_set_data_s *adv_data);
  573. /*****************************************************************
  574. * Function: ql_bleadv_set_scan_rsp_data
  575. *
  576. * Description:
  577. * 设置扫描回复数据,扫描回复数据最长不超过31个字节
  578. *
  579. * Parameters:
  580. * avd_data [in] 扫描回复数据,格式与广播数据一样,实际上也是广播出去的
  581. *
  582. * Return:ql_errcode_bt_e
  583. *
  584. *****************************************************************/
  585. ql_errcode_bt_e ql_bleadv_set_scan_rsp_data(ql_bleadv_set_data_s adv_data);
  586. /*****************************************************************
  587. * Function: ql_ble_set_ibeacon_data
  588. *
  589. * Description:
  590. * 设置ibeacon数据
  591. *
  592. * Parameters:
  593. * uuid_l [in] 16字节的长UUID
  594. * major [in] 主要部分
  595. * minor [in] 次要部分
  596. *
  597. * Return:ql_errcode_bt_e
  598. *
  599. *****************************************************************/
  600. ql_errcode_bt_e ql_ble_set_ibeacon_data(unsigned char uuid_l[QL_BLE_LONG_UUID_SIZE], unsigned short major, unsigned short minor);
  601. /*****************************************************************
  602. * Function: ql_ble_write_ibeacon_cfg
  603. *
  604. * Description:
  605. * 设置ibeacon数据到NVM中
  606. *
  607. * Parameters:
  608. * info [in] ibeacon数据
  609. *
  610. * Return:ql_errcode_bt_e
  611. *
  612. *****************************************************************/
  613. ql_errcode_bt_e ql_ble_write_ibeacon_cfg(ql_ble_ibeacon_cfg_s info);
  614. /*****************************************************************
  615. * Function: ql_ble_read_ibeacon_cfg
  616. *
  617. * Description:
  618. * 将ibeacon数据从NVM读取出来
  619. *
  620. * Parameters:
  621. * info [out] ibeacon数据
  622. *
  623. * Return:ql_errcode_bt_e
  624. *
  625. *****************************************************************/
  626. ql_errcode_bt_e ql_ble_read_ibeacon_cfg(ql_ble_ibeacon_cfg_s *info);
  627. /*****************************************************************
  628. * Function: ql_bleadv_start
  629. *
  630. * Description:
  631. * 开启广播
  632. *
  633. * Parameters:
  634. *
  635. * Return:ql_errcode_bt_e
  636. *
  637. *****************************************************************/
  638. ql_errcode_bt_e ql_bleadv_start();
  639. /*****************************************************************
  640. * Function: ql_bleadv_stop
  641. *
  642. * Description:
  643. * 停止广播
  644. *
  645. * Parameters:
  646. *
  647. * Return:ql_errcode_bt_e
  648. *
  649. *****************************************************************/
  650. ql_errcode_bt_e ql_bleadv_stop();
  651. /*****************************************************************
  652. * Function: ql_bleadv_get_state
  653. *
  654. * Description:
  655. * 获取广播状态
  656. *
  657. * Parameters:
  658. * adv_state [out] 广播状态
  659. *
  660. * Return:ql_errcode_bt_e
  661. *
  662. *****************************************************************/
  663. ql_errcode_bt_e ql_bleadv_get_state(ql_ble_adv_state_e *adv_state);
  664. //以下为BLE扫描使用API
  665. /*****************************************************************
  666. * Function: ql_ble_gatt_client_init
  667. *
  668. * Description:
  669. * 设置扫描参数
  670. *
  671. * Parameters:
  672. * scan_param [in] 扫描参数
  673. *
  674. * Return:ql_errcode_bt_e
  675. *
  676. *****************************************************************/
  677. ql_errcode_bt_e ql_blescan_set_param(ql_blescan_scan_s scan_param);
  678. /*****************************************************************
  679. * Function: ql_ble_gatt_client_init
  680. *
  681. * Description:
  682. * 获取扫描参数
  683. *
  684. * Parameters:
  685. * scan_param [out] 扫描参数
  686. *
  687. * Return:ql_errcode_bt_e
  688. *
  689. *****************************************************************/
  690. ql_errcode_bt_e ql_blescan_get_param(ql_blescan_scan_s *scan_param);
  691. /*****************************************************************
  692. * Function: ql_blescan_start
  693. *
  694. * Description:
  695. * 开启扫描
  696. *
  697. * Parameters:
  698. *
  699. * Return:ql_errcode_bt_e
  700. *
  701. *****************************************************************/
  702. ql_errcode_bt_e ql_blescan_start();
  703. /*****************************************************************
  704. * Function: ql_blescan_stop
  705. *
  706. * Description:
  707. * 停止扫描
  708. *
  709. * Parameters:
  710. *
  711. * Return:ql_errcode_bt_e
  712. *
  713. *****************************************************************/
  714. ql_errcode_bt_e ql_blescan_stop();
  715. /*****************************************************************
  716. * Function: ql_blescan_stop
  717. *
  718. * Description:
  719. * 获取扫描状态
  720. *
  721. * Parameters:
  722. * scan_state [out] 扫描状态
  723. *
  724. * Return:ql_errcode_bt_e
  725. *
  726. *****************************************************************/
  727. ql_errcode_bt_e ql_blescan_get_state(ql_ble_scan_state_e *scan_state);
  728. /*****************************************************************
  729. * Function: ql_bt_rssi_filter_set
  730. *
  731. * Description:
  732. * 设置RSSI,过滤高于此设置值的设备
  733. * Parameters:
  734. * rssi_value [in] RSSI value 0~255 0:不过滤
  735. *
  736. * Return:ql_errcode_bt_e
  737. ******************************************************************/
  738. ql_errcode_bt_e ql_bt_rssi_filter_set(UINT8 rssi_value);
  739. /*****************************************************************
  740. * Function: ql_bt_rssi_filter_get
  741. *
  742. * Description:
  743. * 查询设置的RSSI
  744. * Parameters:
  745. * rssi_value [in] RSSI value
  746. *
  747. * Return:ql_errcode_bt_e
  748. ******************************************************************/
  749. ql_errcode_bt_e ql_bt_rssi_filter_get(UINT8 * rssi_value);
  750. /*****************************************************************
  751. * Function: ql_bt_name_filter_set
  752. *
  753. * Description:
  754. * 设置字符串,过滤名字相同或者包含此字符串的设备
  755. * Parameters:
  756. * filter_type [in] filter type 0~2 0:不过滤 1:设备名和ble_keyword完全相同上报 2:ble_keyword是设备名的子集上报
  757. * ble_keyword [in] ble_keyword 字符串首地址 ,长度不超过32个字符
  758. * Return:ql_errcode_bt_e
  759. ******************************************************************/
  760. ql_errcode_bt_e ql_bt_name_filter_set(ql_bt_namefilter_type_e filter_type, unsigned char * ble_keyword);
  761. /*****************************************************************
  762. * Function: ql_bt_name_filter_get
  763. *
  764. * Description:
  765. * 查询设置的名称
  766. * Parameters:
  767. * filter_type [in] filter type 读取filter type
  768. * ble_keyword [in] ble_keyword 当filter type 为 1,2时,传入指针读取当前配置值,指针size要大于32,底层会把配置值memcpy到传入的指针里
  769. *
  770. * Return:ql_errcode_bt_e
  771. ******************************************************************/
  772. ql_errcode_bt_e ql_bt_name_filter_get(ql_bt_namefilter_type_e * filter_type, unsigned char * ble_keyword);
  773. /*****************************************************************
  774. * Function: ql_bt_same_dev_filter_set
  775. *
  776. * Description:
  777. * 设置是否重复上报已经扫描上报过的设备信息
  778. * Parameters:
  779. * same_dev_filter_switch [in] 0: 不重复上报 ; 1: 重复上报
  780. *
  781. * Return:ql_errcode_bt_e
  782. ******************************************************************/
  783. ql_errcode_bt_e ql_bt_same_dev_filter_set(ql_bt_same_dev_filter_switch_e same_dev_filter_switch);
  784. /*****************************************************************
  785. * Function: ql_bt_same_dev_filter_get
  786. *
  787. * Description:
  788. * 获取当前设置的是否重复上报状态
  789. * Parameters:
  790. * same_dev_filter_switch [in] 0: 不重复上报 ; 1: 重复上报
  791. *
  792. * Return:ql_errcode_bt_e
  793. ******************************************************************/
  794. ql_errcode_bt_e ql_bt_same_dev_filter_get(ql_bt_same_dev_filter_switch_e * same_dev_filter_switch);
  795. #ifdef __cplusplus
  796. } /*"C" */
  797. #endif
  798. #endif /* QL_API_BT_H */