• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/bt


Commit MetaInfo

Revision8d3cf5988a28f0691062183b18280fc329845575 (tree)
Zeit2017-01-05 10:20:11
AutorAndre Eisenbach <eisenbach@goog...>
CommiterAndre Eisenbach

Log Message

Remove position dependent lookup tables in AT command parser

The various position dependent lookup tables in the AT command parser
were out of sync, causing invalid responses to the AT+CBPS command for
example.

This patch gets rid of positionally dependent enums for simple lookup
tables that correlate all the values for easier, less error prone
maintenance of the related tables.

This re-instates a previously reverted patch after fixing incorrect
field order in tBTA_AG_INDICATOR_MAP.

Change-Id: I7f8a052e78706c8c72c5102b38cfe9ce200ae0d9
Fixes: 29978908

Ändern Zusammenfassung

Diff

--- a/bta/ag/bta_ag_at.c
+++ b/bta/ag/bta_ag_at.c
@@ -149,12 +149,16 @@ void bta_ag_process_at(tBTA_AG_AT_CB *p_cb)
149149 else
150150 {
151151
152- (*p_cb->p_cmd_cback)(p_cb->p_user, idx, arg_type, p_arg, int_arg);
152+ (*p_cb->p_cmd_cback)(p_cb->p_user,
153+ p_cb->p_at_tbl[idx].command_id,
154+ arg_type, p_arg, int_arg);
153155 }
154156 }
155157 else
156158 {
157- (*p_cb->p_cmd_cback)(p_cb->p_user, idx, arg_type, p_arg, int_arg);
159+ (*p_cb->p_cmd_cback)(p_cb->p_user,
160+ p_cb->p_at_tbl[idx].command_id,
161+ arg_type, p_arg, int_arg);
158162 }
159163 }
160164 /* else error */
--- a/bta/ag/bta_ag_at.h
+++ b/bta/ag/bta_ag_at.h
@@ -47,6 +47,7 @@
4747 typedef struct
4848 {
4949 const char *p_cmd; /* AT command string */
50+ size_t command_id; /* passed to the callback on p_cmd match */
5051 UINT8 arg_type; /* allowable argument type syntax */
5152 UINT8 fmt; /* whether arg is int or string */
5253 UINT8 min; /* minimum value for int arg */
@@ -54,7 +55,7 @@ typedef struct
5455 } tBTA_AG_AT_CMD;
5556
5657 /* callback function executed when command is parsed */
57-typedef void (tBTA_AG_AT_CMD_CBACK)(void *p_user, UINT16 cmd, UINT8 arg_type,
58+typedef void (tBTA_AG_AT_CMD_CBACK)(void *p_user, UINT16 command_id, UINT8 arg_type,
5859 char *p_arg, INT16 int_arg);
5960
6061 /* callback function executed to send "ERROR" result code */
--- a/bta/ag/bta_ag_cmd.c
+++ b/bta/ag/bta_ag_cmd.c
@@ -16,11 +16,8 @@
1616 *
1717 ******************************************************************************/
1818
19-/******************************************************************************
20- *
21- * This file contains functions for processing AT commands and results.
22- *
23- ******************************************************************************/
19+#define LOG_TAG "bta_ag_cmd"
20+
2421 #include <ctype.h>
2522 #include <stdio.h>
2623 #include <string.h>
@@ -33,6 +30,7 @@
3330 #include "bta_api.h"
3431 #include "bta_sys.h"
3532 #include "bt_common.h"
33+#include "osi/include/log.h"
3634 #include "port_api.h"
3735 #include "utl.h"
3836
@@ -55,116 +53,73 @@
5553 #define BTA_AG_CLIP_TYPE_DEFAULT 129
5654 #define BTA_AG_CLIP_TYPE_VOIP 255
5755
58-#if defined(BTA_AG_MULTI_RESULT_INCLUDED) && (BTA_AG_MULTI_RESULT_INCLUDED == TRUE)
59-#define BTA_AG_AT_MULTI_LEN 2
60-#define AT_SET_RES_CB(res_cb, c, p, i) {res_cb.code = c; res_cb.p_arg = p; res_cb.int_arg = i;}
61-
62-/* type for AT result code block */
63-typedef struct
64-{
65- UINT8 code;
66- char *p_arg;
67- INT16 int_arg;
68-} tBTA_AG_RESULT_CB;
69-
70-/* type for multiple AT result codes block */
71-typedef struct
72-{
73- UINT8 num_result;
74- tBTA_AG_RESULT_CB res_cb[BTA_AG_AT_MULTI_LEN];
75-} tBTA_AG_MULTI_RESULT_CB;
76-#endif
77-
78-/* enumeration of HSP AT commands matches HSP command interpreter table */
79-enum
80-{
81- BTA_AG_HS_CMD_CKPD,
82- BTA_AG_HS_CMD_VGS,
83- BTA_AG_HS_CMD_VGM
84-};
56+#define COLON_IDX_4_VGSVGM 4
8557
86-/* enumeration of HFP AT commands matches HFP command interpreter table */
58+/* Local events which will not trigger a higher layer callback */
8759 enum
8860 {
89- BTA_AG_HF_CMD_A,
90- BTA_AG_HF_CMD_D,
91- BTA_AG_HF_CMD_VGS,
92- BTA_AG_HF_CMD_VGM,
93- BTA_AG_HF_CMD_CCWA,
94- BTA_AG_HF_CMD_CHLD,
95- BTA_AG_HF_CMD_CHUP,
96- BTA_AG_HF_CMD_CIND,
97- BTA_AG_HF_CMD_CLIP,
98- BTA_AG_HF_CMD_CMER,
99- BTA_AG_HF_CMD_VTS,
100- BTA_AG_HF_CMD_BINP,
101- BTA_AG_HF_CMD_BLDN,
102- BTA_AG_HF_CMD_BVRA,
103- BTA_AG_HF_CMD_BRSF,
104- BTA_AG_HF_CMD_NREC,
105- BTA_AG_HF_CMD_CNUM,
106- BTA_AG_HF_CMD_BTRH,
107- BTA_AG_HF_CMD_CLCC,
108- BTA_AG_HF_CMD_COPS,
109- BTA_AG_HF_CMD_CMEE,
110- BTA_AG_HF_CMD_BIA,
111- BTA_AG_HF_CMD_CBC,
112- BTA_AG_HF_CMD_BCC,
113- BTA_AG_HF_CMD_BCS,
114- BTA_AG_HF_CMD_BIND,
115- BTA_AG_HF_CMD_BIEV,
116- BTA_AG_HF_CMD_BAC
61+ BTA_AG_LOCAL_EVT_FIRST = 0x100,
62+ BTA_AG_LOCAL_EVT_CCWA,
63+ BTA_AG_LOCAL_EVT_CLIP,
64+ BTA_AG_LOCAL_EVT_CMER,
65+ BTA_AG_LOCAL_EVT_BRSF,
66+ BTA_AG_LOCAL_EVT_CMEE,
67+ BTA_AG_LOCAL_EVT_BIA,
68+ BTA_AG_LOCAL_EVT_BCC,
11769 };
11870
11971 /* AT command interpreter table for HSP */
12072 const tBTA_AG_AT_CMD bta_ag_hsp_cmd[] =
12173 {
122- {"+CKPD", BTA_AG_AT_SET, BTA_AG_AT_INT, 200, 200},
123- {"+VGS", BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 15},
124- {"+VGM", BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 15},
125- {"", BTA_AG_AT_NONE, BTA_AG_AT_STR, 0, 0}
74+ {"+CKPD", BTA_AG_AT_CKPD_EVT, BTA_AG_AT_SET, BTA_AG_AT_INT, 200, 200},
75+ {"+VGS", BTA_AG_SPK_EVT, BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 15},
76+ {"+VGM", BTA_AG_MIC_EVT, BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 15},
77+ /* End-of-table marker used to stop lookup iteration */
78+ {"", 0, 0, 0, 0, 0}
12679 };
12780
12881 /* AT command interpreter table for HFP */
12982 const tBTA_AG_AT_CMD bta_ag_hfp_cmd[] =
13083 {
131- {"A", BTA_AG_AT_NONE, BTA_AG_AT_STR, 0, 0},
132- {"D", (BTA_AG_AT_NONE | BTA_AG_AT_FREE), BTA_AG_AT_STR, 0, 0},
133- {"+VGS", BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 15},
134- {"+VGM", BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 15},
135- {"+CCWA", BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 1},
84+ {"A", BTA_AG_AT_A_EVT, BTA_AG_AT_NONE, BTA_AG_AT_STR, 0, 0},
85+ {"D", BTA_AG_AT_D_EVT, BTA_AG_AT_NONE | BTA_AG_AT_FREE, BTA_AG_AT_STR, 0, 0},
86+ {"+VGS", BTA_AG_SPK_EVT, BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 15},
87+ {"+VGM", BTA_AG_MIC_EVT, BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 15},
88+ {"+CCWA", BTA_AG_LOCAL_EVT_CCWA, BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 1},
13689 /* Consider CHLD as str to take care of indexes for ECC */
137- {"+CHLD", (BTA_AG_AT_SET | BTA_AG_AT_TEST), BTA_AG_AT_STR, 0, 4},
138- {"+CHUP", BTA_AG_AT_NONE, BTA_AG_AT_STR, 0, 0},
139- {"+CIND", (BTA_AG_AT_READ | BTA_AG_AT_TEST), BTA_AG_AT_STR, 0, 0},
140- {"+CLIP", BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 1},
141- {"+CMER", BTA_AG_AT_SET, BTA_AG_AT_STR, 0, 0},
142- {"+VTS", BTA_AG_AT_SET, BTA_AG_AT_STR, 0, 0},
143- {"+BINP", BTA_AG_AT_SET, BTA_AG_AT_INT, 1, 1},
144- {"+BLDN", BTA_AG_AT_NONE, BTA_AG_AT_STR, 0, 0},
145- {"+BVRA", BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 1},
146- {"+BRSF", BTA_AG_AT_SET, BTA_AG_AT_INT, 0, BTA_AG_CMD_MAX_VAL},
147- {"+NREC", BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 0},
148- {"+CNUM", BTA_AG_AT_NONE, BTA_AG_AT_STR, 0, 0},
149- {"+BTRH", (BTA_AG_AT_READ | BTA_AG_AT_SET), BTA_AG_AT_INT, 0, 2},
150- {"+CLCC", BTA_AG_AT_NONE, BTA_AG_AT_STR, 0, 0},
151- {"+COPS", (BTA_AG_AT_READ | BTA_AG_AT_SET), BTA_AG_AT_STR, 0, 0},
152- {"+CMEE", BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 1},
153- {"+BIA", BTA_AG_AT_SET, BTA_AG_AT_STR, 0, 20},
154- {"+CBC", BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 100},
155- {"+BCC", BTA_AG_AT_NONE, BTA_AG_AT_STR, 0, 0},
156- {"+BCS", BTA_AG_AT_SET, BTA_AG_AT_INT, 0, BTA_AG_CMD_MAX_VAL},
157- {"+BIND", BTA_AG_AT_SET | BTA_AG_AT_READ | BTA_AG_AT_TEST , BTA_AG_AT_STR, 0, 0},
158- {"+BIEV", BTA_AG_AT_SET, BTA_AG_AT_STR, 0, 0},
159- {"+BAC", BTA_AG_AT_SET, BTA_AG_AT_STR, 0, 0},
160- {"", BTA_AG_AT_NONE, BTA_AG_AT_STR, 0, 0}
90+ {"+CHLD", BTA_AG_AT_CHLD_EVT, BTA_AG_AT_SET | BTA_AG_AT_TEST, BTA_AG_AT_STR, 0, 4},
91+ {"+CHUP", BTA_AG_AT_CHUP_EVT, BTA_AG_AT_NONE, BTA_AG_AT_STR, 0, 0},
92+ {"+CIND", BTA_AG_AT_CIND_EVT, BTA_AG_AT_READ | BTA_AG_AT_TEST, BTA_AG_AT_STR, 0, 0},
93+ {"+CLIP", BTA_AG_LOCAL_EVT_CLIP, BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 1},
94+ {"+CMER", BTA_AG_LOCAL_EVT_CMER, BTA_AG_AT_SET, BTA_AG_AT_STR, 0, 0},
95+ {"+VTS", BTA_AG_AT_VTS_EVT, BTA_AG_AT_SET, BTA_AG_AT_STR, 0, 0},
96+ {"+BINP", BTA_AG_AT_BINP_EVT, BTA_AG_AT_SET, BTA_AG_AT_INT, 1, 1},
97+ {"+BLDN", BTA_AG_AT_BLDN_EVT, BTA_AG_AT_NONE, BTA_AG_AT_STR, 0, 0},
98+ {"+BVRA", BTA_AG_AT_BVRA_EVT, BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 1},
99+ {"+BRSF", BTA_AG_LOCAL_EVT_BRSF, BTA_AG_AT_SET, BTA_AG_AT_INT, 0, BTA_AG_CMD_MAX_VAL},
100+ {"+NREC", BTA_AG_AT_NREC_EVT, BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 0},
101+ {"+CNUM", BTA_AG_AT_CNUM_EVT, BTA_AG_AT_NONE, BTA_AG_AT_STR, 0, 0},
102+ {"+BTRH", BTA_AG_AT_BTRH_EVT, BTA_AG_AT_READ | BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 2},
103+ {"+CLCC", BTA_AG_AT_CLCC_EVT, BTA_AG_AT_NONE, BTA_AG_AT_STR, 0, 0},
104+ {"+COPS", BTA_AG_AT_COPS_EVT, BTA_AG_AT_READ | BTA_AG_AT_SET, BTA_AG_AT_STR, 0, 0},
105+ {"+CMEE", BTA_AG_LOCAL_EVT_CMEE, BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 1},
106+ {"+BIA", BTA_AG_LOCAL_EVT_BIA, BTA_AG_AT_SET, BTA_AG_AT_STR, 0, 20},
107+ {"+CBC", BTA_AG_AT_CBC_EVT, BTA_AG_AT_SET, BTA_AG_AT_INT, 0, 100},
108+ {"+BCC", BTA_AG_LOCAL_EVT_BCC, BTA_AG_AT_NONE, BTA_AG_AT_STR, 0, 0},
109+ {"+BCS", BTA_AG_AT_BCS_EVT, BTA_AG_AT_SET, BTA_AG_AT_INT, 0, BTA_AG_CMD_MAX_VAL},
110+ {"+BIND", BTA_AG_AT_BIND_EVT, BTA_AG_AT_SET | BTA_AG_AT_READ | BTA_AG_AT_TEST, BTA_AG_AT_STR, 0, 0},
111+ {"+BIEV", BTA_AG_AT_BIEV_EVT, BTA_AG_AT_SET, BTA_AG_AT_STR, 0, 0},
112+ {"+BAC", BTA_AG_AT_BAC_EVT, BTA_AG_AT_SET, BTA_AG_AT_STR, 0, 0},
113+ /* End-of-table marker used to stop lookup iteration */
114+ {"", 0, 0, 0, 0, 0}
161115 };
162116
163117 /* AT result code table element */
164118 typedef struct
165119 {
166- const char *p_res; /* AT result string */
167- UINT8 fmt; /* whether argument is int or string */
120+ const char *result_string; /* AT result string */
121+ size_t result_id; /* Local or BTA result id */
122+ UINT8 arg_type; /* whether argument is int or string */
168123 } tBTA_AG_RESULT;
169124
170125 /* AT result code argument types */
@@ -175,162 +130,88 @@ enum
175130 BTA_AG_RES_FMT_STR /* string argument */
176131 };
177132
178-/* enumeration of AT result codes, matches constant table */
133+/* Local AT command result codes not defined in bta_ag_api.h */
179134 enum
180135 {
181- BTA_AG_RES_OK,
182- BTA_AG_RES_ERROR,
183- BTA_AG_RES_RING,
184- BTA_AG_RES_VGS,
185- BTA_AG_RES_VGM,
186- BTA_AG_RES_CCWA,
187- BTA_AG_RES_CHLD,
188- BTA_AG_RES_CIND,
189- BTA_AG_RES_CLIP,
190- BTA_AG_RES_CIEV,
191- BTA_AG_RES_BINP,
192- BTA_AG_RES_BVRA,
193- BTA_AG_RES_BRSF,
194- BTA_AG_RES_BSIR,
195- BTA_AG_RES_CNUM,
196- BTA_AG_RES_BTRH,
197- BTA_AG_RES_CLCC,
198- BTA_AG_RES_COPS,
199- BTA_AG_RES_CMEE,
200- BTA_AG_RES_BCS,
201- BTA_AG_RES_BIND,
202- BTA_AG_RES_UNAT
136+ BTA_AG_LOCAL_RES_FIRST = 0x0100,
137+ BTA_AG_LOCAL_RES_OK,
138+ BTA_AG_LOCAL_RES_ERROR,
139+ BTA_AG_LOCAL_RES_RING,
140+ BTA_AG_LOCAL_RES_CLIP,
141+ BTA_AG_LOCAL_RES_BRSF,
142+ BTA_AG_LOCAL_RES_CMEE,
143+ BTA_AG_LOCAL_RES_BCS
203144 };
204145
205-#if defined(BTA_HSP_RESULT_REPLACE_COLON) && (BTA_HSP_RESULT_REPLACE_COLON == TRUE)
206-#define COLON_IDX_4_VGSVGM 4
207-#endif
208-/* AT result code constant table (Indexed by result code) */
146+/* AT result code constant table */
209147 const tBTA_AG_RESULT bta_ag_result_tbl[] =
210148 {
211- {"OK", BTA_AG_RES_FMT_NONE},
212- {"ERROR", BTA_AG_RES_FMT_NONE},
213- {"RING", BTA_AG_RES_FMT_NONE},
214- {"+VGS: ", BTA_AG_RES_FMT_INT},
215- {"+VGM: ", BTA_AG_RES_FMT_INT},
216- {"+CCWA: ", BTA_AG_RES_FMT_STR},
217- {"+CHLD: ", BTA_AG_RES_FMT_STR},
218- {"+CIND: ", BTA_AG_RES_FMT_STR},
219- {"+CLIP: ", BTA_AG_RES_FMT_STR},
220- {"+CIEV: ", BTA_AG_RES_FMT_STR},
221- {"+BINP: ", BTA_AG_RES_FMT_STR},
222- {"+BVRA: ", BTA_AG_RES_FMT_INT},
223- {"+BRSF: ", BTA_AG_RES_FMT_INT},
224- {"+BSIR: ", BTA_AG_RES_FMT_INT},
225- {"+CNUM: ", BTA_AG_RES_FMT_STR},
226- {"+BTRH: ", BTA_AG_RES_FMT_INT},
227- {"+CLCC: ", BTA_AG_RES_FMT_STR},
228- {"+COPS: ", BTA_AG_RES_FMT_STR},
229- {"+CME ERROR: ", BTA_AG_RES_FMT_INT},
230- {"+BCS: ", BTA_AG_RES_FMT_INT},
231- {"+BIND: ", BTA_AG_RES_FMT_STR},
232- {"", BTA_AG_RES_FMT_STR}
149+ {"OK", BTA_AG_LOCAL_RES_OK, BTA_AG_RES_FMT_NONE},
150+ {"ERROR", BTA_AG_LOCAL_RES_ERROR, BTA_AG_RES_FMT_NONE},
151+ {"RING", BTA_AG_LOCAL_RES_RING, BTA_AG_RES_FMT_NONE},
152+ {"+VGS: ", BTA_AG_SPK_RES, BTA_AG_RES_FMT_INT},
153+ {"+VGM: ", BTA_AG_MIC_RES, BTA_AG_RES_FMT_INT},
154+ {"+CCWA: ", BTA_AG_CALL_WAIT_RES, BTA_AG_RES_FMT_STR},
155+ {"+CHLD: ", BTA_AG_IN_CALL_HELD_RES,BTA_AG_RES_FMT_STR},
156+ {"+CIND: ", BTA_AG_CIND_RES, BTA_AG_RES_FMT_STR},
157+ {"+CLIP: ", BTA_AG_LOCAL_RES_CLIP, BTA_AG_RES_FMT_STR},
158+ {"+CIEV: ", BTA_AG_IND_RES, BTA_AG_RES_FMT_STR},
159+ {"+BINP: ", BTA_AG_BINP_RES, BTA_AG_RES_FMT_STR},
160+ {"+BVRA: ", BTA_AG_BVRA_RES, BTA_AG_RES_FMT_INT},
161+ {"+BRSF: ", BTA_AG_LOCAL_RES_BRSF, BTA_AG_RES_FMT_INT},
162+ {"+BSIR: ", BTA_AG_INBAND_RING_RES, BTA_AG_RES_FMT_INT},
163+ {"+CNUM: ", BTA_AG_CNUM_RES, BTA_AG_RES_FMT_STR},
164+ {"+BTRH: ", BTA_AG_BTRH_RES, BTA_AG_RES_FMT_INT},
165+ {"+CLCC: ", BTA_AG_CLCC_RES, BTA_AG_RES_FMT_STR},
166+ {"+COPS: ", BTA_AG_COPS_RES, BTA_AG_RES_FMT_STR},
167+ {"+CME ERROR: ", BTA_AG_LOCAL_RES_CMEE, BTA_AG_RES_FMT_INT},
168+ {"+BCS: ", BTA_AG_LOCAL_RES_BCS, BTA_AG_RES_FMT_INT},
169+ {"+BIND: ", BTA_AG_BIND_RES, BTA_AG_RES_FMT_STR},
170+ {"", BTA_AG_UNAT_RES, BTA_AG_RES_FMT_STR}
233171 };
234172
173+static const tBTA_AG_RESULT* bta_ag_result_by_code(size_t code)
174+{
175+ for (size_t i = 0; i != sizeof(bta_ag_result_tbl) /
176+ sizeof(bta_ag_result_tbl[0]); ++i)
177+ {
178+ if (code == bta_ag_result_tbl[i].result_id)
179+ return &bta_ag_result_tbl[i];
180+ }
181+ return 0;
182+}
183+
235184 const tBTA_AG_AT_CMD *bta_ag_at_tbl[BTA_AG_NUM_IDX] =
236185 {
237186 bta_ag_hsp_cmd,
238187 bta_ag_hfp_cmd
239188 };
240189
241-/* callback event lookup table for HSP */
242-const tBTA_AG_EVT bta_ag_hsp_cb_evt[] =
243-{
244- BTA_AG_AT_CKPD_EVT, /* BTA_AG_HS_CMD_CKPD */
245- BTA_AG_SPK_EVT, /* BTA_AG_HS_CMD_VGS */
246- BTA_AG_MIC_EVT /* BTA_AG_HS_CMD_VGM */
247-};
248-
249-/* callback event lookup table for HFP (Indexed by command) */
250-const tBTA_AG_EVT bta_ag_hfp_cb_evt[] =
190+typedef struct
251191 {
252- BTA_AG_AT_A_EVT, /* BTA_AG_HF_CMD_A */
253- BTA_AG_AT_D_EVT, /* BTA_AG_HF_CMD_D */
254- BTA_AG_SPK_EVT, /* BTA_AG_HF_CMD_VGS */
255- BTA_AG_MIC_EVT, /* BTA_AG_HF_CMD_VGM */
256- 0, /* BTA_AG_HF_CMD_CCWA */
257- BTA_AG_AT_CHLD_EVT, /* BTA_AG_HF_CMD_CHLD */
258- BTA_AG_AT_CHUP_EVT, /* BTA_AG_HF_CMD_CHUP */
259- BTA_AG_AT_CIND_EVT, /* BTA_AG_HF_CMD_CIND */
260- 0, /* BTA_AG_HF_CMD_CLIP */
261- 0, /* BTA_AG_HF_CMD_CMER */
262- BTA_AG_AT_VTS_EVT, /* BTA_AG_HF_CMD_VTS */
263- BTA_AG_AT_BINP_EVT, /* BTA_AG_HF_CMD_BINP */
264- BTA_AG_AT_BLDN_EVT, /* BTA_AG_HF_CMD_BLDN */
265- BTA_AG_AT_BVRA_EVT, /* BTA_AG_HF_CMD_BVRA */
266- 0, /* BTA_AG_HF_CMD_BRSF */
267- BTA_AG_AT_NREC_EVT, /* BTA_AG_HF_CMD_NREC */
268- BTA_AG_AT_CNUM_EVT, /* BTA_AG_HF_CMD_CNUM */
269- BTA_AG_AT_BTRH_EVT, /* BTA_AG_HF_CMD_BTRH */
270- BTA_AG_AT_CLCC_EVT, /* BTA_AG_HF_CMD_CLCC */
271- BTA_AG_AT_COPS_EVT, /* BTA_AG_HF_CMD_COPS */
272- 0, /* BTA_AG_HF_CMD_CMEE */
273- 0, /* BTA_AG_HF_CMD_BIA */
274- BTA_AG_AT_CBC_EVT, /* BTA_AG_HF_CMD_CBC */
275- 0, /* BTA_AG_HF_CMD_BCC */
276- BTA_AG_AT_BCS_EVT, /* BTA_AG_HF_CMD_BCS */
277- BTA_AG_AT_BIND_EVT, /* BTA_AG_HF_CMD_BIND */
278- BTA_AG_AT_BIEV_EVT, /* BTA_AG_HF_CMD_BIEV */
279- BTA_AG_AT_BAC_EVT /* BTA_AG_HF_CMD_BAC */
280-};
192+ size_t result_code;
193+ size_t indicator;
194+} tBTA_AG_INDICATOR_MAP;
281195
282-/* translation of API result code values to internal values */
283-const UINT8 bta_ag_trans_result[] =
196+/* callsetup indicator value lookup table */
197+const tBTA_AG_INDICATOR_MAP callsetup_indicator_map[] =
284198 {
285- BTA_AG_RES_VGS, /* BTA_AG_SPK_RES */
286- BTA_AG_RES_VGM, /* BTA_AG_MIC_RES */
287- BTA_AG_RES_BSIR, /* BTA_AG_INBAND_RING_RES */
288- BTA_AG_RES_CIND, /* BTA_AG_CIND_RES */
289- BTA_AG_RES_BINP, /* BTA_AG_BINP_RES */
290- BTA_AG_RES_CIEV, /* BTA_AG_IND_RES */
291- BTA_AG_RES_BVRA, /* BTA_AG_BVRA_RES */
292- BTA_AG_RES_CNUM, /* BTA_AG_CNUM_RES */
293- BTA_AG_RES_BTRH, /* BTA_AG_BTRH_RES */
294- BTA_AG_RES_CLCC, /* BTA_AG_CLCC_RES */
295- BTA_AG_RES_COPS, /* BTA_AG_COPS_RES */
296- 0, /* BTA_AG_IN_CALL_RES */
297- 0, /* BTA_AG_IN_CALL_CONN_RES */
298- BTA_AG_RES_CCWA, /* BTA_AG_CALL_WAIT_RES */
299- 0, /* BTA_AG_OUT_CALL_ORIG_RES */
300- 0, /* BTA_AG_OUT_CALL_ALERT_RES */
301- 0, /* BTA_AG_OUT_CALL_CONN_RES */
302- 0, /* BTA_AG_CALL_CANCEL_RES */
303- 0, /* BTA_AG_END_CALL_RES */
304- 0, /* BTA_AG_IN_CALL_HELD_RES */
305- BTA_AG_RES_BIND, /* BTA_AG_BIND_RES */
306- BTA_AG_RES_UNAT /* BTA_AG_UNAT_RES */
199+ {BTA_AG_IN_CALL_RES, BTA_AG_CALLSETUP_INCOMING},
200+ {BTA_AG_CALL_WAIT_RES, BTA_AG_CALLSETUP_INCOMING},
201+ {BTA_AG_OUT_CALL_ORIG_RES, BTA_AG_CALLSETUP_OUTGOING},
202+ {BTA_AG_OUT_CALL_ALERT_RES, BTA_AG_CALLSETUP_ALERTING}
307203 };
308204
309-/* callsetup indicator value lookup table */
310-const UINT8 bta_ag_callsetup_ind_tbl[] =
205+static size_t bta_ag_indicator_by_result_code(size_t code)
311206 {
312- 0, /* BTA_AG_SPK_RES */
313- 0, /* BTA_AG_MIC_RES */
314- 0, /* BTA_AG_INBAND_RING_RES */
315- 0, /* BTA_AG_CIND_RES */
316- 0, /* BTA_AG_BINP_RES */
317- 0, /* BTA_AG_IND_RES */
318- 0, /* BTA_AG_BVRA_RES */
319- 0, /* BTA_AG_CNUM_RES */
320- 0, /* BTA_AG_BTRH_RES */
321- 0, /* BTA_AG_CLCC_RES */
322- 0, /* BTA_AG_COPS_RES */
323- BTA_AG_CALLSETUP_INCOMING, /* BTA_AG_IN_CALL_RES */
324- BTA_AG_CALLSETUP_NONE, /* BTA_AG_IN_CALL_CONN_RES */
325- BTA_AG_CALLSETUP_INCOMING, /* BTA_AG_CALL_WAIT_RES */
326- BTA_AG_CALLSETUP_OUTGOING, /* BTA_AG_OUT_CALL_ORIG_RES */
327- BTA_AG_CALLSETUP_ALERTING, /* BTA_AG_OUT_CALL_ALERT_RES */
328- BTA_AG_CALLSETUP_NONE, /* BTA_AG_OUT_CALL_CONN_RES */
329- BTA_AG_CALLSETUP_NONE, /* BTA_AG_CALL_CANCEL_RES */
330- BTA_AG_CALLSETUP_NONE, /* BTA_AG_END_CALL_RES */
331- BTA_AG_CALLSETUP_NONE, /* BTA_AG_IN_CALL_HELD_RES */
332- 0 /* BTA_AG_BIND_RES */
333-};
207+ for (size_t i = 0; i != sizeof(callsetup_indicator_map) /
208+ sizeof(callsetup_indicator_map[0]); ++i)
209+ {
210+ if (code == callsetup_indicator_map[i].result_code)
211+ return callsetup_indicator_map[i].indicator;
212+ }
213+ return BTA_AG_CALLSETUP_NONE;
214+}
334215
335216 /*******************************************************************************
336217 **
@@ -342,49 +223,50 @@ const UINT8 bta_ag_callsetup_ind_tbl[] =
342223 ** Returns void
343224 **
344225 *******************************************************************************/
345-static void bta_ag_send_result(tBTA_AG_SCB *p_scb, UINT8 code, char *p_arg,
226+static void bta_ag_send_result(tBTA_AG_SCB *p_scb, size_t code, char *p_arg,
346227 INT16 int_arg)
347228 {
348- char buf[BTA_AG_AT_MAX_LEN + 16];
349- char *p = buf;
350- UINT16 len;
229+ const tBTA_AG_RESULT *result = bta_ag_result_by_code(code);
230+ if (result == 0)
231+ {
232+ LOG_ERROR(LOG_TAG, "%s Unable to lookup result for code %zu", __func__, code);
233+ return;
234+ }
235+
236+ char buf[BTA_AG_AT_MAX_LEN + 16];
237+ char *p = buf;
238+ memset(buf, 0, sizeof(buf));
351239
352-#if defined(BTA_AG_RESULT_DEBUG) && (BTA_AG_RESULT_DEBUG == TRUE)
353- memset(buf, NULL, sizeof(buf));
354-#endif
355240 /* init with \r\n */
356241 *p++ = '\r';
357242 *p++ = '\n';
358243
359244 /* copy result code string */
360- strlcpy(p, bta_ag_result_tbl[code].p_res, sizeof(buf) - 2);
361-#if defined(BTA_HSP_RESULT_REPLACE_COLON) && (BTA_HSP_RESULT_REPLACE_COLON == TRUE)
362- if(p_scb->conn_service == BTA_AG_HSP)
245+ strlcpy(p, result->result_string, sizeof(buf) - 2);
246+
247+ if (p_scb->conn_service == BTA_AG_HSP)
363248 {
364249 /* If HSP then ":"symbol should be changed as "=" for HSP compatibility */
365250 switch(code)
366251 {
367- case BTA_AG_RES_VGS:
368- case BTA_AG_RES_VGM:
252+ case BTA_AG_SPK_RES:
253+ case BTA_AG_MIC_RES:
369254 if(*(p+COLON_IDX_4_VGSVGM) == ':')
370255 {
371- #if defined(BTA_AG_RESULT_DEBUG) && (BTA_AG_RESULT_DEBUG == TRUE)
372- APPL_TRACE_DEBUG("[HSP] ':'symbol is changed as '=' for HSP compatibility");
373- #endif
374256 *(p+COLON_IDX_4_VGSVGM) = '=';
375257 }
376258 break;
377259 }
378260 }
379-#endif
380- p += strlen(bta_ag_result_tbl[code].p_res);
261+
262+ p += strlen(result->result_string);
381263
382264 /* copy argument if any */
383- if (bta_ag_result_tbl[code].fmt == BTA_AG_RES_FMT_INT)
265+ if (result->arg_type == BTA_AG_RES_FMT_INT)
384266 {
385267 p += utl_itoa((UINT16) int_arg, p);
386268 }
387- else if (bta_ag_result_tbl[code].fmt == BTA_AG_RES_FMT_STR)
269+ else if (result->arg_type == BTA_AG_RES_FMT_STR)
388270 {
389271 strcpy(p, p_arg);
390272 p += strlen(p_arg);
@@ -394,78 +276,10 @@ static void bta_ag_send_result(tBTA_AG_SCB *p_scb, UINT8 code, char *p_arg,
394276 *p++ = '\r';
395277 *p++ = '\n';
396278
397-#if defined(BTA_AG_RESULT_DEBUG) && (BTA_AG_RESULT_DEBUG == TRUE)
398- APPL_TRACE_DEBUG("bta_ag_send_result: %s", buf);
399-#endif
400-
401- /* send to RFCOMM */
402- PORT_WriteData(p_scb->conn_handle, buf, (UINT16) (p - buf), &len);
403-}
404-
405-#if defined(BTA_AG_MULTI_RESULT_INCLUDED) && (BTA_AG_MULTI_RESULT_INCLUDED == TRUE)
406-/*******************************************************************************
407-**
408-** Function bta_ag_send_multi_result
409-**
410-** Description Send multiple AT result codes.
411-**
412-**
413-** Returns void
414-**
415-*******************************************************************************/
416-static void bta_ag_send_multi_result(tBTA_AG_SCB *p_scb, tBTA_AG_MULTI_RESULT_CB *m_res_cb)
417-{
418- char buf[BTA_AG_AT_MAX_LEN * BTA_AG_AT_MULTI_LEN + 16];
419- char *p = buf;
420- UINT16 len;
421- UINT8 res_idx = 0;
422-
423- if((!m_res_cb) || (m_res_cb->num_result == 0) || (m_res_cb->num_result > BTA_AG_AT_MULTI_LEN))
424- {
425- APPL_TRACE_DEBUG("m_res_cb is NULL or num_result is out of range.");
426- return;
427- }
428-
429-#if defined(BTA_AG_RESULT_DEBUG) && (BTA_AG_RESULT_DEBUG == TRUE)
430- memset(buf, NULL, sizeof(buf));
431-#endif
432-
433- while(res_idx < m_res_cb->num_result)
434- {
435- /* init with \r\n */
436- *p++ = '\r';
437- *p++ = '\n';
438-
439- /* copy result code string */
440- strcpy(p, bta_ag_result_tbl[m_res_cb->res_cb[res_idx].code].p_res);
441- p += strlen(bta_ag_result_tbl[m_res_cb->res_cb[res_idx].code].p_res);
442-
443- /* copy argument if any */
444- if (bta_ag_result_tbl[m_res_cb->res_cb[res_idx].code].fmt == BTA_AG_RES_FMT_INT)
445- {
446- p += utl_itoa((UINT16) m_res_cb->res_cb[res_idx].int_arg, p);
447- }
448- else if (bta_ag_result_tbl[m_res_cb->res_cb[res_idx].code].fmt == BTA_AG_RES_FMT_STR)
449- {
450- strcpy(p, m_res_cb->res_cb[res_idx].p_arg);
451- p += strlen(m_res_cb->res_cb[res_idx].p_arg);
452- }
453-
454- /* finish with \r\n */
455- *p++ = '\r';
456- *p++ = '\n';
457-
458- res_idx++;
459- }
460-
461-#if defined(BTA_AG_RESULT_DEBUG) && (BTA_AG_RESULT_DEBUG == TRUE)
462- APPL_TRACE_DEBUG("send_result: %s", buf);
463-#endif
464-
465279 /* send to RFCOMM */
280+ UINT16 len = 0;
466281 PORT_WriteData(p_scb->conn_handle, buf, (UINT16) (p - buf), &len);
467282 }
468-#endif
469283
470284 /*******************************************************************************
471285 **
@@ -479,7 +293,7 @@ static void bta_ag_send_multi_result(tBTA_AG_SCB *p_scb, tBTA_AG_MULTI_RESULT_CB
479293 *******************************************************************************/
480294 static void bta_ag_send_ok(tBTA_AG_SCB *p_scb)
481295 {
482- bta_ag_send_result(p_scb, BTA_AG_RES_OK, NULL, 0);
296+ bta_ag_send_result(p_scb, BTA_AG_LOCAL_RES_OK, NULL, 0);
483297 }
484298
485299 /*******************************************************************************
@@ -497,9 +311,9 @@ static void bta_ag_send_error(tBTA_AG_SCB *p_scb, INT16 errcode)
497311 {
498312 /* If HFP and extended audio gateway error codes are enabled */
499313 if (p_scb->conn_service == BTA_AG_HFP && p_scb->cmee_enabled)
500- bta_ag_send_result(p_scb, BTA_AG_RES_CMEE, NULL, errcode);
314+ bta_ag_send_result(p_scb, BTA_AG_LOCAL_RES_CMEE, NULL, errcode);
501315 else
502- bta_ag_send_result(p_scb, BTA_AG_RES_ERROR, NULL, 0);
316+ bta_ag_send_result(p_scb, BTA_AG_LOCAL_RES_ERROR, NULL, 0);
503317 }
504318
505319 /*******************************************************************************
@@ -584,7 +398,7 @@ static void bta_ag_send_ind(tBTA_AG_SCB *p_scb, UINT16 id, UINT16 value, BOOLEAN
584398 p += utl_itoa(id, p);
585399 *p++ = ',';
586400 utl_itoa(value, p);
587- bta_ag_send_result(p_scb, BTA_AG_RES_CIEV, str, 0);
401+ bta_ag_send_result(p_scb, BTA_AG_IND_RES, str, 0);
588402 }
589403 }
590404
@@ -812,10 +626,9 @@ BOOLEAN bta_ag_inband_enabled(tBTA_AG_SCB *p_scb)
812626 void bta_ag_send_call_inds(tBTA_AG_SCB *p_scb, tBTA_AG_RES result)
813627 {
814628 UINT8 call = p_scb->call_ind;
815- UINT8 callsetup;
816629
817630 /* set new call and callsetup values based on BTA_AgResult */
818- callsetup = bta_ag_callsetup_ind_tbl[result];
631+ size_t callsetup = bta_ag_indicator_by_result_code(result);
819632
820633 if (result == BTA_AG_END_CALL_RES)
821634 {
@@ -846,24 +659,22 @@ void bta_ag_send_call_inds(tBTA_AG_SCB *p_scb, tBTA_AG_RES result)
846659 ** Returns void
847660 **
848661 *******************************************************************************/
849-void bta_ag_at_hsp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
662+void bta_ag_at_hsp_cback(tBTA_AG_SCB *p_scb, UINT16 command_id, UINT8 arg_type,
850663 char *p_arg, INT16 int_arg)
851664 {
852- tBTA_AG_VAL val;
853-
854- APPL_TRACE_DEBUG("AT cmd:%d arg_type:%d arg:%d arg:%s", cmd, arg_type,
665+ APPL_TRACE_DEBUG("AT cmd:%d arg_type:%d arg:%d arg:%s", command_id, arg_type,
855666 int_arg, p_arg);
856667
857- /* send OK */
858668 bta_ag_send_ok(p_scb);
859669
670+ tBTA_AG_VAL val;
860671 val.hdr.handle = bta_ag_scb_to_idx(p_scb);
861672 val.hdr.app_id = p_scb->app_id;
862673 val.num = (UINT16) int_arg;
863674 strlcpy(val.str, p_arg, BTA_AG_AT_MAX_LEN);
864675
865676 /* call callback with event */
866- (*bta_ag_cb.p_cback)(bta_ag_hsp_cb_evt[cmd], (tBTA_AG *) &val);
677+ (*bta_ag_cb.p_cback)(command_id, (tBTA_AG *) &val);
867678 }
868679
869680 /*******************************************************************************
@@ -980,7 +791,7 @@ static void bta_ag_bind_response(tBTA_AG_SCB *p_scb, uint8_t arg_type)
980791
981792 buffer[index++] = ')';
982793
983- bta_ag_send_result(p_scb, BTA_AG_RES_BIND, buffer, 0);
794+ bta_ag_send_result(p_scb, BTA_AG_BIND_RES, buffer, 0);
984795 bta_ag_send_ok(p_scb);
985796 }
986797 else if (arg_type == BTA_AG_AT_READ)
@@ -1012,7 +823,7 @@ static void bta_ag_bind_response(tBTA_AG_SCB *p_scb, uint8_t arg_type)
1012823 *p++ = ',';
1013824 p += utl_itoa((uint16_t) p_scb->local_hf_indicators[i].is_enable, p);
1014825
1015- bta_ag_send_result(p_scb, BTA_AG_RES_BIND, buffer, 0);
826+ bta_ag_send_result(p_scb, BTA_AG_BIND_RES, buffer, 0);
1016827
1017828 memset(buffer, 0, sizeof(buffer));
1018829 p = buffer;
@@ -1096,7 +907,6 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
1096907 char *p_arg, INT16 int_arg)
1097908 {
1098909 tBTA_AG_VAL val;
1099- tBTA_AG_EVT event;
1100910 tBTA_AG_SCB *ag_scb;
1101911 UINT32 i, ind_id;
1102912 UINT32 bia_masked_out;
@@ -1120,25 +930,33 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
1120930 bdcpy(val.bd_addr, p_scb->peer_addr);
1121931 strlcpy(val.str, p_arg, BTA_AG_AT_MAX_LEN);
1122932
1123- event = bta_ag_hfp_cb_evt[cmd];
933+ /**
934+ * Unless this this is a local event, by default we'll forward
935+ * the event code to the application.
936+ * If |event| is 0 at the end of this function, the application
937+ * callback is NOT invoked.
938+ */
939+ tBTA_AG_EVT event = 0;
940+ if (cmd < BTA_AG_LOCAL_EVT_FIRST)
941+ event = cmd;
1124942
1125943 switch (cmd)
1126944 {
1127- case BTA_AG_HF_CMD_A:
1128- case BTA_AG_HF_CMD_VGS:
1129- case BTA_AG_HF_CMD_VGM:
1130- case BTA_AG_HF_CMD_CHUP:
1131- case BTA_AG_HF_CMD_CBC:
945+ case BTA_AG_AT_A_EVT:
946+ case BTA_AG_SPK_EVT:
947+ case BTA_AG_MIC_EVT:
948+ case BTA_AG_AT_CHUP_EVT:
949+ case BTA_AG_AT_CBC_EVT:
1132950 /* send OK */
1133951 bta_ag_send_ok(p_scb);
1134952 break;
1135953
1136- case BTA_AG_HF_CMD_BLDN:
954+ case BTA_AG_AT_BLDN_EVT:
1137955 /* Do not send OK, App will send error or OK depending on
1138956 ** last dial number enabled or not */
1139957 break;
1140958
1141- case BTA_AG_HF_CMD_D:
959+ case BTA_AG_AT_D_EVT:
1142960 /* Do not send OK for Dial cmds
1143961 ** Let application decide whether to send OK or ERROR*/
1144962
@@ -1172,7 +990,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
1172990 }
1173991 break;
1174992
1175- case BTA_AG_HF_CMD_CCWA:
993+ case BTA_AG_LOCAL_EVT_CCWA:
1176994 /* store setting */
1177995 p_scb->ccwa_enabled = (BOOLEAN) int_arg;
1178996
@@ -1180,7 +998,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
1180998 bta_ag_send_ok(p_scb);
1181999 break;
11821000
1183- case BTA_AG_HF_CMD_CHLD:
1001+ case BTA_AG_AT_CHLD_EVT:
11841002 if (arg_type == BTA_AG_AT_TEST)
11851003 {
11861004 /* don't call callback */
@@ -1191,16 +1009,17 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
11911009 if ((p_scb->peer_version >= HFP_VERSION_1_5) &&
11921010 (p_scb->features & BTA_AG_FEAT_ECC) &&
11931011 (p_scb->peer_features & BTA_AG_PEER_FEAT_ECC))
1194- bta_ag_send_result(p_scb, BTA_AG_RES_CHLD, p_bta_ag_cfg->chld_val_ecc, 0);
1012+ bta_ag_send_result(p_scb, BTA_AG_IN_CALL_HELD_RES,
1013+ p_bta_ag_cfg->chld_val_ecc, 0);
11951014 else
1196- bta_ag_send_result(p_scb, BTA_AG_RES_CHLD, p_bta_ag_cfg->chld_val, 0);
1015+ bta_ag_send_result(p_scb, BTA_AG_IN_CALL_HELD_RES,
1016+ p_bta_ag_cfg->chld_val, 0);
11971017
11981018 /* send OK */
11991019 bta_ag_send_ok(p_scb);
12001020
12011021 /* if service level conn. not already open, now it's open */
12021022 bta_ag_svc_conn_open(p_scb, NULL);
1203-
12041023 }
12051024 else
12061025 {
@@ -1244,8 +1063,8 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
12441063 }
12451064 break;
12461065
1247- case BTA_AG_HF_CMD_BIND:
1248- APPL_TRACE_DEBUG("%s BTA_AG_HF_CMD_BIND arg_type: %d", __func__, arg_type);
1066+ case BTA_AG_AT_BIND_EVT:
1067+ APPL_TRACE_DEBUG("%s BTA_AG_AT_BIND_EVT arg_type: %d", __func__, arg_type);
12491068 if (arg_type == BTA_AG_AT_SET)
12501069 {
12511070 if (bta_ag_parse_bind_set(p_scb, val))
@@ -1264,7 +1083,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
12641083 }
12651084 break;
12661085
1267- case BTA_AG_HF_CMD_BIEV:
1086+ case BTA_AG_AT_BIEV_EVT:
12681087 if (bta_ag_parse_biev_response(p_scb, &val))
12691088 {
12701089 bta_ag_send_ok(p_scb);
@@ -1275,25 +1094,25 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
12751094 }
12761095 break;
12771096
1278- case BTA_AG_HF_CMD_CIND:
1097+ case BTA_AG_AT_CIND_EVT:
12791098 if (arg_type == BTA_AG_AT_TEST)
12801099 {
12811100 /* don't call callback */
12821101 event = 0;
12831102
12841103 /* send CIND string, send OK */
1285- bta_ag_send_result(p_scb, BTA_AG_RES_CIND, p_bta_ag_cfg->cind_info, 0);
1104+ bta_ag_send_result(p_scb, BTA_AG_CIND_RES, p_bta_ag_cfg->cind_info, 0);
12861105 bta_ag_send_ok(p_scb);
12871106 }
12881107 break;
12891108
1290- case BTA_AG_HF_CMD_CLIP:
1109+ case BTA_AG_LOCAL_EVT_CLIP:
12911110 /* store setting, send OK */
12921111 p_scb->clip_enabled = (BOOLEAN) int_arg;
12931112 bta_ag_send_ok(p_scb);
12941113 break;
12951114
1296- case BTA_AG_HF_CMD_CMER:
1115+ case BTA_AG_LOCAL_EVT_CMER:
12971116 /* if parsed ok store setting, send OK */
12981117 if (bta_ag_parse_cmer(p_arg, &p_scb->cmer_enabled))
12991118 {
@@ -1314,7 +1133,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
13141133 }
13151134 break;
13161135
1317- case BTA_AG_HF_CMD_VTS:
1136+ case BTA_AG_AT_VTS_EVT:
13181137 /* check argument */
13191138 if (strlen(p_arg) == 1)
13201139 {
@@ -1327,7 +1146,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
13271146 }
13281147 break;
13291148
1330- case BTA_AG_HF_CMD_BINP:
1149+ case BTA_AG_AT_BINP_EVT:
13311150 /* if feature not set don't call callback, send ERROR */
13321151 if (!(p_scb->features & BTA_AG_FEAT_VTAG))
13331152 {
@@ -1336,7 +1155,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
13361155 }
13371156 break;
13381157
1339- case BTA_AG_HF_CMD_BVRA:
1158+ case BTA_AG_AT_BVRA_EVT:
13401159 /* if feature not supported don't call callback, send ERROR. App will send OK */
13411160 if (!(p_scb->features & BTA_AG_FEAT_VREC))
13421161 {
@@ -1345,7 +1164,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
13451164 }
13461165 break;
13471166
1348- case BTA_AG_HF_CMD_BRSF:
1167+ case BTA_AG_LOCAL_EVT_BRSF:
13491168 {
13501169 /* store peer features */
13511170 p_scb->peer_features = (uint16_t) int_arg;
@@ -1360,12 +1179,12 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
13601179 p_scb->peer_features, features);
13611180
13621181 /* send BRSF, send OK */
1363- bta_ag_send_result(p_scb, BTA_AG_RES_BRSF, NULL, (int16_t) features);
1182+ bta_ag_send_result(p_scb, BTA_AG_LOCAL_RES_BRSF, NULL, (int16_t)features);
13641183 bta_ag_send_ok(p_scb);
13651184 break;
13661185 }
13671186
1368- case BTA_AG_HF_CMD_NREC:
1187+ case BTA_AG_AT_NREC_EVT:
13691188 /* if feature send OK, else don't call callback, send ERROR */
13701189 if (p_scb->features & BTA_AG_FEAT_ECNR)
13711190 {
@@ -1378,7 +1197,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
13781197 }
13791198 break;
13801199
1381- case BTA_AG_HF_CMD_BTRH:
1200+ case BTA_AG_AT_BTRH_EVT:
13821201 /* if feature send BTRH, send OK:, else don't call callback, send ERROR */
13831202 if (p_scb->features & BTA_AG_FEAT_BTRH)
13841203 {
@@ -1389,7 +1208,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
13891208 {
13901209 if (ag_scb->in_use)
13911210 {
1392- bta_ag_send_result(ag_scb, BTA_AG_RES_BTRH, NULL, int_arg);
1211+ bta_ag_send_result(ag_scb, BTA_AG_BTRH_RES, NULL, int_arg);
13931212 }
13941213 }
13951214 bta_ag_send_ok(p_scb);
@@ -1406,7 +1225,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
14061225 }
14071226 break;
14081227
1409- case BTA_AG_HF_CMD_COPS:
1228+ case BTA_AG_AT_COPS_EVT:
14101229 if (arg_type == BTA_AG_AT_SET)
14111230 {
14121231 /* don't call callback */
@@ -1417,7 +1236,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
14171236 }
14181237 break;
14191238
1420- case BTA_AG_HF_CMD_CMEE:
1239+ case BTA_AG_LOCAL_EVT_CMEE:
14211240 if (p_scb->features & BTA_AG_FEAT_EXTERR)
14221241 {
14231242 /* store setting */
@@ -1434,7 +1253,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
14341253 event = 0;
14351254 break;
14361255
1437- case BTA_AG_HF_CMD_BIA:
1256+ case BTA_AG_LOCAL_EVT_BIA:
14381257 /* don't call callback */
14391258 event = 0;
14401259
@@ -1466,9 +1285,10 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
14661285 bta_ag_send_error (p_scb, BTA_AG_ERR_INVALID_INDEX);
14671286 break;
14681287
1469- case BTA_AG_HF_CMD_CNUM:
1288+ case BTA_AG_AT_CNUM_EVT:
14701289 break;
1471- case BTA_AG_HF_CMD_CLCC:
1290+
1291+ case BTA_AG_AT_CLCC_EVT:
14721292 if(!(p_scb->features & BTA_AG_FEAT_ECS))
14731293 {
14741294 event = 0;
@@ -1477,7 +1297,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
14771297 break;
14781298
14791299 #if (BTM_WBS_INCLUDED == TRUE )
1480- case BTA_AG_HF_CMD_BAC:
1300+ case BTA_AG_AT_BAC_EVT:
14811301 bta_ag_send_ok(p_scb);
14821302
14831303 /* store available codecs from the peer */
@@ -1513,7 +1333,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
15131333 }
15141334 break;
15151335
1516- case BTA_AG_HF_CMD_BCS:
1336+ case BTA_AG_AT_BCS_EVT:
15171337 bta_ag_send_ok(p_scb);
15181338 alarm_cancel(p_scb->codec_negotiation_timer);
15191339
@@ -1541,7 +1361,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB *p_scb, UINT16 cmd, UINT8 arg_type,
15411361 val.num = codec_sent;
15421362 break;
15431363
1544- case BTA_AG_HF_CMD_BCC:
1364+ case BTA_AG_LOCAL_EVT_BCC:
15451365 bta_ag_send_ok(p_scb);
15461366 bta_ag_sco_open(p_scb, NULL);
15471367 break;
@@ -1608,15 +1428,13 @@ void bta_ag_at_err_cback(tBTA_AG_SCB *p_scb, BOOLEAN unknown, char *p_arg)
16081428 *******************************************************************************/
16091429 void bta_ag_hsp_result(tBTA_AG_SCB *p_scb, tBTA_AG_API_RESULT *p_result)
16101430 {
1611- UINT8 code = bta_ag_trans_result[p_result->result];
1612-
16131431 APPL_TRACE_DEBUG("bta_ag_hsp_result : res = %d", p_result->result);
16141432
16151433 switch(p_result->result)
16161434 {
16171435 case BTA_AG_SPK_RES:
16181436 case BTA_AG_MIC_RES:
1619- bta_ag_send_result(p_scb, code, NULL, p_result->data.num);
1437+ bta_ag_send_result(p_scb, p_result->result, NULL, p_result->data.num);
16201438 break;
16211439
16221440 case BTA_AG_IN_CALL_RES:
@@ -1690,7 +1508,7 @@ void bta_ag_hsp_result(tBTA_AG_SCB *p_scb, tBTA_AG_API_RESULT *p_result)
16901508 {
16911509 if (p_result->data.str[0] != 0)
16921510 {
1693- bta_ag_send_result(p_scb, code, p_result->data.str, 0);
1511+ bta_ag_send_result(p_scb, p_result->result, p_result->data.str, 0);
16941512 }
16951513
16961514 if (p_result->data.ok_flag == BTA_AG_OK_DONE)
@@ -1720,14 +1538,13 @@ void bta_ag_hsp_result(tBTA_AG_SCB *p_scb, tBTA_AG_API_RESULT *p_result)
17201538 *******************************************************************************/
17211539 void bta_ag_hfp_result(tBTA_AG_SCB *p_scb, tBTA_AG_API_RESULT *p_result)
17221540 {
1723- UINT8 code = bta_ag_trans_result[p_result->result];
17241541 APPL_TRACE_DEBUG("bta_ag_hfp_result : res = %d", p_result->result);
17251542
17261543 switch(p_result->result)
17271544 {
17281545 case BTA_AG_SPK_RES:
17291546 case BTA_AG_MIC_RES:
1730- bta_ag_send_result(p_scb, code, NULL, p_result->data.num);
1547+ bta_ag_send_result(p_scb, p_result->result, NULL, p_result->data.num);
17311548 break;
17321549
17331550 case BTA_AG_IN_CALL_RES:
@@ -1884,7 +1701,7 @@ void bta_ag_hfp_result(tBTA_AG_SCB *p_scb, tBTA_AG_API_RESULT *p_result)
18841701 case BTA_AG_INBAND_RING_RES:
18851702 p_scb->inband_enabled = p_result->data.state;
18861703 APPL_TRACE_DEBUG("inband_enabled set to %d", p_scb->inband_enabled);
1887- bta_ag_send_result(p_scb, code, NULL, p_result->data.state);
1704+ bta_ag_send_result(p_scb, p_result->result, NULL, p_result->data.state);
18881705 break;
18891706
18901707 case BTA_AG_CIND_RES:
@@ -1898,7 +1715,7 @@ void bta_ag_hfp_result(tBTA_AG_SCB *p_scb, tBTA_AG_API_RESULT *p_result)
18981715 p_scb->callheld_ind = p_result->data.str[12] - '0';
18991716 APPL_TRACE_DEBUG("cind call:%d callsetup:%d", p_scb->call_ind, p_scb->callsetup_ind);
19001717
1901- bta_ag_send_result(p_scb, code, p_result->data.str, 0);
1718+ bta_ag_send_result(p_scb, p_result->result, p_result->data.str, 0);
19021719 bta_ag_send_ok(p_scb);
19031720 break;
19041721
@@ -1910,7 +1727,7 @@ void bta_ag_hfp_result(tBTA_AG_SCB *p_scb, tBTA_AG_API_RESULT *p_result)
19101727 {
19111728 if (p_result->data.str[0] != 0)
19121729 {
1913- bta_ag_send_result(p_scb, code, p_result->data.str, 0);
1730+ bta_ag_send_result(p_scb, p_result->result, p_result->data.str, 0);
19141731 }
19151732
19161733 if (p_result->data.ok_flag == BTA_AG_OK_DONE)
@@ -1930,7 +1747,7 @@ void bta_ag_hfp_result(tBTA_AG_SCB *p_scb, tBTA_AG_API_RESULT *p_result)
19301747 {
19311748 bta_ag_process_unat_res(p_result->data.str);
19321749 APPL_TRACE_DEBUG("BTA_AG_RES :%s",p_result->data.str);
1933- bta_ag_send_result(p_scb, code, p_result->data.str, 0);
1750+ bta_ag_send_result(p_scb, p_result->result, p_result->data.str, 0);
19341751 }
19351752
19361753 if (p_result->data.ok_flag == BTA_AG_OK_DONE)
@@ -1945,7 +1762,7 @@ void bta_ag_hfp_result(tBTA_AG_SCB *p_scb, tBTA_AG_API_RESULT *p_result)
19451762 case BTA_AG_CALL_WAIT_RES:
19461763 if (p_scb->ccwa_enabled)
19471764 {
1948- bta_ag_send_result(p_scb, code, p_result->data.str, 0);
1765+ bta_ag_send_result(p_scb, p_result->result, p_result->data.str, 0);
19491766 }
19501767 bta_ag_send_call_inds(p_scb, p_result->result);
19511768 break;
@@ -1955,7 +1772,7 @@ void bta_ag_hfp_result(tBTA_AG_SCB *p_scb, tBTA_AG_API_RESULT *p_result)
19551772 break;
19561773
19571774 case BTA_AG_BVRA_RES:
1958- bta_ag_send_result(p_scb, code, NULL, p_result->data.state);
1775+ bta_ag_send_result(p_scb, p_result->result, NULL, p_result->data.state);
19591776 break;
19601777
19611778 case BTA_AG_BTRH_RES:
@@ -1964,7 +1781,7 @@ void bta_ag_hfp_result(tBTA_AG_SCB *p_scb, tBTA_AG_API_RESULT *p_result)
19641781 /* Don't respond to read if not in response & hold state */
19651782 if (p_result->data.num != BTA_AG_BTRH_NO_RESP)
19661783 {
1967- bta_ag_send_result(p_scb, code, NULL, p_result->data.num);
1784+ bta_ag_send_result(p_scb, p_result->result, NULL, p_result->data.num);
19681785 }
19691786
19701787 /* In case of a response to a read request we need to send OK */
@@ -2010,7 +1827,7 @@ void bta_ag_hfp_result(tBTA_AG_SCB *p_scb, tBTA_AG_API_RESULT *p_result)
20101827 *p++ = ',';
20111828 p += utl_itoa(p_scb->local_hf_indicators[local_index].is_enable, p);
20121829
2013- bta_ag_send_result(p_scb, code, buffer, 0);
1830+ bta_ag_send_result(p_scb, p_result->result, buffer, 0);
20141831 } else {
20151832 APPL_TRACE_DEBUG("%s HF Indicator %d already %s", p_result->data.ind.id,
20161833 (p_result->data.ind.on_demand == true) ? "Enabled" : "Disabled");
@@ -2080,7 +1897,7 @@ void bta_ag_send_bcs(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data)
20801897
20811898 /* send +BCS */
20821899 APPL_TRACE_DEBUG("send +BCS codec is %d", codec_uuid);
2083- bta_ag_send_result(p_scb, BTA_AG_RES_BCS, NULL, codec_uuid);
1900+ bta_ag_send_result(p_scb, BTA_AG_LOCAL_RES_BCS, NULL, codec_uuid);
20841901
20851902 }
20861903 #endif
@@ -2099,34 +1916,14 @@ void bta_ag_send_ring(tBTA_AG_SCB *p_scb, tBTA_AG_DATA *p_data)
20991916 {
21001917 UNUSED(p_data);
21011918
2102-#if defined(BTA_AG_MULTI_RESULT_INCLUDED) && (BTA_AG_MULTI_RESULT_INCLUDED == TRUE)
2103- tBTA_AG_MULTI_RESULT_CB m_res_cb;
2104-
2105- if (p_scb->conn_service == BTA_AG_HFP && p_scb->clip_enabled && p_scb->clip[0] != 0)
2106- {
2107- memset(&m_res_cb, NULL, sizeof(tBTA_AG_MULTI_RESULT_CB));
2108-
2109- m_res_cb.num_result = 2;
2110- AT_SET_RES_CB(m_res_cb.res_cb[0], BTA_AG_RES_RING, NULL, 0)
2111- AT_SET_RES_CB(m_res_cb.res_cb[1], BTA_AG_RES_CLIP, p_scb->clip, 0)
2112-
2113- bta_ag_send_multi_result(p_scb, &m_res_cb);
2114- }
2115- else
2116- {
2117- /* send RING ONLY */
2118- bta_ag_send_result(p_scb, BTA_AG_RES_RING, NULL, 0);
2119- }
2120-#else
21211919 /* send RING */
2122- bta_ag_send_result(p_scb, BTA_AG_RES_RING, NULL, 0);
1920+ bta_ag_send_result(p_scb, BTA_AG_LOCAL_RES_RING, NULL, 0);
21231921
21241922 /* if HFP and clip enabled and clip data send CLIP */
21251923 if (p_scb->conn_service == BTA_AG_HFP && p_scb->clip_enabled && p_scb->clip[0] != 0)
21261924 {
2127- bta_ag_send_result(p_scb, BTA_AG_RES_CLIP, p_scb->clip, 0);
1925+ bta_ag_send_result(p_scb, BTA_AG_LOCAL_RES_CLIP, p_scb->clip, 0);
21281926 }
2129-#endif
21301927
21311928 bta_sys_start_timer(p_scb->ring_timer, BTA_AG_RING_TIMEOUT_MS,
21321929 BTA_AG_RING_TIMEOUT_EVT, bta_ag_scb_to_idx(p_scb));
--- a/bta/ag/bta_ag_int.h
+++ b/bta/ag/bta_ag_int.h
@@ -29,16 +29,6 @@
2929 #include "bta_ag_api.h"
3030 #include "bta_ag_at.h"
3131
32-/* Send RING & CLIP in one AT cmd */
33-#ifndef BTA_AG_MULTI_RESULT_INCLUDED
34-#define BTA_AG_MULTI_RESULT_INCLUDED FALSE
35-#endif
36-
37-/* Replace : in VGS and VGM for HSP */
38-#ifndef BTA_HSP_RESULT_REPLACE_COLON
39-#define BTA_HSP_RESULT_REPLACE_COLON TRUE
40-#endif
41-
4232 /*****************************************************************************
4333 ** Constants
4434 *****************************************************************************/