1 /******************************************************************************
2 *
3 * Copyright (c) 2014 The Android Open Source Project
4 * Copyright (C) 2009-2012 Broadcom Corporation
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 ******************************************************************************/
19
20 /************************************************************************************
21 *
22 * Filename: btif_util.c
23 *
24 * Description: Miscellaneous helper functions
25 *
26 *
27 ***********************************************************************************/
28
29 #include <hardware/bluetooth.h>
30 #include <hardware/bt_hf.h>
31 #include <hardware/bt_av.h>
32 #include <netinet/in.h>
33 #include <stdio.h>
34 #include <stdlib.h>
35 #include <string.h>
36 #include <ctype.h>
37
38
39 #define LOG_TAG "BTIF_UTIL"
40 #include "btif_common.h"
41 #include "bta_api.h"
42 #include "gki.h"
43 #include "btu.h"
44 #include "bte.h"
45 #include "bd.h"
46 #include "btif_dm.h"
47 #include "btif_util.h"
48 #include "bta_ag_api.h"
49 #include "bta_av_api.h"
50 #include "bta_hh_api.h"
51 #include "bta_hf_client_api.h"
52 #include "avrc_defs.h"
53
54 /************************************************************************************
55 ** Constants & Macros
56 ************************************************************************************/
57 #define ISDIGIT(a) ((a>='0') && (a<='9'))
58 #define ISXDIGIT(a) (((a>='0') && (a<='9'))||((a>='A') && (a<='F'))||((a>='a') && (a<='f')))
59
60 /************************************************************************************
61 ** Local type definitions
62 ************************************************************************************/
63
64 /************************************************************************************
65 ** Static variables
66 ************************************************************************************/
67
68 /************************************************************************************
69 ** Static functions
70 ************************************************************************************/
71
72 /************************************************************************************
73 ** Externs
74 ************************************************************************************/
75
76 /************************************************************************************
77 ** Functions
78 ************************************************************************************/
79
80 /*****************************************************************************
81 ** Logging helper functions
82 *****************************************************************************/
83
str2bd(char * str,bt_bdaddr_t * addr)84 int str2bd(char *str, bt_bdaddr_t *addr)
85 {
86 int32_t i = 0;
87 for (i = 0; i < 6; i++) {
88 addr->address[i] = (uint8_t)strtoul(str, &str, 16);
89 str++;
90 }
91 return 0;
92 }
93
bd2str(const bt_bdaddr_t * bdaddr,bdstr_t * bdstr)94 char *bd2str(const bt_bdaddr_t *bdaddr, bdstr_t *bdstr)
95 {
96 const uint8_t *addr = bdaddr->address;
97
98 sprintf(*bdstr, "%02x:%02x:%02x:%02x:%02x:%02x",
99 addr[0], addr[1], addr[2],
100 addr[3], addr[4], addr[5]);
101 return *bdstr;
102 }
103
devclass2uint(DEV_CLASS dev_class)104 UINT32 devclass2uint(DEV_CLASS dev_class)
105 {
106 UINT32 cod = 0;
107
108 if(dev_class != NULL)
109 {
110 /* if COD is 0, irrespective of the device type set it to Unclassified device */
111 cod = (dev_class[2]) | (dev_class[1] << 8) | (dev_class[0] << 16);
112 }
113 return cod;
114 }
uint2devclass(UINT32 cod,DEV_CLASS dev_class)115 void uint2devclass(UINT32 cod, DEV_CLASS dev_class)
116 {
117 dev_class[2] = (UINT8)cod;
118 dev_class[1] = (UINT8)(cod >> 8);
119 dev_class[0] = (UINT8)(cod >> 16);
120 }
121
122 static const UINT8 sdp_base_uuid[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
123 0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
124
uuid16_to_uuid128(uint16_t uuid16,bt_uuid_t * uuid128)125 void uuid16_to_uuid128(uint16_t uuid16, bt_uuid_t* uuid128)
126 {
127 uint16_t uuid16_bo;
128 memset(uuid128, 0, sizeof(bt_uuid_t));
129
130 memcpy(uuid128->uu, sdp_base_uuid, MAX_UUID_SIZE);
131 uuid16_bo = ntohs(uuid16);
132 memcpy(uuid128->uu + 2, &uuid16_bo, sizeof(uint16_t));
133 }
134
string_to_uuid(char * str,bt_uuid_t * p_uuid)135 void string_to_uuid(char *str, bt_uuid_t *p_uuid)
136 {
137 uint32_t uuid0, uuid4;
138 uint16_t uuid1, uuid2, uuid3, uuid5;
139
140 sscanf(str, "%08x-%04hx-%04hx-%04hx-%08x%04hx",
141 &uuid0, &uuid1, &uuid2, &uuid3, &uuid4, &uuid5);
142
143 uuid0 = htonl(uuid0);
144 uuid1 = htons(uuid1);
145 uuid2 = htons(uuid2);
146 uuid3 = htons(uuid3);
147 uuid4 = htonl(uuid4);
148 uuid5 = htons(uuid5);
149
150 memcpy(&(p_uuid->uu[0]), &uuid0, 4);
151 memcpy(&(p_uuid->uu[4]), &uuid1, 2);
152 memcpy(&(p_uuid->uu[6]), &uuid2, 2);
153 memcpy(&(p_uuid->uu[8]), &uuid3, 2);
154 memcpy(&(p_uuid->uu[10]), &uuid4, 4);
155 memcpy(&(p_uuid->uu[14]), &uuid5, 2);
156
157 return;
158
159 }
160
uuid_to_string(bt_uuid_t * p_uuid,char * str)161 void uuid_to_string(bt_uuid_t *p_uuid, char *str)
162 {
163 uint32_t uuid0, uuid4;
164 uint16_t uuid1, uuid2, uuid3, uuid5;
165
166 memcpy(&uuid0, &(p_uuid->uu[0]), 4);
167 memcpy(&uuid1, &(p_uuid->uu[4]), 2);
168 memcpy(&uuid2, &(p_uuid->uu[6]), 2);
169 memcpy(&uuid3, &(p_uuid->uu[8]), 2);
170 memcpy(&uuid4, &(p_uuid->uu[10]), 4);
171 memcpy(&uuid5, &(p_uuid->uu[14]), 2);
172
173 sprintf((char *)str, "%.8x-%.4x-%.4x-%.4x-%.8x%.4x",
174 ntohl(uuid0), ntohs(uuid1),
175 ntohs(uuid2), ntohs(uuid3),
176 ntohl(uuid4), ntohs(uuid5));
177 return;
178 }
179
180 /*****************************************************************************
181 ** Function ascii_2_hex
182 **
183 ** Description This function converts an ASCII string into HEX
184 **
185 ** Returns the number of hex bytes filled.
186 */
ascii_2_hex(char * p_ascii,int len,UINT8 * p_hex)187 int ascii_2_hex (char *p_ascii, int len, UINT8 *p_hex)
188 {
189 int x;
190 UINT8 c;
191
192 for (x = 0; (x < len) && (*p_ascii); x++)
193 {
194 if (ISDIGIT (*p_ascii))
195 c = (*p_ascii - '0') << 4;
196 else
197 c = (toupper(*p_ascii) - 'A' + 10) << 4;
198
199 p_ascii++;
200 if (*p_ascii)
201 {
202 if (ISDIGIT (*p_ascii))
203 c |= (*p_ascii - '0');
204 else
205 c |= (toupper(*p_ascii) - 'A' + 10);
206
207 p_ascii++;
208 }
209 *p_hex++ = c;
210 }
211
212 return (x);
213 }
214
215
dump_dm_search_event(UINT16 event)216 const char* dump_dm_search_event(UINT16 event)
217 {
218 switch(event)
219 {
220 CASE_RETURN_STR(BTA_DM_INQ_RES_EVT)
221 CASE_RETURN_STR(BTA_DM_INQ_CMPL_EVT)
222 CASE_RETURN_STR(BTA_DM_DISC_RES_EVT)
223 CASE_RETURN_STR(BTA_DM_DISC_BLE_RES_EVT)
224 CASE_RETURN_STR(BTA_DM_DISC_CMPL_EVT)
225 CASE_RETURN_STR(BTA_DM_DI_DISC_CMPL_EVT)
226 CASE_RETURN_STR(BTA_DM_SEARCH_CANCEL_CMPL_EVT)
227
228 default:
229 return "UNKNOWN MSG ID";
230 }
231 }
232
233
dump_property_type(bt_property_type_t type)234 const char* dump_property_type(bt_property_type_t type)
235 {
236 switch(type)
237 {
238 CASE_RETURN_STR(BT_PROPERTY_BDNAME)
239 CASE_RETURN_STR(BT_PROPERTY_BDADDR)
240 CASE_RETURN_STR(BT_PROPERTY_UUIDS)
241 CASE_RETURN_STR(BT_PROPERTY_CLASS_OF_DEVICE)
242 CASE_RETURN_STR(BT_PROPERTY_TYPE_OF_DEVICE)
243 CASE_RETURN_STR(BT_PROPERTY_REMOTE_RSSI)
244 CASE_RETURN_STR(BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT)
245 CASE_RETURN_STR(BT_PROPERTY_ADAPTER_BONDED_DEVICES)
246 CASE_RETURN_STR(BT_PROPERTY_ADAPTER_SCAN_MODE)
247 CASE_RETURN_STR(BT_PROPERTY_REMOTE_FRIENDLY_NAME)
248
249 default:
250 return "UNKNOWN PROPERTY ID";
251 }
252 }
253
dump_dm_event(UINT16 event)254 const char* dump_dm_event(UINT16 event)
255 {
256 switch(event)
257 {
258 CASE_RETURN_STR(BTA_DM_ENABLE_EVT)
259 CASE_RETURN_STR(BTA_DM_DISABLE_EVT)
260 CASE_RETURN_STR(BTA_DM_PIN_REQ_EVT)
261 CASE_RETURN_STR(BTA_DM_AUTH_CMPL_EVT)
262 CASE_RETURN_STR(BTA_DM_AUTHORIZE_EVT)
263 CASE_RETURN_STR(BTA_DM_LINK_UP_EVT)
264 CASE_RETURN_STR(BTA_DM_LINK_DOWN_EVT)
265 CASE_RETURN_STR(BTA_DM_SIG_STRENGTH_EVT)
266 CASE_RETURN_STR(BTA_DM_BUSY_LEVEL_EVT)
267 CASE_RETURN_STR(BTA_DM_BOND_CANCEL_CMPL_EVT)
268 CASE_RETURN_STR(BTA_DM_SP_CFM_REQ_EVT)
269 CASE_RETURN_STR(BTA_DM_SP_KEY_NOTIF_EVT)
270 CASE_RETURN_STR(BTA_DM_SP_RMT_OOB_EVT)
271 CASE_RETURN_STR(BTA_DM_SP_KEYPRESS_EVT)
272 CASE_RETURN_STR(BTA_DM_ROLE_CHG_EVT)
273 CASE_RETURN_STR(BTA_DM_BLE_KEY_EVT)
274 CASE_RETURN_STR(BTA_DM_BLE_SEC_REQ_EVT)
275 CASE_RETURN_STR(BTA_DM_BLE_PASSKEY_NOTIF_EVT)
276 CASE_RETURN_STR(BTA_DM_BLE_PASSKEY_REQ_EVT)
277 CASE_RETURN_STR(BTA_DM_BLE_OOB_REQ_EVT)
278 CASE_RETURN_STR(BTA_DM_BLE_LOCAL_IR_EVT)
279 CASE_RETURN_STR(BTA_DM_BLE_LOCAL_ER_EVT)
280 CASE_RETURN_STR(BTA_DM_BLE_AUTH_CMPL_EVT)
281 CASE_RETURN_STR(BTA_DM_DEV_UNPAIRED_EVT)
282 CASE_RETURN_STR(BTA_DM_HW_ERROR_EVT)
283 CASE_RETURN_STR(BTA_DM_ENER_INFO_READ)
284
285 default:
286 return "UNKNOWN DM EVENT";
287 }
288 }
289
dump_hf_event(UINT16 event)290 const char* dump_hf_event(UINT16 event)
291 {
292 switch(event)
293 {
294 CASE_RETURN_STR(BTA_AG_ENABLE_EVT)
295 CASE_RETURN_STR(BTA_AG_REGISTER_EVT)
296 CASE_RETURN_STR(BTA_AG_OPEN_EVT)
297 CASE_RETURN_STR(BTA_AG_CLOSE_EVT)
298 CASE_RETURN_STR(BTA_AG_CONN_EVT)
299 CASE_RETURN_STR(BTA_AG_AUDIO_OPEN_EVT)
300 CASE_RETURN_STR(BTA_AG_AUDIO_CLOSE_EVT)
301 CASE_RETURN_STR(BTA_AG_SPK_EVT)
302 CASE_RETURN_STR(BTA_AG_MIC_EVT)
303 CASE_RETURN_STR(BTA_AG_AT_CKPD_EVT)
304 CASE_RETURN_STR(BTA_AG_DISABLE_EVT)
305 #if (BTM_WBS_INCLUDED == TRUE )
306 CASE_RETURN_STR(BTA_AG_WBS_EVT)
307 #endif
308 CASE_RETURN_STR(BTA_AG_AT_A_EVT)
309 CASE_RETURN_STR(BTA_AG_AT_D_EVT)
310 CASE_RETURN_STR(BTA_AG_AT_CHLD_EVT)
311 CASE_RETURN_STR(BTA_AG_AT_CHUP_EVT)
312 CASE_RETURN_STR(BTA_AG_AT_CIND_EVT)
313 CASE_RETURN_STR(BTA_AG_AT_VTS_EVT)
314 CASE_RETURN_STR(BTA_AG_AT_BINP_EVT)
315 CASE_RETURN_STR(BTA_AG_AT_BLDN_EVT)
316 CASE_RETURN_STR(BTA_AG_AT_BVRA_EVT)
317 CASE_RETURN_STR(BTA_AG_AT_NREC_EVT)
318 CASE_RETURN_STR(BTA_AG_AT_CNUM_EVT)
319 CASE_RETURN_STR(BTA_AG_AT_BTRH_EVT)
320 CASE_RETURN_STR(BTA_AG_AT_CLCC_EVT)
321 CASE_RETURN_STR(BTA_AG_AT_COPS_EVT)
322 CASE_RETURN_STR(BTA_AG_AT_UNAT_EVT)
323 CASE_RETURN_STR(BTA_AG_AT_CBC_EVT)
324 CASE_RETURN_STR(BTA_AG_AT_BAC_EVT)
325 CASE_RETURN_STR(BTA_AG_AT_BCS_EVT)
326
327 default:
328 return "UNKNOWN MSG ID";
329 }
330 }
331
dump_hf_client_event(UINT16 event)332 const char* dump_hf_client_event(UINT16 event)
333 {
334 switch(event)
335 {
336 CASE_RETURN_STR(BTA_HF_CLIENT_ENABLE_EVT)
337 CASE_RETURN_STR(BTA_HF_CLIENT_REGISTER_EVT)
338 CASE_RETURN_STR(BTA_HF_CLIENT_OPEN_EVT)
339 CASE_RETURN_STR(BTA_HF_CLIENT_CLOSE_EVT)
340 CASE_RETURN_STR(BTA_HF_CLIENT_CONN_EVT)
341 CASE_RETURN_STR(BTA_HF_CLIENT_AUDIO_OPEN_EVT)
342 CASE_RETURN_STR(BTA_HF_CLIENT_AUDIO_MSBC_OPEN_EVT)
343 CASE_RETURN_STR(BTA_HF_CLIENT_AUDIO_CLOSE_EVT)
344 CASE_RETURN_STR(BTA_HF_CLIENT_SPK_EVT)
345 CASE_RETURN_STR(BTA_HF_CLIENT_MIC_EVT)
346 CASE_RETURN_STR(BTA_HF_CLIENT_DISABLE_EVT)
347 CASE_RETURN_STR(BTA_HF_CLIENT_IND_EVT)
348 CASE_RETURN_STR(BTA_HF_CLIENT_VOICE_REC_EVT)
349 CASE_RETURN_STR(BTA_HF_CLIENT_OPERATOR_NAME_EVT)
350 CASE_RETURN_STR(BTA_HF_CLIENT_CLIP_EVT)
351 CASE_RETURN_STR(BTA_HF_CLIENT_CCWA_EVT)
352 CASE_RETURN_STR(BTA_HF_CLIENT_AT_RESULT_EVT)
353 CASE_RETURN_STR(BTA_HF_CLIENT_CLCC_EVT)
354 CASE_RETURN_STR(BTA_HF_CLIENT_CNUM_EVT)
355 CASE_RETURN_STR(BTA_HF_CLIENT_BTRH_EVT)
356 CASE_RETURN_STR(BTA_HF_CLIENT_BSIR_EVT)
357 CASE_RETURN_STR(BTA_HF_CLIENT_BINP_EVT)
358 CASE_RETURN_STR(BTA_HF_CLIENT_RING_INDICATION)
359 default:
360 return "UNKNOWN MSG ID";
361 }
362 }
363
dump_hh_event(UINT16 event)364 const char* dump_hh_event(UINT16 event)
365 {
366 switch(event)
367 {
368 CASE_RETURN_STR(BTA_HH_ENABLE_EVT)
369 CASE_RETURN_STR(BTA_HH_DISABLE_EVT)
370 CASE_RETURN_STR(BTA_HH_OPEN_EVT)
371 CASE_RETURN_STR(BTA_HH_CLOSE_EVT)
372 CASE_RETURN_STR(BTA_HH_GET_DSCP_EVT)
373 CASE_RETURN_STR(BTA_HH_GET_PROTO_EVT)
374 CASE_RETURN_STR(BTA_HH_GET_RPT_EVT)
375 CASE_RETURN_STR(BTA_HH_GET_IDLE_EVT)
376 CASE_RETURN_STR(BTA_HH_SET_PROTO_EVT)
377 CASE_RETURN_STR(BTA_HH_SET_RPT_EVT)
378 CASE_RETURN_STR(BTA_HH_SET_IDLE_EVT)
379 CASE_RETURN_STR(BTA_HH_VC_UNPLUG_EVT)
380 CASE_RETURN_STR(BTA_HH_ADD_DEV_EVT)
381 CASE_RETURN_STR(BTA_HH_RMV_DEV_EVT)
382 CASE_RETURN_STR(BTA_HH_API_ERR_EVT)
383 default:
384 return "UNKNOWN MSG ID";
385 }
386 }
387
388
dump_hf_conn_state(UINT16 event)389 const char* dump_hf_conn_state(UINT16 event)
390 {
391 switch(event)
392 {
393 CASE_RETURN_STR(BTHF_CONNECTION_STATE_DISCONNECTED)
394 CASE_RETURN_STR(BTHF_CONNECTION_STATE_CONNECTING)
395 CASE_RETURN_STR(BTHF_CONNECTION_STATE_CONNECTED)
396 CASE_RETURN_STR(BTHF_CONNECTION_STATE_SLC_CONNECTED)
397 CASE_RETURN_STR(BTHF_CONNECTION_STATE_DISCONNECTING)
398 default:
399 return "UNKNOWN MSG ID";
400 }
401 }
402
dump_hf_call_state(bthf_call_state_t call_state)403 const char* dump_hf_call_state(bthf_call_state_t call_state)
404 {
405 switch(call_state)
406 {
407 CASE_RETURN_STR(BTHF_CALL_STATE_IDLE)
408 CASE_RETURN_STR(BTHF_CALL_STATE_HELD)
409 CASE_RETURN_STR(BTHF_CALL_STATE_DIALING)
410 CASE_RETURN_STR(BTHF_CALL_STATE_ALERTING)
411 CASE_RETURN_STR(BTHF_CALL_STATE_INCOMING)
412 CASE_RETURN_STR(BTHF_CALL_STATE_WAITING)
413 CASE_RETURN_STR(BTHF_CALL_STATE_ACTIVE)
414 default:
415 return "UNKNOWN CALL STATE";
416 }
417 }
418
dump_thread_evt(bt_cb_thread_evt evt)419 const char* dump_thread_evt(bt_cb_thread_evt evt)
420 {
421 switch(evt)
422 {
423 CASE_RETURN_STR(ASSOCIATE_JVM)
424 CASE_RETURN_STR(DISASSOCIATE_JVM)
425
426 default:
427 return "unknown thread evt";
428 }
429 }
430
431
dump_hf_audio_state(UINT16 event)432 const char* dump_hf_audio_state(UINT16 event)
433 {
434 switch(event)
435 {
436 CASE_RETURN_STR(BTHF_AUDIO_STATE_DISCONNECTED)
437 CASE_RETURN_STR(BTHF_AUDIO_STATE_CONNECTING)
438 CASE_RETURN_STR(BTHF_AUDIO_STATE_CONNECTED)
439 CASE_RETURN_STR(BTHF_AUDIO_STATE_DISCONNECTING)
440 default:
441 return "UNKNOWN MSG ID";
442
443 }
444 }
445
dump_av_conn_state(UINT16 event)446 const char* dump_av_conn_state(UINT16 event)
447 {
448 switch(event)
449 {
450 CASE_RETURN_STR(BTAV_CONNECTION_STATE_DISCONNECTED)
451 CASE_RETURN_STR(BTAV_CONNECTION_STATE_CONNECTING)
452 CASE_RETURN_STR(BTAV_CONNECTION_STATE_CONNECTED)
453 CASE_RETURN_STR(BTAV_CONNECTION_STATE_DISCONNECTING)
454 default:
455 return "UNKNOWN MSG ID";
456 }
457 }
458
dump_av_audio_state(UINT16 event)459 const char* dump_av_audio_state(UINT16 event)
460 {
461 switch(event)
462 {
463 CASE_RETURN_STR(BTAV_AUDIO_STATE_REMOTE_SUSPEND)
464 CASE_RETURN_STR(BTAV_AUDIO_STATE_STOPPED)
465 CASE_RETURN_STR(BTAV_AUDIO_STATE_STARTED)
466 default:
467 return "UNKNOWN MSG ID";
468 }
469 }
470
dump_adapter_scan_mode(bt_scan_mode_t mode)471 const char* dump_adapter_scan_mode(bt_scan_mode_t mode)
472 {
473 switch(mode)
474 {
475 CASE_RETURN_STR(BT_SCAN_MODE_NONE)
476 CASE_RETURN_STR(BT_SCAN_MODE_CONNECTABLE)
477 CASE_RETURN_STR(BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE)
478
479 default:
480 return "unknown scan mode";
481 }
482 }
483
dump_bt_status(bt_status_t status)484 const char* dump_bt_status(bt_status_t status)
485 {
486 switch(status)
487 {
488 CASE_RETURN_STR(BT_STATUS_SUCCESS)
489 CASE_RETURN_STR(BT_STATUS_FAIL)
490 CASE_RETURN_STR(BT_STATUS_NOT_READY)
491 CASE_RETURN_STR(BT_STATUS_NOMEM)
492 CASE_RETURN_STR(BT_STATUS_BUSY)
493 CASE_RETURN_STR(BT_STATUS_UNSUPPORTED)
494
495 default:
496 return "unknown scan mode";
497 }
498 }
499
dump_rc_event(UINT8 event)500 const char *dump_rc_event(UINT8 event)
501 {
502 switch(event) {
503 CASE_RETURN_STR(BTA_AV_RC_OPEN_EVT)
504 CASE_RETURN_STR(BTA_AV_RC_CLOSE_EVT)
505 CASE_RETURN_STR(BTA_AV_REMOTE_CMD_EVT)
506 CASE_RETURN_STR(BTA_AV_REMOTE_RSP_EVT)
507 CASE_RETURN_STR(BTA_AV_VENDOR_CMD_EVT)
508 CASE_RETURN_STR(BTA_AV_VENDOR_RSP_EVT)
509 CASE_RETURN_STR(BTA_AV_META_MSG_EVT)
510 CASE_RETURN_STR(BTA_AV_RC_FEAT_EVT)
511 default:
512 return "UNKNOWN_EVENT";
513 }
514 }
515
dump_rc_notification_event_id(UINT8 event_id)516 const char * dump_rc_notification_event_id(UINT8 event_id)
517 {
518 switch(event_id)
519 {
520 CASE_RETURN_STR(AVRC_EVT_PLAY_STATUS_CHANGE)
521 CASE_RETURN_STR(AVRC_EVT_TRACK_CHANGE)
522 CASE_RETURN_STR(AVRC_EVT_TRACK_REACHED_END)
523 CASE_RETURN_STR(AVRC_EVT_TRACK_REACHED_START)
524 CASE_RETURN_STR(AVRC_EVT_PLAY_POS_CHANGED)
525 CASE_RETURN_STR(AVRC_EVT_BATTERY_STATUS_CHANGE)
526 CASE_RETURN_STR(AVRC_EVT_SYSTEM_STATUS_CHANGE)
527 CASE_RETURN_STR(AVRC_EVT_APP_SETTING_CHANGE)
528 CASE_RETURN_STR(AVRC_EVT_VOLUME_CHANGE)
529
530 default:
531 return "Unhandled Event ID";
532 }
533 }
534
dump_rc_pdu(UINT8 pdu)535 const char* dump_rc_pdu(UINT8 pdu)
536 {
537 switch(pdu)
538 {
539 CASE_RETURN_STR(AVRC_PDU_LIST_PLAYER_APP_ATTR)
540 CASE_RETURN_STR(AVRC_PDU_LIST_PLAYER_APP_VALUES)
541 CASE_RETURN_STR(AVRC_PDU_GET_CUR_PLAYER_APP_VALUE)
542 CASE_RETURN_STR(AVRC_PDU_SET_PLAYER_APP_VALUE)
543 CASE_RETURN_STR(AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT)
544 CASE_RETURN_STR(AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT)
545 CASE_RETURN_STR(AVRC_PDU_INFORM_DISPLAY_CHARSET)
546 CASE_RETURN_STR(AVRC_PDU_INFORM_BATTERY_STAT_OF_CT)
547 CASE_RETURN_STR(AVRC_PDU_GET_ELEMENT_ATTR)
548 CASE_RETURN_STR(AVRC_PDU_GET_PLAY_STATUS)
549 CASE_RETURN_STR(AVRC_PDU_REGISTER_NOTIFICATION)
550 CASE_RETURN_STR(AVRC_PDU_REQUEST_CONTINUATION_RSP)
551 CASE_RETURN_STR(AVRC_PDU_ABORT_CONTINUATION_RSP)
552 CASE_RETURN_STR(AVRC_PDU_SET_ABSOLUTE_VOLUME)
553 default:
554 return "Unknown PDU";
555 }
556 }
557