bta_ag_api.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605
  1. /******************************************************************************
  2. *
  3. * Copyright 2003-2012 Broadcom Corporation
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at:
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. ******************************************************************************/
  18. /******************************************************************************
  19. *
  20. * This is the public interface file for the audio gateway (AG) subsystem
  21. * of BTA, Broadcom's Bluetooth application layer for mobile phones.
  22. *
  23. ******************************************************************************/
  24. #ifndef BTA_AG_API_H
  25. #define BTA_AG_API_H
  26. #include "bta_api.h"
  27. #include <string>
  28. #include <vector>
  29. /*****************************************************************************
  30. * Constants and data types
  31. ****************************************************************************/
  32. /* Number of SCBs (AG service instances that can be registered) */
  33. #define BTA_AG_MAX_NUM_CLIENTS 6
  34. #define HFP_HSP_VERSION_UNKNOWN 0x0000
  35. #define HFP_VERSION_1_1 0x0101
  36. #define HFP_VERSION_1_5 0x0105
  37. #define HFP_VERSION_1_6 0x0106
  38. #define HFP_VERSION_1_7 0x0107
  39. #define HSP_VERSION_1_0 0x0100
  40. #define HSP_VERSION_1_2 0x0102
  41. #define HFP_VERSION_CONFIG_KEY "HfpVersion"
  42. #define HFP_SDP_FEATURES_CONFIG_KEY "HfpSdpFeatures"
  43. /* Note, if you change the default version here, please also change the one in
  44. * bta_hs_api.h, they are meant to be the same.
  45. */
  46. #ifndef BTA_HFP_VERSION
  47. #define BTA_HFP_VERSION HFP_VERSION_1_7
  48. #endif
  49. /* AG feature masks */
  50. #define BTA_AG_FEAT_3WAY 0x00000001 /* Three-way calling */
  51. #define BTA_AG_FEAT_ECNR 0x00000002 /* Echo cancellation/noise reduction */
  52. #define BTA_AG_FEAT_VREC 0x00000004 /* Voice recognition */
  53. #define BTA_AG_FEAT_INBAND 0x00000008 /* In-band ring tone */
  54. #define BTA_AG_FEAT_VTAG 0x00000010 /* Attach a phone number to a voice tag */
  55. #define BTA_AG_FEAT_REJECT 0x00000020 /* Ability to reject incoming call */
  56. #define BTA_AG_FEAT_ECS 0x00000040 /* Enhanced Call Status */
  57. #define BTA_AG_FEAT_ECC 0x00000080 /* Enhanced Call Control */
  58. #define BTA_AG_FEAT_EXTERR 0x00000100 /* Extended error codes */
  59. #define BTA_AG_FEAT_CODEC 0x00000200 /* Codec Negotiation */
  60. /* AG SDP feature masks */
  61. #define BTA_AG_FEAT_WBS_SUPPORT 0x0020 /* Supports WBS */
  62. /* Only SDP feature bits 0 to 4 matches BRSF feature bits */
  63. #define HFP_SDP_BRSF_FEATURES_MASK 0x001F
  64. /* Valid feature bit mask for HFP 1.6 (and below) */
  65. #define HFP_1_6_FEAT_MASK 0x000003FF
  66. /* HFP 1.7+ */
  67. #define BTA_AG_FEAT_HF_IND 0x00000400 /* HF Indicators */
  68. #define BTA_AG_FEAT_ESCO 0x00000800 /* eSCO S4 (and T2) setting supported */
  69. /* Proprietary features: using 31 ~ 16 bits */
  70. #define BTA_AG_FEAT_BTRH 0x00010000 /* CCAP incoming call hold */
  71. #define BTA_AG_FEAT_UNAT 0x00020000 /* Pass unknown AT commands to app */
  72. #define BTA_AG_FEAT_NOSCO 0x00040000 /* No SCO control performed by BTA AG */
  73. #define BTA_AG_FEAT_NO_ESCO 0x00080000 /* Do not allow or use eSCO */
  74. #define BTA_AG_FEAT_VOIP 0x00100000 /* VoIP call */
  75. typedef uint32_t tBTA_AG_FEAT;
  76. /* AG open status */
  77. #define BTA_AG_SUCCESS 0 /* Connection successfully opened */
  78. #define BTA_AG_FAIL_SDP 1 /* Open failed due to SDP */
  79. #define BTA_AG_FAIL_RFCOMM 2 /* Open failed due to RFCOMM */
  80. #define BTA_AG_FAIL_RESOURCES 3 /* out of resources failure */
  81. /* Status to disallow passing AT Events after BTIF */
  82. #define BTA_AG_DISALLOW_AT 5
  83. typedef uint8_t tBTA_AG_STATUS;
  84. /* handle values used with BTA_AgResult */
  85. #define BTA_AG_HANDLE_NONE 0
  86. #define BTA_AG_HANDLE_ALL 0xFFFF
  87. /* It is safe to use the same value as BTA_AG_HANDLE_ALL
  88. * HANDLE_ALL is used for delivering indication
  89. * SCO_NO_CHANGE is used for changing sco behavior
  90. * They donot interfere with each other
  91. */
  92. /* Number of supported HF indicators, there is one HF indicator so far i.e.
  93. enhanced driver status. */
  94. /* Number of supported HF indicators,
  95. 1 for Enhanced Safety Status
  96. 2 for Battery Level Status */
  97. #ifndef BTA_AG_NUM_LOCAL_HF_IND
  98. #define BTA_AG_NUM_LOCAL_HF_IND 2
  99. #endif
  100. #define BTA_AG_HANDLE_SCO_NO_CHANGE 0xFFFF
  101. /* AG result codes used with BTA_AgResult */
  102. #define BTA_AG_SPK_RES 0 /* Update speaker volume */
  103. #define BTA_AG_MIC_RES 1 /* Update microphone volume */
  104. #define BTA_AG_INBAND_RING_RES 2 /* Update inband ring state */
  105. #define BTA_AG_CIND_RES 3 /* Send indicator response for AT+CIND */
  106. #define BTA_AG_BINP_RES 4 /* Send phone number for voice tag for AT+BINP */
  107. #define BTA_AG_IND_RES 5 /* Update an indicator value */
  108. #define BTA_AG_BVRA_RES 6 /* Update voice recognition state */
  109. #define BTA_AG_CNUM_RES 7 /* Send subscriber number response for AT+CNUM */
  110. #define BTA_AG_BTRH_RES 8 /* Send CCAP incoming call hold */
  111. #define BTA_AG_CLCC_RES 9 /* Query list of calls */
  112. #define BTA_AG_COPS_RES 10 /* Read network operator */
  113. #define BTA_AG_IN_CALL_RES 11 /* Indicate incoming phone call */
  114. #define BTA_AG_IN_CALL_CONN_RES 12 /* Incoming phone call connected */
  115. #define BTA_AG_CALL_WAIT_RES 13 /* Call waiting notification */
  116. #define BTA_AG_OUT_CALL_ORIG_RES 14 /* Outgoing phone call origination */
  117. /* Outgoing phone call alerting remote party */
  118. #define BTA_AG_OUT_CALL_ALERT_RES 15
  119. #define BTA_AG_OUT_CALL_CONN_RES 16 /* Outgoing phone call connected */
  120. /* Incoming/outgoing 3-way canceled before connected */
  121. #define BTA_AG_CALL_CANCEL_RES 17
  122. #define BTA_AG_END_CALL_RES 18 /* End call */
  123. #define BTA_AG_IN_CALL_HELD_RES 19 /* Incoming call held */
  124. #define BTA_AG_UNAT_RES 20 /* Response to unknown AT command event */
  125. #define BTA_AG_MULTI_CALL_RES 21 /* SLC at three way call */
  126. #define BTA_AG_BIND_RES 22 /* Activate/Deactivate HF indicator */
  127. #define BTA_AG_IND_RES_ON_DEMAND 33 /* Update an indicator value forcible */
  128. typedef uint8_t tBTA_AG_RES;
  129. /* HFP peer features */
  130. #define BTA_AG_PEER_FEAT_ECNR 0x0001 /* Echo cancellation/noise reduction */
  131. #define BTA_AG_PEER_FEAT_3WAY 0x0002 /* Call waiting and three-way calling */
  132. #define BTA_AG_PEER_FEAT_CLI 0x0004 /* Caller ID presentation capability */
  133. #define BTA_AG_PEER_FEAT_VREC 0x0008 /* Voice recognition activation */
  134. #define BTA_AG_PEER_FEAT_VOL 0x0010 /* Remote volume control */
  135. #define BTA_AG_PEER_FEAT_ECS 0x0020 /* Enhanced Call Status */
  136. #define BTA_AG_PEER_FEAT_ECC 0x0040 /* Enhanced Call Control */
  137. #define BTA_AG_PEER_FEAT_CODEC 0x0080 /* Codec Negotiation */
  138. #define BTA_AG_PEER_FEAT_HF_IND 0x0100 /* HF Indicators */
  139. #define BTA_AG_PEER_FEAT_ESCO 0x0200 /* eSCO S4 (and T2) setting supported */
  140. /* Proprietary features: using bits after 12 */
  141. /* Pass unknown AT command responses to application */
  142. #define BTA_AG_PEER_FEAT_UNAT 0x1000
  143. #define BTA_AG_PEER_FEAT_VOIP 0x2000 /* VoIP call */
  144. typedef uint16_t tBTA_AG_PEER_FEAT;
  145. /* HFP peer supported codec masks */
  146. // TODO(google) This should use common definitions
  147. #define BTA_AG_CODEC_NONE BTM_SCO_CODEC_NONE
  148. #define BTA_AG_CODEC_CVSD BTM_SCO_CODEC_CVSD /* CVSD */
  149. #define BTA_AG_CODEC_MSBC BTM_SCO_CODEC_MSBC /* mSBC */
  150. typedef uint16_t tBTA_AG_PEER_CODEC;
  151. /* HFP errcode - Set when BTA_AG_OK_ERROR is returned in 'ok_flag' */
  152. #define BTA_AG_ERR_PHONE_FAILURE 0 /* Phone Failure */
  153. #define BTA_AG_ERR_NO_CONN_PHONE 1 /* No connection to phone */
  154. #define BTA_AG_ERR_OP_NOT_ALLOWED 3 /* Operation not allowed */
  155. #define BTA_AG_ERR_OP_NOT_SUPPORTED 4 /* Operation not supported */
  156. #define BTA_AG_ERR_PHSIM_PIN_REQ 5 /* PH-SIM PIN required */
  157. #define BTA_AG_ERR_SIM_NOT_INSERTED 10 /* SIM not inserted */
  158. #define BTA_AG_ERR_SIM_PIN_REQ 11 /* SIM PIN required */
  159. #define BTA_AG_ERR_SIM_PUK_REQ 12 /* SIM PUK required */
  160. #define BTA_AG_ERR_SIM_FAILURE 13 /* SIM failure */
  161. #define BTA_AG_ERR_SIM_BUSY 14 /* SIM busy */
  162. #define BTA_AG_ERR_INCORRECT_PWD 16 /* Incorrect password */
  163. #define BTA_AG_ERR_SIM_PIN2_REQ 17 /* SIM PIN2 required */
  164. #define BTA_AG_ERR_SIM_PUK2_REQ 18 /* SIM PUK2 required */
  165. #define BTA_AG_ERR_MEMORY_FULL 20 /* Memory full */
  166. #define BTA_AG_ERR_INVALID_INDEX 21 /* Invalid index */
  167. #define BTA_AG_ERR_MEMORY_FAILURE 23 /* Memory failure */
  168. #define BTA_AG_ERR_TEXT_TOO_LONG 24 /* Text string too long */
  169. #define BTA_AG_ERR_INV_CHAR_IN_TSTR 25 /* Invalid characters in text string */
  170. #define BTA_AG_ERR_DSTR_TOO_LONG 26 /* Dial string too long */
  171. #define BTA_AG_ERR_INV_CHAR_IN_DSTR 27 /* Invalid characters in dial string */
  172. #define BTA_AG_ERR_NO_NETWORK_SERV 30 /* No network service */
  173. #define BTA_AG_ERR_NETWORK_TIME_OUT 31 /* Network timeout */
  174. /* Network not allowed - emergency service only */
  175. #define BTA_AG_ERR_NO_NET_EMG_ONLY 32
  176. /* AG cannot create simultaneous VoIP and CS calls */
  177. #define BTA_AG_ERR_VOIP_CS_CALLS 33
  178. #define BTA_AG_ERR_NOT_FOR_VOIP 34 /* Not supported on this call type(VoIP) */
  179. #define BTA_AG_ERR_SIP_RESP_CODE 35 /* SIP 3 digit response code */
  180. #if 0 /* Not Used in Bluetooth HFP 1.5 Specification */
  181. #define BTA_AG_ERR_PHADAP_LNK_RES 2 /* Phone-adapter link reserved */
  182. #define BTA_AG_ERR_PHFSIM_PIN_REQ 6 /* PH-FSIM PIN required */
  183. #define BTA_AG_ERR_PHFSIM_PUK_REQ 7 /* PH-FSIM PUK required */
  184. #define BTA_AG_ERR_SIM_WRONG 15 /* SIM wrong */
  185. #define BTA_AG_ERR_NOT_FOUND 22 /* Not found */
  186. #define BTA_AG_ERR_NETWORK_TIMEOUT 31 /* Network timeout */
  187. #define BTA_AG_ERR_NET_PIN_REQ 40 /* Network personalization PIN required */
  188. #define BTA_AG_ERR_NET_PUK_REQ 41 /* Network personalization PUK required */
  189. /* Network subset personalization PIN required */
  190. #define BTA_AG_ERR_SUBSET_PIN_REQ 42
  191. /* Network subset personalization PUK required */
  192. #define BTA_AG_ERR_SUBSET_PUK_REQ 43
  193. /* Service provider personalization PIN required */
  194. #define BTA_AG_ERR_SERVPRO_PIN_REQ 44
  195. /* Service provider personalization PUK required */
  196. #define BTA_AG_ERR_SERVPRO_PUK_REQ 45
  197. /* Corporate personalization PIN required */
  198. #define BTA_AG_ERR_CORP_PIN_REQ 46
  199. /* Corporate personalization PUK required */
  200. #define BTA_AG_ERR_CORP_PUK_REQ 47
  201. #define BTA_AG_ERR_UNKNOWN 100 /* Unknown error */
  202. /* GPRS-related errors */
  203. #define BTA_AG_ERR_ILL_MS 103 /* Illegal MS (#3) */
  204. #define BTA_AG_ERR_ILL_ME 106 /* Illegal ME (#6) */
  205. #define BTA_AG_ERR_GPRS_NOT_ALLOWED 107 /* GPRS services not allowed (#7) */
  206. #define BTA_AG_ERR_PLMN_NOT_ALLOWED 111 /* PLMN services not allowed (#11) */
  207. #define BTA_AG_ERR_LOC_NOT_ALLOWED 112 /* Location area not allowed (#12) */
  208. /* Roaming not allowed in this location area (#13) */
  209. #define BTA_AG_ERR_ROAM_NOT_ALLOWED 113
  210. /* Errors related to a failure to Activate a Context */
  211. #define BTA_AG_ERR_OPT_NOT_SUPP 132 /* Service option not supported (#32) */
  212. /* Requested service option not subscribed (#33) */
  213. #define BTA_AG_ERR_OPT_NOT_SUBSCR 133
  214. /* Service option temporarily out of order (#34) */
  215. #define BTA_AG_ERR_OPT_OUT_OF_ORDER 134
  216. #define BTA_AG_ERR_PDP_AUTH_FAILURE 149 /* PDP authentication failure */
  217. /* Other GPRS errors */
  218. #define BTA_AG_ERR_INV_MOBILE_CLASS 150 /* Invalid mobile class */
  219. #define BTA_AG_ERR_UNSPEC_GPRS_ERR 148 /* Unspecified GPRS error */
  220. #endif /* Unused error codes */
  221. /* HFP result data 'ok_flag' */
  222. #define BTA_AG_OK_CONTINUE 0 /* Send out response (more responses coming) */
  223. #define BTA_AG_OK_DONE 1 /* Send out response followed by OK (finished) */
  224. #define BTA_AG_OK_ERROR 2 /* Error response */
  225. /* BTRH values */
  226. #define BTA_AG_BTRH_SET_HOLD 0 /* Put incoming call on hold */
  227. #define BTA_AG_BTRH_SET_ACC 1 /* Accept incoming call on hold */
  228. #define BTA_AG_BTRH_SET_REJ 2 /* Reject incoming call on hold */
  229. #define BTA_AG_BTRH_READ 3 /* Read the current value */
  230. #define BTA_AG_BTRH_NO_RESP 4 /* Not in RH States (reply to read) */
  231. /* clip type constants */
  232. #define BTA_AG_CLIP_TYPE_MIN 128
  233. #define BTA_AG_CLIP_TYPE_MAX 175
  234. #define BTA_AG_CLIP_TYPE_DEFAULT 129
  235. #define BTA_AG_CLIP_TYPE_VOIP 255
  236. /* ASCII character string of arguments to the AT command or result */
  237. #ifndef BTA_AG_AT_MAX_LEN
  238. #define BTA_AG_AT_MAX_LEN 256
  239. #endif
  240. /* data associated with BTA_AG_IND_RES */
  241. typedef struct {
  242. uint16_t id;
  243. uint16_t value;
  244. bool on_demand;
  245. } tBTA_AG_IND;
  246. /* data type for BTA_AgResult() */
  247. struct tBTA_AG_RES_DATA {
  248. char str[BTA_AG_AT_MAX_LEN + 1];
  249. tBTA_AG_IND ind;
  250. uint16_t num;
  251. uint16_t audio_handle;
  252. uint16_t errcode; /* Valid only if 'ok_flag' is set to BTA_AG_OK_ERROR */
  253. uint8_t
  254. ok_flag; /* Indicates if response is finished, and if error occurred */
  255. bool state;
  256. static const tBTA_AG_RES_DATA kEmpty;
  257. };
  258. /* AG callback events */
  259. #define BTA_AG_ENABLE_EVT 0 /* AG enabled */
  260. #define BTA_AG_REGISTER_EVT 1 /* AG registered */
  261. #define BTA_AG_OPEN_EVT 2 /* AG connection open */
  262. #define BTA_AG_CLOSE_EVT 3 /* AG connection closed */
  263. #define BTA_AG_CONN_EVT 4 /* Service level connection opened */
  264. #define BTA_AG_AUDIO_OPEN_EVT 5 /* Audio connection open */
  265. #define BTA_AG_AUDIO_CLOSE_EVT 6 /* Audio connection closed */
  266. #define BTA_AG_SPK_EVT 7 /* Speaker volume changed */
  267. #define BTA_AG_MIC_EVT 8 /* Microphone volume changed */
  268. #define BTA_AG_AT_CKPD_EVT 9 /* CKPD from the HS */
  269. #define BTA_AG_DISABLE_EVT 30 /* AG disabled */
  270. #define BTA_AG_WBS_EVT 31 /* SCO codec info */
  271. /* Values below are for HFP only */
  272. #define BTA_AG_AT_A_EVT 10 /* Answer a call */
  273. #define BTA_AG_AT_D_EVT 11 /* Place a call using number or memory dial */
  274. #define BTA_AG_AT_CHLD_EVT 12 /* Call hold */
  275. #define BTA_AG_AT_CHUP_EVT 13 /* Hang up a call */
  276. #define BTA_AG_AT_CIND_EVT 14 /* Read indicator settings */
  277. #define BTA_AG_AT_VTS_EVT 15 /* Transmit DTMF tone */
  278. #define BTA_AG_AT_BINP_EVT 16 /* Retrieve number from voice tag */
  279. #define BTA_AG_AT_BLDN_EVT 17 /* Place call to last dialed number */
  280. #define BTA_AG_AT_BVRA_EVT 18 /* Enable/disable voice recognition */
  281. #define BTA_AG_AT_NREC_EVT 19 /* Disable echo canceling */
  282. #define BTA_AG_AT_CNUM_EVT 20 /* Retrieve subscriber number */
  283. #define BTA_AG_AT_BTRH_EVT 21 /* CCAP-style incoming call hold */
  284. #define BTA_AG_AT_CLCC_EVT 22 /* Query list of current calls */
  285. #define BTA_AG_AT_COPS_EVT 23 /* Query list of current calls */
  286. #define BTA_AG_AT_UNAT_EVT 24 /* Unknown AT command */
  287. #define BTA_AG_AT_CBC_EVT 25 /* Battery Level report from HF */
  288. #define BTA_AG_AT_BAC_EVT 26 /* avablable codec */
  289. #define BTA_AG_AT_BCS_EVT 27 /* Codec select */
  290. #define BTA_AG_AT_BIND_EVT 28 /* HF indicator */
  291. #define BTA_AG_AT_BIEV_EVT 29 /* HF indicator updates from peer */
  292. #define BTA_AG_AT_BIA_EVT 32 /* AG indicator activation event from peer */
  293. typedef uint8_t tBTA_AG_EVT;
  294. /* data associated with most non-AT events */
  295. typedef struct {
  296. uint16_t handle;
  297. uint8_t app_id;
  298. tBTA_AG_STATUS status;
  299. } tBTA_AG_HDR;
  300. /* data associated with BTA_AG_REGISTER_EVT */
  301. typedef struct {
  302. tBTA_AG_HDR hdr;
  303. tBTA_AG_STATUS status;
  304. } tBTA_AG_REGISTER;
  305. /* data associated with BTA_AG_OPEN_EVT */
  306. typedef struct {
  307. tBTA_AG_HDR hdr;
  308. RawAddress bd_addr;
  309. tBTA_SERVICE_ID service_id;
  310. tBTA_AG_STATUS status;
  311. } tBTA_AG_OPEN;
  312. /* data associated with BTA_AG_CLOSE_EVT */
  313. typedef struct {
  314. tBTA_AG_HDR hdr;
  315. RawAddress bd_addr;
  316. } tBTA_AG_CLOSE;
  317. /* data associated with BTA_AG_CONN_EVT */
  318. typedef struct {
  319. tBTA_AG_HDR hdr;
  320. tBTA_AG_PEER_FEAT peer_feat;
  321. RawAddress bd_addr;
  322. tBTA_AG_PEER_CODEC peer_codec;
  323. } tBTA_AG_CONN;
  324. /* data associated with AT command event */
  325. typedef struct {
  326. tBTA_AG_HDR hdr;
  327. RawAddress bd_addr;
  328. char str[BTA_AG_AT_MAX_LEN + 1];
  329. uint32_t num;
  330. uint8_t idx; /* call number used by CLCC and CHLD */
  331. uint16_t lidx; /* long index, ex, HF indicator */
  332. } tBTA_AG_VAL;
  333. /* union of data associated with AG callback */
  334. typedef union {
  335. tBTA_AG_HDR hdr;
  336. tBTA_AG_REGISTER reg;
  337. tBTA_AG_OPEN open;
  338. tBTA_AG_CLOSE close;
  339. tBTA_AG_CONN conn;
  340. tBTA_AG_VAL val;
  341. } tBTA_AG;
  342. /* AG callback */
  343. typedef void(tBTA_AG_CBACK)(tBTA_AG_EVT event, tBTA_AG* p_data);
  344. /* indicator constants HFP 1.1 and later */
  345. #define BTA_AG_IND_CALL 1 /* position of call indicator */
  346. #define BTA_AG_IND_CALLSETUP 2 /* position of callsetup indicator */
  347. #define BTA_AG_IND_SERVICE 3 /* position of service indicator */
  348. /* indicator constants HFP 1.5 and later */
  349. #define BTA_AG_IND_SIGNAL 4 /* position of signal strength indicator */
  350. #define BTA_AG_IND_ROAM 5 /* position of roaming indicator */
  351. #define BTA_AG_IND_BATTCHG 6 /* position of battery charge indicator */
  352. #define BTA_AG_IND_CALLHELD 7 /* position of callheld indicator */
  353. #define BTA_AG_IND_BEARER 8 /* position of bearer indicator */
  354. /* call indicator values */
  355. #define BTA_AG_CALL_INACTIVE 0 /* Phone call inactive */
  356. #define BTA_AG_CALL_ACTIVE 1 /* Phone call active */
  357. /* callsetup indicator values */
  358. #define BTA_AG_CALLSETUP_NONE 0 /* Not currently in call set up */
  359. #define BTA_AG_CALLSETUP_INCOMING 1 /* Incoming call process ongoing */
  360. #define BTA_AG_CALLSETUP_OUTGOING 2 /* Outgoing call set up is ongoing */
  361. /* Remote party being alerted in an outgoing call */
  362. #define BTA_AG_CALLSETUP_ALERTING 3
  363. /* service indicator values */
  364. #define BTA_AG_SERVICE_NONE 0 /* Neither CS nor VoIP service is available */
  365. #define BTA_AG_SERVICE_CS 1 /* Only CS service is available */
  366. #define BTA_AG_SERVICE_VOIP 2 /* Only VoIP service is available */
  367. #define BTA_AG_SERVICE_CS_VOIP 3 /* Both CS and VoIP services available */
  368. /* callheld indicator values */
  369. #define BTA_AG_CALLHELD_INACTIVE 0 /* No held calls */
  370. #define BTA_AG_CALLHELD_ACTIVE 1 /* Call held and call active */
  371. #define BTA_AG_CALLHELD_NOACTIVE 2 /* Call held and no call active */
  372. /* signal strength indicator values */
  373. #define BTA_AG_ROAMING_INACTIVE 0 /* Phone call inactive */
  374. #define BTA_AG_ROAMING_ACTIVE 1 /* Phone call active */
  375. /* bearer indicator values */
  376. #define BTA_AG_BEARER_WLAN 0 /* WLAN */
  377. #define BTA_AG_BEARER_BLUETOOTH 1 /* Bluetooth */
  378. #define BTA_AG_BEARER_WIRED 2 /* Wired */
  379. #define BTA_AG_BEARER_2G3G 3 /* 2G 3G */
  380. #define BTA_AG_BEARER_WIMAX 4 /* WIMAX */
  381. #define BTA_AG_BEARER_RES1 5 /* Reserved */
  382. #define BTA_AG_BEARER_RES2 6 /* Reserved */
  383. #define BTA_AG_BEARER_RES3 7 /* Reserved */
  384. /* type for HF indicator */
  385. typedef struct {
  386. uint16_t ind_id;
  387. bool is_supported;
  388. bool is_enable;
  389. uint32_t ind_min_val;
  390. uint32_t ind_max_val;
  391. } tBTA_AG_HF_IND;
  392. /* AG configuration structure */
  393. typedef struct {
  394. const char* cind_info;
  395. const char* bind_info;
  396. uint8_t num_local_hf_ind;
  397. int32_t conn_tout;
  398. uint16_t sco_pkt_types;
  399. const char* chld_val_ecc;
  400. const char* chld_val;
  401. } tBTA_AG_CFG;
  402. /*****************************************************************************
  403. * External Function Declarations
  404. ****************************************************************************/
  405. /*******************************************************************************
  406. *
  407. * Function BTA_AgEnable
  408. *
  409. * Description Enable the audio gateway service. When the enable
  410. * operation is complete the callback function will be
  411. * called with a BTA_AG_ENABLE_EVT. This function must
  412. * be called before other function in the AG API are
  413. * called.
  414. *
  415. * Returns BTA_SUCCESS if OK, BTA_FAILURE otherwise.
  416. *
  417. ******************************************************************************/
  418. tBTA_STATUS BTA_AgEnable(tBTA_AG_CBACK* p_cback);
  419. /*******************************************************************************
  420. *
  421. * Function BTA_AgDisable
  422. *
  423. * Description Disable the audio gateway service
  424. *
  425. *
  426. * Returns void
  427. *
  428. ******************************************************************************/
  429. void BTA_AgDisable();
  430. /*******************************************************************************
  431. *
  432. * Function BTA_AgRegister
  433. *
  434. * Description Register an Audio Gateway service.
  435. *
  436. *
  437. * Returns void
  438. *
  439. ******************************************************************************/
  440. void BTA_AgRegister(tBTA_SERVICE_MASK services, tBTA_SEC sec_mask,
  441. tBTA_AG_FEAT features,
  442. const std::vector<std::string>& service_names,
  443. uint8_t app_id);
  444. /*******************************************************************************
  445. *
  446. * Function BTA_AgDeregister
  447. *
  448. * Description Deregister an audio gateway service.
  449. *
  450. *
  451. * Returns void
  452. *
  453. ******************************************************************************/
  454. void BTA_AgDeregister(uint16_t handle);
  455. /*******************************************************************************
  456. *
  457. * Function BTA_AgOpen
  458. *
  459. * Description Opens a connection to a headset or hands-free device.
  460. * When connection is open callback function is called
  461. * with a BTA_AG_OPEN_EVT. Only the data connection is
  462. * opened. The audio connection is not opened.
  463. *
  464. *
  465. * Returns void
  466. *
  467. ******************************************************************************/
  468. void BTA_AgOpen(uint16_t handle, const RawAddress& bd_addr, tBTA_SEC sec_mask);
  469. /*******************************************************************************
  470. *
  471. * Function BTA_AgClose
  472. *
  473. * Description Close the current connection to a headset or a handsfree
  474. * Any current audio connection will also be closed
  475. *
  476. *
  477. * Returns void
  478. *
  479. ******************************************************************************/
  480. void BTA_AgClose(uint16_t handle);
  481. /*******************************************************************************
  482. *
  483. * Function BTA_AgAudioOpen
  484. *
  485. * Description Opens an audio connection to the currently connected
  486. * headset or hnadsfree
  487. *
  488. *
  489. * Returns void
  490. *
  491. ******************************************************************************/
  492. void BTA_AgAudioOpen(uint16_t handle);
  493. /*******************************************************************************
  494. *
  495. * Function BTA_AgAudioClose
  496. *
  497. * Description Close the currently active audio connection to a headset
  498. * or hnadsfree. The data connection remains open
  499. *
  500. *
  501. * Returns void
  502. *
  503. ******************************************************************************/
  504. void BTA_AgAudioClose(uint16_t handle);
  505. /*******************************************************************************
  506. *
  507. * Function BTA_AgResult
  508. *
  509. * Description Send an AT result code to a headset or hands-free device.
  510. *
  511. *
  512. * Returns void
  513. *
  514. ******************************************************************************/
  515. void BTA_AgResult(uint16_t handle, tBTA_AG_RES result,
  516. const tBTA_AG_RES_DATA& data);
  517. /*******************************************************************************
  518. *
  519. * Function BTA_AgSetCodec
  520. *
  521. * Description Specify the codec type to be used for the subsequent
  522. * audio connection.
  523. *
  524. *
  525. *
  526. * Returns void
  527. *
  528. ******************************************************************************/
  529. void BTA_AgSetCodec(uint16_t handle, tBTA_AG_PEER_CODEC codec);
  530. void BTA_AgSetScoAllowed(bool value);
  531. void BTA_AgSetActiveDevice(const RawAddress& active_device_addr);
  532. #endif /* BTA_AG_API_H */