ql_api_bt_common.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. /** @file
  2. ql_api_bt_commom.h
  3. @brief
  4. This file is used to define bt api commom for different Quectel Project.
  5. ql_api_bt.h can use this common define.
  6. */
  7. /*================================================================
  8. Copyright (c) 2020 Quectel Wireless Solution, Co., Ltd. All Rights Reserved.
  9. Quectel Wireless Solution Proprietary and Confidential.
  10. =================================================================*/
  11. /*=================================================================
  12. EDIT HISTORY FOR MODULE
  13. This section contains comments describing changes made to the module.
  14. Notice that changes are listed in reverse chronological order.
  15. WHEN WHO WHAT, WHERE, WHY
  16. ------------ ------- -------------------------------------------------------------------------------
  17. =================================================================*/
  18. #ifndef QL_API_BT_COMMON_H
  19. #define QL_API_BT_COMMON_H
  20. #include "ql_api_common.h"
  21. /*========================================================================
  22. * Variable Definition
  23. *========================================================================*/
  24. typedef enum
  25. {
  26. QL_BT_SUCCESS = 0,
  27. //
  28. QL_BT_ERROR = 1 | (QL_COMPONENT_BSP_BT << 16),
  29. QL_BT_PENDING,
  30. QL_BT_BUSY_ERR,
  31. QL_BT_NO_RESOURCE_ERR,
  32. QL_BT_NOT_FOUND_ERR,
  33. QL_BT_DEVICE_NOT_FOUND_ERR,
  34. QL_BT_CONNECTION_FAILED_ERR,
  35. QL_BT_TIMEOUT_ERR,
  36. QL_BT_NO_CONNECTION_ERR,
  37. QL_BT_INVALID_PARM_ERR,
  38. QL_BT_NOT_SUPPORTED_ERR,
  39. QL_BT_CANCELLED_ERR,
  40. QL_BT_IN_PROGRESS_ERR,
  41. QL_BT_RESTRICTED_ERR,
  42. QL_BT_INVALID_HANDLE_ERR,
  43. QL_BT_PACKET_TOO_SMALL_ERR,
  44. QL_BT_NO_PAIR_ERR,
  45. QL_BT_FAILED_ERR,
  46. QL_BT_DISCONNECT_ERR,
  47. QL_BT_NO_CONNECT_ERR,
  48. QL_BT_IN_USE_ERR,
  49. QL_BT_MEDIA_BUSY_ERR,
  50. QL_BT_OFF_ERR,
  51. //蓝牙协议栈返回的错误
  52. QL_BT_SYS_FAIL_ERR, //操作失败
  53. QL_BT_SYS_DONE_ERR, //处于完成状态
  54. QL_BT_SYS_PENDING_ERR, //处于等待状态
  55. QL_BT_SYS_INVALID_PARAM_ERR, //输入的参数无效
  56. QL_BT_SYS_ISECFAIL_ERR, //安全连接失败
  57. QL_BT_SYS_FLOWCTRL_ERR, //处于流控状态
  58. QL_BT_SYS_NORESOURCES_ERR, //资源不足
  59. QL_BT_SYS_UNSUPPORTED_ERR, //设备或能力不支持
  60. QL_BT_SYS_HW_ERR, //蓝牙硬件错误
  61. QL_BT_SYS_HOST_ERR, //蓝牙主机错误
  62. QL_BT_SYS_UNKOWN_ERR, //蓝牙未知错误
  63. QL_BT_SYS_NOT_READY_ERR, //处于未就绪状态
  64. QL_BT_SYS_READY_ERR, //处于就绪状态
  65. QL_BT_SYS_AUTHORISE_FAIL_ERR, //授权失败
  66. QL_BT_SYS_AUTHEN_FAIL_ERR, //认证失败
  67. QL_BT_SYS_ENCRYPT_FAIL_ERR, //加密失败
  68. QL_BT_SYS_TIMEOUT_ERR, //操作超时
  69. QL_BT_SYS_PROTOCOL_ERR, //协议错误
  70. QL_BT_SYS_DISALLOWED_ERR, //操作不允许
  71. QL_BT_SYS_BUFF_SAMLL_ERR, //蓝牙协议栈buffer太小
  72. QL_BT_SYS_DISCONNECT_ERR, //处于未连接
  73. QL_BT_SYS_MORE_ERR, //更多错误
  74. QL_BT_REGISTER_MSG_ERR,
  75. QL_BT_DISCONNECT,
  76. QL_BT_ALREADY_CONNECTED_ERR, //已经建立了连接
  77. QL_BT_ALREADY_STARTED_ERR,
  78. QL_BT_ALREADY_STOPED_ERR,
  79. QL_BT_NOT_START_ERR,
  80. QL_BT_NOT_STOP_ERR,
  81. QL_BT_PRAMA_TYPE_ERR,
  82. QL_BT_PRAMA_LENGTH_ERR,
  83. QL_BT_PRAMA_DATA_ERR, //BT/BLE input parameter error
  84. QL_BT_PRAMA_SIZE_ERR,
  85. QL_BT_PRAMA_NULL_ERR,
  86. QL_BT_NOT_INQURY_ERR,
  87. QL_BT_SPP_NOT_CONNECT_ERR,
  88. QL_BT_SPP_NOT_SUPPORT_ERR,
  89. QL_BT_GET_PAIR_INFO_ERR,
  90. QL_BT_REMVOE_PAIR_INFO_ERR,
  91. QL_BT_GET_WHITELIST_ERR,
  92. QL_BT_MEM_ADDR_NULL_ERR,
  93. QL_BT_GET_FILE_ADDR_ERR,
  94. QL_BT_WIFI_USING_ERR,
  95. QL_BT_NOT_INIT_ERR,
  96. QL_BT_NOT_REGISTER_CB_ERR,
  97. QL_BT_TASK_NOT_EXIT_ERR,
  98. QL_BT_IS_USING_ERR,
  99. QL_BT_ALREADY_REGISTERED_ERR,
  100. QL_BT_SERVICE_ALREADY_EXITED_ERR,
  101. QL_BT_SERVICE_NOT_EXITED_ERR,
  102. QL_BT_SERVICE_NOT_CLEAN_ERR, //服务没有清除,service not clean
  103. QL_BT_CHARA_ALREADY_EXITED_ERR,
  104. QL_BT_CHARA_NOT_EXITED_ERR,
  105. QL_BT_NOT_CONN_ID_ERR,
  106. QL_BLE_PUBLIC_ADDR_NOT_USED_ERR, //cannot use ble public address
  107. QL_BLE_CID_ERR, //没有对应cid的通道
  108. QL_BLE_HANDLE_ERR, //使用了错误的句柄
  109. QL_BLE_PROP_ERR, //属性错误
  110. QL_BLE_WRITE_NAME_FILE_ERR, //写蓝牙名称文件错误
  111. QL_BLE_READ_NAME_FILE_ERR, //读蓝牙名称文件错误
  112. QL_BLE_READ_ADDR_FILE_ERR, //read mac address file err
  113. QL_BTE_IN_UPGRAD_MOAE_ERR, //蓝牙正在升级错误
  114. //bt filter error
  115. QL_BT_FILTER_PARAM_ERR = 500 | (QL_COMPONENT_BSP_BT << 16), //bt filter:param error
  116. }ql_errcode_bt_e;
  117. #define QL_BT_MAC_ADDRESS_SIZE 6
  118. #define QL_BLE_ADV_SCAN_DATA_SIZE 31 //BLE advertise and scan data max length
  119. #define QL_BLE_EXP_ADV_SCAN_DATA_SIZE 255 //BLE expand advertise and scan data max length
  120. //bt/ble address
  121. typedef struct
  122. {
  123. unsigned char addr[QL_BT_MAC_ADDRESS_SIZE];
  124. } ql_bt_addr_s;
  125. //connection parameter
  126. typedef struct
  127. {
  128. unsigned short conn_id; //connection id
  129. unsigned short max_interval; //最大的间隔,间隔:1.25ms,取值范围:6-3200,时间范围:7.5ms~4s
  130. unsigned short min_interval; //最小的间隔,间隔:1.25ms,取值范围:6-3200,时间范围:7.5ms~4s
  131. unsigned short latency; //从机忽略连接状态事件的时间。需满足:(1+latecy)*max_interval*2*1.25<timeout*10
  132. unsigned short timeout; //没有交互,超时断开时间,间隔:10ms,取值范围:10-3200,时间范围:100ms~32s
  133. }ql_ble_update_conn_infos_s;
  134. //ble gatt uiid information
  135. #define QL_BLE_LONG_UUID_SIZE 16
  136. typedef enum
  137. {
  138. QL_BLE_GATT_LONG_UUID = 0, //长UUID:128bit
  139. QL_BLE_GATT_SHORT_UUID, //短UUID:16bit
  140. }ql_ble_gatt_uuid_state_e;
  141. typedef struct
  142. {
  143. ql_ble_gatt_uuid_state_e uuid_type;
  144. unsigned char uuid_l[QL_BLE_LONG_UUID_SIZE];
  145. unsigned short uuid_s;
  146. }ql_ble_gatt_uuid_s;
  147. #define QL_BT_BLE_NAME_MAX_SIZE 22 //now is 22,will be 29 in future
  148. typedef enum
  149. {
  150. QL_BT_BLE_NAME_CODE_UTF8 = 0, //code utf8
  151. QL_BT_BLE_NAME_CODE_GBK , //code GBK
  152. }ql_bt_ble_name_code_type_e;
  153. //bt/ble local name
  154. typedef struct
  155. {
  156. unsigned char name[QL_BT_BLE_NAME_MAX_SIZE+1]; //蓝牙名称实际长度,最大长度为22.end with \0
  157. ql_bt_ble_name_code_type_e code_type;
  158. }ql_bt_ble_local_name_s;
  159. //BLE IBEACON信息
  160. typedef struct
  161. {
  162. unsigned char uuid_l[QL_BLE_LONG_UUID_SIZE];
  163. unsigned short major;
  164. unsigned short minor;
  165. }ql_ble_ibeacon_cfg_s;
  166. //bt/ble connection information
  167. typedef enum
  168. {
  169. QL_BT_BLE_CONN_DISCONNECTED = 0, //ble is disconnected
  170. QL_BT_BLE_CONN_CONNECTED, //ble is connected
  171. }ql_bt_ble_connection_state_e;
  172. typedef struct
  173. {
  174. unsigned short conn_id;
  175. ql_bt_ble_connection_state_e conn_state;
  176. ql_bt_addr_s addr;
  177. }ql_bt_ble_connection_info_s;
  178. typedef struct
  179. {
  180. ql_bt_addr_s addr;
  181. unsigned char rssi;
  182. unsigned char device_name[QL_BT_BLE_NAME_MAX_SIZE+1];
  183. unsigned int device_class;
  184. unsigned char status;
  185. }ql_bt_inquiry_info_s;
  186. typedef struct
  187. {
  188. ql_bt_addr_s addr;
  189. unsigned char device_name[QL_BT_BLE_NAME_MAX_SIZE+1];
  190. unsigned char name_len;
  191. unsigned int value;
  192. unsigned char state;
  193. }ql_bt_bond_info_s;
  194. /*========================================================================
  195. * function Definition
  196. *========================================================================*/
  197. #endif /* QL_API_BT_COMMON_H */