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