bt_hf_client.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. /*
  2. * Copyright (C) 2012-2014 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef ANDROID_INCLUDE_BT_HF_CLIENT_H
  17. #define ANDROID_INCLUDE_BT_HF_CLIENT_H
  18. __BEGIN_DECLS
  19. typedef enum {
  20. BTHF_CLIENT_CONNECTION_STATE_DISCONNECTED = 0,
  21. BTHF_CLIENT_CONNECTION_STATE_CONNECTING,
  22. BTHF_CLIENT_CONNECTION_STATE_CONNECTED,
  23. BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED,
  24. BTHF_CLIENT_CONNECTION_STATE_DISCONNECTING
  25. } bthf_client_connection_state_t;
  26. typedef enum {
  27. BTHF_CLIENT_AUDIO_STATE_DISCONNECTED = 0,
  28. BTHF_CLIENT_AUDIO_STATE_CONNECTING,
  29. BTHF_CLIENT_AUDIO_STATE_CONNECTED,
  30. BTHF_CLIENT_AUDIO_STATE_CONNECTED_MSBC,
  31. } bthf_client_audio_state_t;
  32. typedef enum {
  33. BTHF_CLIENT_VR_STATE_STOPPED = 0,
  34. BTHF_CLIENT_VR_STATE_STARTED
  35. } bthf_client_vr_state_t;
  36. typedef enum {
  37. BTHF_CLIENT_VOLUME_TYPE_SPK = 0,
  38. BTHF_CLIENT_VOLUME_TYPE_MIC
  39. } bthf_client_volume_type_t;
  40. typedef enum {
  41. BTHF_CLIENT_NETWORK_STATE_NOT_AVAILABLE = 0,
  42. BTHF_CLIENT_NETWORK_STATE_AVAILABLE
  43. } bthf_client_network_state_t;
  44. typedef enum {
  45. BTHF_CLIENT_SERVICE_TYPE_HOME = 0,
  46. BTHF_CLIENT_SERVICE_TYPE_ROAMING
  47. } bthf_client_service_type_t;
  48. typedef enum {
  49. BTHF_CLIENT_CALL_STATE_ACTIVE = 0,
  50. BTHF_CLIENT_CALL_STATE_HELD,
  51. BTHF_CLIENT_CALL_STATE_DIALING,
  52. BTHF_CLIENT_CALL_STATE_ALERTING,
  53. BTHF_CLIENT_CALL_STATE_INCOMING,
  54. BTHF_CLIENT_CALL_STATE_WAITING,
  55. BTHF_CLIENT_CALL_STATE_HELD_BY_RESP_HOLD,
  56. } bthf_client_call_state_t;
  57. typedef enum {
  58. BTHF_CLIENT_CALL_NO_CALLS_IN_PROGRESS = 0,
  59. BTHF_CLIENT_CALL_CALLS_IN_PROGRESS
  60. } bthf_client_call_t;
  61. typedef enum {
  62. BTHF_CLIENT_CALLSETUP_NONE = 0,
  63. BTHF_CLIENT_CALLSETUP_INCOMING,
  64. BTHF_CLIENT_CALLSETUP_OUTGOING,
  65. BTHF_CLIENT_CALLSETUP_ALERTING
  66. } bthf_client_callsetup_t;
  67. typedef enum {
  68. BTHF_CLIENT_CALLHELD_NONE = 0,
  69. BTHF_CLIENT_CALLHELD_HOLD_AND_ACTIVE,
  70. BTHF_CLIENT_CALLHELD_HOLD,
  71. } bthf_client_callheld_t;
  72. typedef enum {
  73. BTHF_CLIENT_RESP_AND_HOLD_HELD = 0,
  74. BTRH_CLIENT_RESP_AND_HOLD_ACCEPT,
  75. BTRH_CLIENT_RESP_AND_HOLD_REJECT,
  76. } bthf_client_resp_and_hold_t;
  77. typedef enum {
  78. BTHF_CLIENT_CALL_DIRECTION_OUTGOING = 0,
  79. BTHF_CLIENT_CALL_DIRECTION_INCOMING
  80. } bthf_client_call_direction_t;
  81. typedef enum {
  82. BTHF_CLIENT_CALL_MPTY_TYPE_SINGLE = 0,
  83. BTHF_CLIENT_CALL_MPTY_TYPE_MULTI
  84. } bthf_client_call_mpty_type_t;
  85. typedef enum {
  86. BTHF_CLIENT_CMD_COMPLETE_OK = 0,
  87. BTHF_CLIENT_CMD_COMPLETE_ERROR,
  88. BTHF_CLIENT_CMD_COMPLETE_ERROR_NO_CARRIER,
  89. BTHF_CLIENT_CMD_COMPLETE_ERROR_BUSY,
  90. BTHF_CLIENT_CMD_COMPLETE_ERROR_NO_ANSWER,
  91. BTHF_CLIENT_CMD_COMPLETE_ERROR_DELAYED,
  92. BTHF_CLIENT_CMD_COMPLETE_ERROR_BLACKLISTED,
  93. BTHF_CLIENT_CMD_COMPLETE_ERROR_CME
  94. } bthf_client_cmd_complete_t;
  95. typedef enum {
  96. BTHF_CLIENT_CALL_ACTION_CHLD_0 = 0,
  97. BTHF_CLIENT_CALL_ACTION_CHLD_1,
  98. BTHF_CLIENT_CALL_ACTION_CHLD_2,
  99. BTHF_CLIENT_CALL_ACTION_CHLD_3,
  100. BTHF_CLIENT_CALL_ACTION_CHLD_4,
  101. BTHF_CLIENT_CALL_ACTION_CHLD_1x,
  102. BTHF_CLIENT_CALL_ACTION_CHLD_2x,
  103. BTHF_CLIENT_CALL_ACTION_ATA,
  104. BTHF_CLIENT_CALL_ACTION_CHUP,
  105. BTHF_CLIENT_CALL_ACTION_BTRH_0,
  106. BTHF_CLIENT_CALL_ACTION_BTRH_1,
  107. BTHF_CLIENT_CALL_ACTION_BTRH_2,
  108. } bthf_client_call_action_t;
  109. typedef enum {
  110. BTHF_CLIENT_SERVICE_UNKNOWN = 0,
  111. BTHF_CLIENT_SERVICE_VOICE,
  112. BTHF_CLIENT_SERVICE_FAX
  113. } bthf_client_subscriber_service_type_t;
  114. typedef enum {
  115. BTHF_CLIENT_IN_BAND_RINGTONE_NOT_PROVIDED = 0,
  116. BTHF_CLIENT_IN_BAND_RINGTONE_PROVIDED,
  117. } bthf_client_in_band_ring_state_t;
  118. /* Peer features masks */
  119. #define BTHF_CLIENT_PEER_FEAT_3WAY 0x00000001 /* Three-way calling */
  120. #define BTHF_CLIENT_PEER_FEAT_ECNR \
  121. 0x00000002 /* Echo cancellation and/or noise reduction */
  122. #define BTHF_CLIENT_PEER_FEAT_VREC 0x00000004 /* Voice recognition */
  123. #define BTHF_CLIENT_PEER_FEAT_INBAND 0x00000008 /* In-band ring tone */
  124. #define BTHF_CLIENT_PEER_FEAT_VTAG \
  125. 0x00000010 /* Attach a phone number to a voice tag */
  126. #define BTHF_CLIENT_PEER_FEAT_REJECT \
  127. 0x00000020 /* Ability to reject incoming call */
  128. #define BTHF_CLIENT_PEER_FEAT_ECS 0x00000040 /* Enhanced Call Status */
  129. #define BTHF_CLIENT_PEER_FEAT_ECC 0x00000080 /* Enhanced Call Control */
  130. #define BTHF_CLIENT_PEER_FEAT_EXTERR 0x00000100 /* Extended error codes */
  131. #define BTHF_CLIENT_PEER_FEAT_CODEC 0x00000200 /* Codec Negotiation */
  132. /* Peer call handling features masks */
  133. #define BTHF_CLIENT_CHLD_FEAT_REL \
  134. 0x00000001 /* 0 Release waiting call or held calls */
  135. #define BTHF_CLIENT_CHLD_FEAT_REL_ACC \
  136. 0x00000002 /* 1 Release active calls and accept other \
  137. (waiting or held) cal */
  138. #define BTHF_CLIENT_CHLD_FEAT_REL_X \
  139. 0x00000004 /* 1x Release specified active call only */
  140. #define BTHF_CLIENT_CHLD_FEAT_HOLD_ACC \
  141. 0x00000008 /* 2 Active calls on hold and accept other \
  142. (waiting or held) call */
  143. #define BTHF_CLIENT_CHLD_FEAT_PRIV_X \
  144. 0x00000010 /* 2x Request private mode with specified \
  145. call (put the rest on hold) */
  146. #define BTHF_CLIENT_CHLD_FEAT_MERGE \
  147. 0x00000020 /* 3 Add held call to multiparty */
  148. #define BTHF_CLIENT_CHLD_FEAT_MERGE_DETACH \
  149. 0x00000040 /* 4 Connect two calls and leave \
  150. (disconnect from) multiparty */
  151. /** Callback for connection state change.
  152. * state will have one of the values from BtHfConnectionState
  153. * peer/chld_features are valid only for
  154. * BTHF_CLIENT_CONNECTION_STATE_SLC_CONNECTED state
  155. */
  156. typedef void (*bthf_client_connection_state_callback)(
  157. const RawAddress* bd_addr, bthf_client_connection_state_t state,
  158. unsigned int peer_feat, unsigned int chld_feat);
  159. /** Callback for audio connection state change.
  160. * state will have one of the values from BtHfAudioState
  161. */
  162. typedef void (*bthf_client_audio_state_callback)(
  163. const RawAddress* bd_addr, bthf_client_audio_state_t state);
  164. /** Callback for VR connection state change.
  165. * state will have one of the values from BtHfVRState
  166. */
  167. typedef void (*bthf_client_vr_cmd_callback)(const RawAddress* bd_addr,
  168. bthf_client_vr_state_t state);
  169. /** Callback for network state change
  170. */
  171. typedef void (*bthf_client_network_state_callback)(
  172. const RawAddress* bd_addr, bthf_client_network_state_t state);
  173. /** Callback for network roaming status change
  174. */
  175. typedef void (*bthf_client_network_roaming_callback)(
  176. const RawAddress* bd_addr, bthf_client_service_type_t type);
  177. /** Callback for signal strength indication
  178. */
  179. typedef void (*bthf_client_network_signal_callback)(const RawAddress* bd_addr,
  180. int signal_strength);
  181. /** Callback for battery level indication
  182. */
  183. typedef void (*bthf_client_battery_level_callback)(const RawAddress* bd_addr,
  184. int battery_level);
  185. /** Callback for current operator name
  186. */
  187. typedef void (*bthf_client_current_operator_callback)(const RawAddress* bd_addr,
  188. const char* name);
  189. /** Callback for call indicator
  190. */
  191. typedef void (*bthf_client_call_callback)(const RawAddress* bd_addr,
  192. bthf_client_call_t call);
  193. /** Callback for callsetup indicator
  194. */
  195. typedef void (*bthf_client_callsetup_callback)(
  196. const RawAddress* bd_addr, bthf_client_callsetup_t callsetup);
  197. /** Callback for callheld indicator
  198. */
  199. typedef void (*bthf_client_callheld_callback)(const RawAddress* bd_addr,
  200. bthf_client_callheld_t callheld);
  201. /** Callback for response and hold
  202. */
  203. typedef void (*bthf_client_resp_and_hold_callback)(
  204. const RawAddress* bd_addr, bthf_client_resp_and_hold_t resp_and_hold);
  205. /** Callback for Calling Line Identification notification
  206. * Will be called only when there is an incoming call and number is provided.
  207. */
  208. typedef void (*bthf_client_clip_callback)(const RawAddress* bd_addr,
  209. const char* number);
  210. /**
  211. * Callback for Call Waiting notification
  212. */
  213. typedef void (*bthf_client_call_waiting_callback)(const RawAddress* bd_addr,
  214. const char* number);
  215. /**
  216. * Callback for listing current calls. Can be called multiple time.
  217. * If number is unknown NULL is passed.
  218. */
  219. typedef void (*bthf_client_current_calls)(const RawAddress* bd_addr, int index,
  220. bthf_client_call_direction_t dir,
  221. bthf_client_call_state_t state,
  222. bthf_client_call_mpty_type_t mpty,
  223. const char* number);
  224. /** Callback for audio volume change
  225. */
  226. typedef void (*bthf_client_volume_change_callback)(
  227. const RawAddress* bd_addr, bthf_client_volume_type_t type, int volume);
  228. /** Callback for command complete event
  229. * cme is valid only for BTHF_CLIENT_CMD_COMPLETE_ERROR_CME type
  230. */
  231. typedef void (*bthf_client_cmd_complete_callback)(
  232. const RawAddress* bd_addr, bthf_client_cmd_complete_t type, int cme);
  233. /** Callback for subscriber information
  234. */
  235. typedef void (*bthf_client_subscriber_info_callback)(
  236. const RawAddress* bd_addr, const char* name,
  237. bthf_client_subscriber_service_type_t type);
  238. /** Callback for in-band ring tone settings
  239. */
  240. typedef void (*bthf_client_in_band_ring_tone_callback)(
  241. const RawAddress* bd_addr, bthf_client_in_band_ring_state_t state);
  242. /**
  243. * Callback for requested number from AG
  244. */
  245. typedef void (*bthf_client_last_voice_tag_number_callback)(
  246. const RawAddress* bd_addr, const char* number);
  247. /**
  248. * Callback for sending ring indication to app
  249. */
  250. typedef void (*bthf_client_ring_indication_callback)(const RawAddress* bd_addr);
  251. /** BT-HF callback structure. */
  252. typedef struct {
  253. /** set to sizeof(BtHfClientCallbacks) */
  254. size_t size;
  255. bthf_client_connection_state_callback connection_state_cb;
  256. bthf_client_audio_state_callback audio_state_cb;
  257. bthf_client_vr_cmd_callback vr_cmd_cb;
  258. bthf_client_network_state_callback network_state_cb;
  259. bthf_client_network_roaming_callback network_roaming_cb;
  260. bthf_client_network_signal_callback network_signal_cb;
  261. bthf_client_battery_level_callback battery_level_cb;
  262. bthf_client_current_operator_callback current_operator_cb;
  263. bthf_client_call_callback call_cb;
  264. bthf_client_callsetup_callback callsetup_cb;
  265. bthf_client_callheld_callback callheld_cb;
  266. bthf_client_resp_and_hold_callback resp_and_hold_cb;
  267. bthf_client_clip_callback clip_cb;
  268. bthf_client_call_waiting_callback call_waiting_cb;
  269. bthf_client_current_calls current_calls_cb;
  270. bthf_client_volume_change_callback volume_change_cb;
  271. bthf_client_cmd_complete_callback cmd_complete_cb;
  272. bthf_client_subscriber_info_callback subscriber_info_cb;
  273. bthf_client_in_band_ring_tone_callback in_band_ring_tone_cb;
  274. bthf_client_last_voice_tag_number_callback last_voice_tag_number_callback;
  275. bthf_client_ring_indication_callback ring_indication_cb;
  276. } bthf_client_callbacks_t;
  277. /** Represents the standard BT-HF interface. */
  278. typedef struct {
  279. /** set to sizeof(BtHfClientInterface) */
  280. size_t size;
  281. /**
  282. * Register the BtHf callbacks
  283. */
  284. bt_status_t (*init)(bthf_client_callbacks_t* callbacks);
  285. /** connect to audio gateway */
  286. bt_status_t (*connect)(RawAddress* bd_addr);
  287. /** disconnect from audio gateway */
  288. bt_status_t (*disconnect)(const RawAddress* bd_addr);
  289. /** create an audio connection */
  290. bt_status_t (*connect_audio)(const RawAddress* bd_addr);
  291. /** close the audio connection */
  292. bt_status_t (*disconnect_audio)(const RawAddress* bd_addr);
  293. /** start voice recognition */
  294. bt_status_t (*start_voice_recognition)(const RawAddress* bd_addr);
  295. /** stop voice recognition */
  296. bt_status_t (*stop_voice_recognition)(const RawAddress* bd_addr);
  297. /** volume control */
  298. bt_status_t (*volume_control)(const RawAddress* bd_addr,
  299. bthf_client_volume_type_t type, int volume);
  300. /** place a call with number a number
  301. * if number is NULL last called number is called (aka re-dial)*/
  302. bt_status_t (*dial)(const RawAddress* bd_addr, const char* number);
  303. /** place a call with number specified by location (speed dial) */
  304. bt_status_t (*dial_memory)(const RawAddress* bd_addr, int location);
  305. /** perform specified call related action
  306. * idx is limited only for enhanced call control related action
  307. */
  308. bt_status_t (*handle_call_action)(const RawAddress* bd_addr,
  309. bthf_client_call_action_t action, int idx);
  310. /** query list of current calls */
  311. bt_status_t (*query_current_calls)(const RawAddress* bd_addr);
  312. /** query name of current selected operator */
  313. bt_status_t (*query_current_operator_name)(const RawAddress* bd_addr);
  314. /** Retrieve subscriber information */
  315. bt_status_t (*retrieve_subscriber_info)(const RawAddress* bd_addr);
  316. /** Send DTMF code*/
  317. bt_status_t (*send_dtmf)(const RawAddress* bd_addr, char code);
  318. /** Request a phone number from AG corresponding to last voice tag recorded */
  319. bt_status_t (*request_last_voice_tag_number)(const RawAddress* bd_addr);
  320. /** Closes the interface. */
  321. void (*cleanup)(void);
  322. /** Send AT Command. */
  323. bt_status_t (*send_at_cmd)(const RawAddress* bd_addr, int cmd, int val1,
  324. int val2, const char* arg);
  325. } bthf_client_interface_t;
  326. __END_DECLS
  327. #endif /* ANDROID_INCLUDE_BT_HF_CLIENT_H */