The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
Hemant Gupta | 41d4a26 | 2013-08-19 18:33:01 +0530 | [diff] [blame] | 3 | * Copyright (c) 2014 The Android Open Source Project |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 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 | #ifndef BTIF_UTIL_H |
| 21 | #define BTIF_UTIL_H |
| 22 | |
| 23 | #include <hardware/bluetooth.h> |
| 24 | #include <hardware/bt_hf.h> |
Sharvil Nanavati | 8c65ba9 | 2014-08-15 16:14:26 -0700 | [diff] [blame] | 25 | #include <stdbool.h> |
Ganesh Ganapathi Batta | ead3cde | 2013-02-05 15:22:31 -0800 | [diff] [blame] | 26 | #include <sys/time.h> |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 27 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 28 | #include "bt_types.h" |
Mike J. Chen | 60126e4 | 2014-01-31 18:13:09 -0800 | [diff] [blame] | 29 | #include "bt_utils.h" |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 30 | |
| 31 | /******************************************************************************* |
| 32 | ** Constants & Macros |
| 33 | ********************************************************************************/ |
| 34 | |
| 35 | #define CASE_RETURN_STR(const) case const: return #const; |
| 36 | |
| 37 | |
| 38 | /******************************************************************************* |
| 39 | ** Type definitions for callback functions |
| 40 | ********************************************************************************/ |
| 41 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 42 | /******************************************************************************* |
| 43 | ** Functions |
| 44 | ********************************************************************************/ |
| 45 | |
| 46 | const char* dump_bt_status(bt_status_t status); |
Marie Janssen | b7f64bc | 2016-06-22 12:52:19 -0700 | [diff] [blame] | 47 | const char* dump_dm_search_event(uint16_t event); |
| 48 | const char* dump_dm_event(uint16_t event); |
| 49 | const char* dump_hf_event(uint16_t event); |
| 50 | const char* dump_hf_client_event(uint16_t event); |
| 51 | const char* dump_hh_event(uint16_t event); |
| 52 | const char* dump_hf_conn_state(uint16_t event); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 53 | const char* dump_hf_call_state(bthf_call_state_t call_state); |
| 54 | const char* dump_property_type(bt_property_type_t type); |
Marie Janssen | b7f64bc | 2016-06-22 12:52:19 -0700 | [diff] [blame] | 55 | const char* dump_hf_audio_state(uint16_t event); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 56 | const char* dump_adapter_scan_mode(bt_scan_mode_t mode); |
| 57 | const char* dump_thread_evt(bt_cb_thread_evt evt); |
Marie Janssen | b7f64bc | 2016-06-22 12:52:19 -0700 | [diff] [blame] | 58 | const char* dump_av_conn_state(uint16_t event); |
| 59 | const char* dump_av_audio_state(uint16_t event); |
| 60 | const char* dump_rc_event(uint8_t event); |
| 61 | const char* dump_rc_notification_event_id(uint8_t event_id); |
| 62 | const char* dump_rc_pdu(uint8_t pdu); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 63 | |
Marie Janssen | b7f64bc | 2016-06-22 12:52:19 -0700 | [diff] [blame] | 64 | uint32_t devclass2uint(DEV_CLASS dev_class); |
| 65 | void uint2devclass(uint32_t dev, DEV_CLASS dev_class); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 66 | void uuid16_to_uuid128(uint16_t uuid16, bt_uuid_t* uuid128); |
| 67 | |
Andre Eisenbach | 1685664 | 2016-01-29 16:11:13 -0800 | [diff] [blame] | 68 | // Takes a |str| containing a 128-bit GUID formatted UUID and stores the |
| 69 | // result in |p_uuid|. |str| must be formatted in this format: |
| 70 | // "12345678-1234-1234-1234-123456789012" |
| 71 | // |p_uuid| cannot be null. Returns true if parsing was successful, false |
| 72 | // otherwise. Returns false if |str| is null. |
| 73 | bool string_to_uuid(const char *str, bt_uuid_t *p_uuid); |
| 74 | |
Marie Janssen | b7f64bc | 2016-06-22 12:52:19 -0700 | [diff] [blame] | 75 | int ascii_2_hex (const char *p_ascii, int len, uint8_t *p_hex); |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 76 | |
Pavlin Radoslavov | b2a292b | 2016-10-14 19:34:48 -0700 | [diff] [blame^] | 77 | void uuid_to_string_legacy(bt_uuid_t *p_uuid, char *str, size_t str_len); |
Jakub Pawlowski | 713993d | 2016-04-21 13:16:45 -0700 | [diff] [blame] | 78 | |
The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame] | 79 | #endif /* BTIF_UTIL_H */ |