• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python3
2#
3# Copyright (C) 2016 The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may not
6# use this file except in compliance with the License. You may obtain a copy of
7# 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, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations under
15# the License.
16
17### Generic Constants Begin ###
18
19bt_default_timeout = 15
20default_rfcomm_timeout_ms = 10000
21default_bluetooth_socket_timeout_ms = 10000
22pan_connect_timeout = 5
23bt_discovery_timeout = 3
24small_timeout = 0.0001
25
26# Time delay (in seconds) at the end of each LE CoC Test to give sufficient time
27# for the ACL LE link to be disconnected. The ACL link stays connected after
28# L2CAP disconnects.  An example of the timeout is L2CAP_LINK_INACTIVITY_TOUT.
29# This delay must be greater than the maximum of these timeouts.
30# TODO: Investigate the use of broadcast intent
31# BluetoothDevice.ACTION_ACL_DISCONNECTED to replace this delay method.
32l2cap_max_inactivity_delay_after_disconnect = 5
33
34# LE specifications related constants
35le_connection_interval_time_step_ms = 1.25
36le_default_supervision_timeout = 2000
37default_le_data_length = 23
38default_le_connection_interval_ms = 30
39le_connection_event_time_step_ms = 0.625
40
41# Headers of LE L2CAP Connection-oriented Channels. See section 3.4, Vol
42# 3, Part A, Version 5.0.
43l2cap_header_size = 4
44l2cap_coc_sdu_length_field_size = 2
45l2cap_coc_header_size = l2cap_header_size + l2cap_coc_sdu_length_field_size
46
47java_integer = {"min": -2147483648, "max": 2147483647}
48
49btsnoop_log_path_on_device = "/data/misc/bluetooth/logs/btsnoop_hci.log"
50btsnoop_last_log_path_on_device = \
51    "/data/misc/bluetooth/logs/btsnoop_hci.log.last"
52pairing_variant_passkey_confirmation = 2
53
54# Callback strings
55scan_result = "BleScan{}onScanResults"
56scan_failed = "BleScan{}onScanFailed"
57batch_scan_result = "BleScan{}onBatchScanResult"
58adv_fail = "BleAdvertise{}onFailure"
59adv_succ = "BleAdvertise{}onSuccess"
60bluetooth_off = "BluetoothStateChangedOff"
61bluetooth_on = "BluetoothStateChangedOn"
62mtu_changed = "GattConnect{}onMtuChanged"
63advertising_set_started = "AdvertisingSet{}onAdvertisingSetStarted"
64advertising_set_stopped = "AdvertisingSet{}onAdvertisingSetStopped"
65advertising_set_on_own_address_read = "AdvertisingSet{}onOwnAddressRead"
66advertising_set_enabled = "AdvertisingSet{}onAdvertisingEnabled"
67advertising_set_data_set = "AdvertisingSet{}onAdvertisingDataSet"
68advertising_set_scan_response_set = "AdvertisingSet{}onScanResponseDataSet"
69advertising_set_parameters_update = \
70    "AdvertisingSet{}onAdvertisingParametersUpdated"
71advertising_set_periodic_parameters_updated = \
72    "AdvertisingSet{}onPeriodicAdvertisingParametersUpdated"
73advertising_set_periodic_data_set = \
74    "AdvertisingSet{}onPeriodicAdvertisingDataSet"
75advertising_set_periodic_enable = "AdvertisingSet{}onPeriodicAdvertisingEnable"
76bluetooth_profile_connection_state_changed = \
77    "BluetoothProfileConnectionStateChanged"
78bluetooth_le_on = "BleStateChangedOn"
79bluetooth_le_off = "BleStateChangedOff"
80bluetooth_a2dp_codec_config_changed = "BluetoothA2dpCodecConfigChanged"
81# End Callback Strings
82
83batch_scan_not_supported_list = [
84    "Nexus 4",
85    "Nexus 5",
86    "Nexus 7",
87]
88
89### Generic Constants End ###
90
91### Bluetooth Constants Begin ###
92
93# rfcomm test uuids
94rfcomm_secure_uuid = "fa87c0d0-afac-11de-8a39-0800200c9a66"
95rfcomm_insecure_uuid = "8ce255c0-200a-11e0-ac64-0800200c9a66"
96
97# bluetooth socket connection test uuid
98bluetooth_socket_conn_test_uuid = "12345678-1234-5678-9abc-123456789abc"
99
100# Bluetooth Adapter Scan Mode Types
101bt_scan_mode_types = {
102    "state_off": -1,
103    "none": 0,
104    "connectable": 1,
105    "connectable_discoverable": 3
106}
107
108# Bluetooth Adapter State Constants
109bt_adapter_states = {
110    "off": 10,
111    "turning_on": 11,
112    "on": 12,
113    "turning_off": 13,
114    "ble_turning_on": 14,
115    "ble_on": 15,
116    "ble_turning_off": 16
117}
118
119# Should be kept in sync with BluetoothProfile.java
120bt_profile_constants = {
121    "headset": 1,
122    "a2dp": 2,
123    "health": 3,
124    "input_device": 4,
125    "pan": 5,
126    "pbap_server": 6,
127    "gatt": 7,
128    "gatt_server": 8,
129    "map": 9,
130    "sap": 10,
131    "a2dp_sink": 11,
132    "avrcp_controller": 12,
133    "headset_client": 16,
134    "pbap_client": 17,
135    "map_mce": 18
136}
137
138# Bluetooth RFCOMM UUIDs as defined by the SIG
139bt_rfcomm_uuids = {
140    "default_uuid": "457807c0-4897-11df-9879-0800200c9a66",
141    "base_uuid": "00000000-0000-1000-8000-00805F9B34FB",
142    "sdp": "00000001-0000-1000-8000-00805F9B34FB",
143    "udp": "00000002-0000-1000-8000-00805F9B34FB",
144    "rfcomm": "00000003-0000-1000-8000-00805F9B34FB",
145    "tcp": "00000004-0000-1000-8000-00805F9B34FB",
146    "tcs_bin": "00000005-0000-1000-8000-00805F9B34FB",
147    "tcs_at": "00000006-0000-1000-8000-00805F9B34FB",
148    "att": "00000007-0000-1000-8000-00805F9B34FB",
149    "obex": "00000008-0000-1000-8000-00805F9B34FB",
150    "ip": "00000009-0000-1000-8000-00805F9B34FB",
151    "ftp": "0000000A-0000-1000-8000-00805F9B34FB",
152    "http": "0000000C-0000-1000-8000-00805F9B34FB",
153    "wsp": "0000000E-0000-1000-8000-00805F9B34FB",
154    "bnep": "0000000F-0000-1000-8000-00805F9B34FB",
155    "upnp": "00000010-0000-1000-8000-00805F9B34FB",
156    "hidp": "00000011-0000-1000-8000-00805F9B34FB",
157    "hardcopy_control_channel": "00000012-0000-1000-8000-00805F9B34FB",
158    "hardcopy_data_channel": "00000014-0000-1000-8000-00805F9B34FB",
159    "hardcopy_notification": "00000016-0000-1000-8000-00805F9B34FB",
160    "avctp": "00000017-0000-1000-8000-00805F9B34FB",
161    "avdtp": "00000019-0000-1000-8000-00805F9B34FB",
162    "cmtp": "0000001B-0000-1000-8000-00805F9B34FB",
163    "mcap_control_channel": "0000001E-0000-1000-8000-00805F9B34FB",
164    "mcap_data_channel": "0000001F-0000-1000-8000-00805F9B34FB",
165    "l2cap": "00000100-0000-1000-8000-00805F9B34FB"
166}
167
168# Should be kept in sync with BluetoothProfile#STATE_* constants.
169bt_profile_states = {
170    "disconnected": 0,
171    "connecting": 1,
172    "connected": 2,
173    "disconnecting": 3
174}
175
176# Access Levels from BluetoothDevice.
177bt_access_levels = {"access_allowed": 1, "access_denied": 2}
178
179# Priority levels as defined in BluetoothProfile.java.
180bt_priority_levels = {
181    "auto_connect": 1000,
182    "on": 100,
183    "off": 0,
184    "undefined": -1
185}
186
187# A2DP codec configuration constants as defined in
188# frameworks/base/core/java/android/bluetooth/BluetoothCodecConfig.java
189codec_types = {
190    'SBC': 0,
191    'AAC': 1,
192    'APTX': 2,
193    'APTX-HD': 3,
194    'LDAC': 4,
195    'MAX': 5,
196    'INVALID': 1000000
197}
198
199codec_priorities = {'DISABLED': -1, 'DEFAULT': 0, 'HIGHEST': 1000000}
200
201sample_rates = {
202    'NONE': 0,
203    '44100': 0x1 << 0,
204    '48000': 0x1 << 1,
205    '88200': 0x1 << 2,
206    '96000': 0x1 << 3,
207    '176400': 0x1 << 4,
208    '192000': 0x1 << 5
209}
210
211bits_per_samples = {'NONE': 0, '16': 0x1 << 0, '24': 0x1 << 1, '32': 0x1 << 2}
212
213channel_modes = {'NONE': 0, 'MONO': 0x1 << 0, 'STEREO': 0x1 << 1}
214
215# Bluetooth HID constants.
216hid_connection_timeout = 5
217
218# Bluetooth HID EventFacade constants.
219hid_on_set_report_event = "onSetReport"
220hid_on_get_report_event = "onGetReport"
221hid_on_set_protocol_event = "onSetProtocol"
222hid_on_intr_data_event = "onInterruptData"
223hid_on_virtual_cable_unplug_event = "onVirtualCableUnplug"
224hid_id_keyboard = 1
225hid_id_mouse = 2
226hid_default_event_timeout = 15
227hid_default_set_report_payload = "Haha"
228
229### Bluetooth Constants End ###
230
231### Bluetooth Low Energy Constants Begin ###
232
233# Bluetooth Low Energy scan callback types
234ble_scan_settings_callback_types = {
235    "all_matches": 1,
236    "first_match": 2,
237    "match_lost": 4,
238    "found_and_lost": 6
239}
240
241# Bluetooth Low Energy scan settings match mode
242ble_scan_settings_match_modes = {"aggresive": 1, "sticky": 2}
243
244# Bluetooth Low Energy scan settings match nums
245ble_scan_settings_match_nums = {"one": 1, "few": 2, "max": 3}
246
247# Bluetooth Low Energy scan settings result types
248ble_scan_settings_result_types = {"full": 0, "abbreviated": 1}
249
250# Bluetooth Low Energy scan settings mode
251ble_scan_settings_modes = {
252    "opportunistic": -1,
253    "low_power": 0,
254    "balanced": 1,
255    "low_latency": 2
256}
257
258# Bluetooth Low Energy scan settings report delay millis
259ble_scan_settings_report_delay_milli_seconds = {
260    "min": 0,
261    "max": 9223372036854775807
262}
263
264# Bluetooth Low Energy scan settings phy
265ble_scan_settings_phys = {"1m": 1, "coded": 3, "all_supported": 255}
266
267# Bluetooth Low Energy advertise settings types
268ble_advertise_settings_types = {"non_connectable": 0, "connectable": 1}
269
270# Bluetooth Low Energy advertise settings modes
271ble_advertise_settings_modes = {
272    "low_power": 0,
273    "balanced": 1,
274    "low_latency": 2
275}
276
277# Bluetooth Low Energy advertise settings tx power
278ble_advertise_settings_tx_powers = {
279    "ultra_low": 0,
280    "low": 1,
281    "medium": 2,
282    "high": 3
283}
284
285# Bluetooth Low Energy advertise settings own address type
286ble_advertise_settings_own_address_types = {
287    "public": 0,
288    "random": 1
289}
290
291# Bluetooth Low Energy service uuids for specific devices
292ble_uuids = {
293    "p_service": "0000feef-0000-1000-8000-00805f9b34fb",
294    "hr_service": "0000180d-0000-1000-8000-00805f9b34fb"
295}
296
297# Bluetooth Low Energy advertising error codes
298ble_advertise_error_code = {
299    "data_too_large": 1,
300    "too_many_advertisers": 2,
301    "advertisement_already_started": 3,
302    "bluetooth_internal_failure": 4,
303    "feature_not_supported": 5
304}
305
306### Bluetooth Low Energy Constants End ###
307
308### Bluetooth GATT Constants Begin ###
309
310# Gatt Callback error messages
311gatt_cb_err = {
312    "char_write_req_err":
313    "Characteristic Write Request event not found. Expected {}",
314    "char_write_err": "Characteristic Write event not found. Expected {}",
315    "desc_write_req_err":
316    "Descriptor Write Request event not found. Expected {}",
317    "desc_write_err": "Descriptor Write event not found. Expected {}",
318    "char_read_err": "Characteristic Read event not found. Expected {}",
319    "char_read_req_err": "Characteristic Read Request not found. Expected {}",
320    "desc_read_err": "Descriptor Read event not found. Expected {}",
321    "desc_read_req_err":
322    "Descriptor Read Request event not found. Expected {}",
323    "rd_remote_rssi_err": "Read Remote RSSI event not found. Expected {}",
324    "gatt_serv_disc_err":
325    "GATT Services Discovered event not found. Expected {}",
326    "serv_added_err": "Service Added event not found. Expected {}",
327    "mtu_changed_err": "MTU Changed event not found. Expected {}",
328    "mtu_serv_changed_err": "MTU Server Changed event not found. Expected {}",
329    "gatt_conn_changed_err":
330    "GATT Connection Changed event not found. Expected {}",
331    "char_change_err":
332    "GATT Characteristic Changed event not fond. Expected {}",
333    "phy_read_err": "Phy Read event not fond. Expected {}",
334    "phy_update_err": "Phy Update event not fond. Expected {}",
335    "exec_write_err": "GATT Execute Write event not found. Expected {}"
336}
337
338# GATT callback strings as defined in GattClientFacade.java and
339# GattServerFacade.java implemented callbacks.
340gatt_cb_strings = {
341    "char_write_req": "GattServer{}onCharacteristicWriteRequest",
342    "exec_write": "GattServer{}onExecuteWrite",
343    "char_write": "GattConnect{}onCharacteristicWrite",
344    "desc_write_req": "GattServer{}onDescriptorWriteRequest",
345    "desc_write": "GattConnect{}onDescriptorWrite",
346    "char_read": "GattConnect{}onCharacteristicRead",
347    "char_read_req": "GattServer{}onCharacteristicReadRequest",
348    "desc_read": "GattConnect{}onDescriptorRead",
349    "desc_read_req": "GattServer{}onDescriptorReadRequest",
350    "rd_remote_rssi": "GattConnect{}onReadRemoteRssi",
351    "rd_remote_ble_rssi": "BleScan{}onScanResults",
352    "gatt_serv_disc": "GattConnect{}onServicesDiscovered",
353    "serv_added": "GattServer{}onServiceAdded",
354    "mtu_changed": "GattConnect{}onMtuChanged",
355    "mtu_serv_changed": "GattServer{}onMtuChanged",
356    "gatt_conn_change": "GattConnect{}onConnectionStateChange",
357    "char_change": "GattConnect{}onCharacteristicChanged",
358    "phy_read": "GattConnect{}onPhyRead",
359    "phy_update": "GattConnect{}onPhyUpdate",
360    "serv_phy_read": "GattServer{}onPhyRead",
361    "serv_phy_update": "GattServer{}onPhyUpdate",
362}
363
364# GATT event dictionary of expected callbacks and errors.
365gatt_event = {
366    "char_write_req": {
367        "evt": gatt_cb_strings["char_write_req"],
368        "err": gatt_cb_err["char_write_req_err"]
369    },
370    "exec_write": {
371        "evt": gatt_cb_strings["exec_write"],
372        "err": gatt_cb_err["exec_write_err"]
373    },
374    "char_write": {
375        "evt": gatt_cb_strings["char_write"],
376        "err": gatt_cb_err["char_write_err"]
377    },
378    "desc_write_req": {
379        "evt": gatt_cb_strings["desc_write_req"],
380        "err": gatt_cb_err["desc_write_req_err"]
381    },
382    "desc_write": {
383        "evt": gatt_cb_strings["desc_write"],
384        "err": gatt_cb_err["desc_write_err"]
385    },
386    "char_read": {
387        "evt": gatt_cb_strings["char_read"],
388        "err": gatt_cb_err["char_read_err"]
389    },
390    "char_read_req": {
391        "evt": gatt_cb_strings["char_read_req"],
392        "err": gatt_cb_err["char_read_req_err"]
393    },
394    "desc_read": {
395        "evt": gatt_cb_strings["desc_read"],
396        "err": gatt_cb_err["desc_read_err"]
397    },
398    "desc_read_req": {
399        "evt": gatt_cb_strings["desc_read_req"],
400        "err": gatt_cb_err["desc_read_req_err"]
401    },
402    "rd_remote_rssi": {
403        "evt": gatt_cb_strings["rd_remote_rssi"],
404        "err": gatt_cb_err["rd_remote_rssi_err"]
405    },
406    "gatt_serv_disc": {
407        "evt": gatt_cb_strings["gatt_serv_disc"],
408        "err": gatt_cb_err["gatt_serv_disc_err"]
409    },
410    "serv_added": {
411        "evt": gatt_cb_strings["serv_added"],
412        "err": gatt_cb_err["serv_added_err"]
413    },
414    "mtu_changed": {
415        "evt": gatt_cb_strings["mtu_changed"],
416        "err": gatt_cb_err["mtu_changed_err"]
417    },
418    "gatt_conn_change": {
419        "evt": gatt_cb_strings["gatt_conn_change"],
420        "err": gatt_cb_err["gatt_conn_changed_err"]
421    },
422    "char_change": {
423        "evt": gatt_cb_strings["char_change"],
424        "err": gatt_cb_err["char_change_err"]
425    },
426    "phy_read": {
427        "evt": gatt_cb_strings["phy_read"],
428        "err": gatt_cb_err["phy_read_err"]
429    },
430    "phy_update": {
431        "evt": gatt_cb_strings["phy_update"],
432        "err": gatt_cb_err["phy_update_err"]
433    },
434    "serv_phy_read": {
435        "evt": gatt_cb_strings["serv_phy_read"],
436        "err": gatt_cb_err["phy_read_err"]
437    },
438    "serv_phy_update": {
439        "evt": gatt_cb_strings["serv_phy_update"],
440        "err": gatt_cb_err["phy_update_err"]
441    }
442}
443
444# Matches constants of connection states defined in BluetoothGatt.java
445gatt_connection_state = {
446    "disconnected": 0,
447    "connecting": 1,
448    "connected": 2,
449    "disconnecting": 3,
450    "closed": 4
451}
452
453# Matches constants of Bluetooth GATT Characteristic values as defined
454# in BluetoothGattCharacteristic.java
455gatt_characteristic = {
456    "property_broadcast": 0x01,
457    "property_read": 0x02,
458    "property_write_no_response": 0x04,
459    "property_write": 0x08,
460    "property_notify": 0x10,
461    "property_indicate": 0x20,
462    "property_signed_write": 0x40,
463    "property_extended_props": 0x80,
464    "permission_read": 0x01,
465    "permission_read_encrypted": 0x02,
466    "permission_read_encrypted_mitm": 0x04,
467    "permission_write": 0x10,
468    "permission_write_encrypted": 0x20,
469    "permission_write_encrypted_mitm": 0x40,
470    "permission_write_signed": 0x80,
471    "permission_write_signed_mitm": 0x100,
472    "write_type_default": 0x02,
473    "write_type_no_response": 0x01,
474    "write_type_signed": 0x04,
475}
476
477# Matches constants of Bluetooth GATT Characteristic values as defined
478# in BluetoothGattDescriptor.java
479gatt_descriptor = {
480    "enable_notification_value": [0x01, 0x00],
481    "enable_indication_value": [0x02, 0x00],
482    "disable_notification_value": [0x00, 0x00],
483    "permission_read": 0x01,
484    "permission_read_encrypted": 0x02,
485    "permission_read_encrypted_mitm": 0x04,
486    "permission_write": 0x10,
487    "permission_write_encrypted": 0x20,
488    "permission_write_encrypted_mitm": 0x40,
489    "permission_write_signed": 0x80,
490    "permission_write_signed_mitm": 0x100
491}
492
493# https://www.bluetooth.com/specifications/gatt/descriptors
494gatt_char_desc_uuids = {
495    "char_ext_props": '00002900-0000-1000-8000-00805f9b34fb',
496    "char_user_desc": '00002901-0000-1000-8000-00805f9b34fb',
497    "client_char_cfg": '00002902-0000-1000-8000-00805f9b34fb',
498    "server_char_cfg": '00002903-0000-1000-8000-00805f9b34fb',
499    "char_fmt_uuid": '00002904-0000-1000-8000-00805f9b34fb',
500    "char_agreg_fmt": '00002905-0000-1000-8000-00805f9b34fb',
501    "char_valid_range": '00002906-0000-1000-8000-00805f9b34fb',
502    "external_report_reference": '00002907-0000-1000-8000-00805f9b34fb',
503    "report_reference": '00002908-0000-1000-8000-00805f9b34fb'
504}
505
506# https://www.bluetooth.com/specifications/gatt/characteristics
507gatt_char_types = {
508    "device_name": '00002a00-0000-1000-8000-00805f9b34fb',
509    "appearance": '00002a01-0000-1000-8000-00805f9b34fb',
510    "peripheral_priv_flag": '00002a02-0000-1000-8000-00805f9b34fb',
511    "reconnection_address": '00002a03-0000-1000-8000-00805f9b34fb',
512    "peripheral_pref_conn": '00002a04-0000-1000-8000-00805f9b34fb',
513    "service_changed": '00002a05-0000-1000-8000-00805f9b34fb',
514    "system_id": '00002a23-0000-1000-8000-00805f9b34fb',
515    "model_number_string": '00002a24-0000-1000-8000-00805f9b34fb',
516    "serial_number_string": '00002a25-0000-1000-8000-00805f9b34fb',
517    "firmware_revision_string": '00002a26-0000-1000-8000-00805f9b34fb',
518    "hardware_revision_string": '00002a27-0000-1000-8000-00805f9b34fb',
519    "software_revision_string": '00002a28-0000-1000-8000-00805f9b34fb',
520    "manufacturer_name_string": '00002a29-0000-1000-8000-00805f9b34fb',
521    "pnp_id": '00002a50-0000-1000-8000-00805f9b34fb',
522}
523
524# Matches constants of Bluetooth GATT Characteristic values as defined
525# in BluetoothGattCharacteristic.java
526gatt_characteristic_value_format = {
527    "string": 0x1,
528    "byte": 0x2,
529    "sint8": 0x21,
530    "uint8": 0x11,
531    "sint16": 0x22,
532    "unit16": 0x12,
533    "sint32": 0x24,
534    "uint32": 0x14
535}
536
537# Matches constants of Bluetooth Gatt Service types as defined in
538# BluetoothGattService.java
539gatt_service_types = {"primary": 0, "secondary": 1}
540
541# Matches constants of Bluetooth Gatt Connection Priority values as defined in
542# BluetoothGatt.java
543gatt_connection_priority = {"balanced": 0, "high": 1, "low_power": 2}
544
545# Min and max MTU values
546gatt_mtu_size = {"min": 23, "max": 217}
547
548# Gatt Characteristic attribute lengths
549gatt_characteristic_attr_length = {"attr_1": 1, "attr_2": 3, "attr_3": 15}
550
551# Matches constants of Bluetooth Gatt operations status as defined in
552# BluetoothGatt.java
553gatt_status = {"success": 0, "failure": 0x101}
554
555# Matches constants of Bluetooth transport values as defined in
556# BluetoothDevice.java
557gatt_transport = {"auto": 0x00, "bredr": 0x01, "le": 0x02}
558
559# Matches constants of Bluetooth physical channeling values as defined in
560# BluetoothDevice.java
561gatt_phy = {"1m": 1, "2m": 2, "le_coded": 3}
562
563# Matches constants of Bluetooth physical channeling bitmask values as defined
564# in BluetoothDevice.java
565gatt_phy_mask = {"1m_mask": 1, "2m_mask": 2, "coded_mask": 4}
566
567# Values as defiend in the Bluetooth GATT specification
568gatt_server_responses = {
569    "GATT_SUCCESS": 0x0,
570    "GATT_FAILURE": 0x1,
571    "GATT_READ_NOT_PERMITTED": 0x2,
572    "GATT_WRITE_NOT_PERMITTED": 0x3,
573    "GATT_INVALID_PDU": 0x4,
574    "GATT_INSUFFICIENT_AUTHENTICATION": 0x5,
575    "GATT_REQUEST_NOT_SUPPORTED": 0x6,
576    "GATT_INVALID_OFFSET": 0x7,
577    "GATT_INSUFFICIENT_AUTHORIZATION": 0x8,
578    "GATT_INVALID_ATTRIBUTE_LENGTH": 0xd,
579    "GATT_INSUFFICIENT_ENCRYPTION": 0xf,
580    "GATT_CONNECTION_CONGESTED": 0x8f,
581    "GATT_13_ERR": 0x13,
582    "GATT_12_ERR": 0x12,
583    "GATT_0C_ERR": 0x0C,
584    "GATT_16": 0x16
585}
586
587### Bluetooth GATT Constants End ###
588
589### Chameleon Constants Begin ###
590
591# Chameleon audio bits per sample.
592audio_bits_per_sample_16 = 16
593audio_bits_per_sample_24 = 24
594audio_bits_per_sample_32 = 32
595
596# Chameleon audio sample rates.
597audio_sample_rate_44100 = 44100
598audio_sample_rate_48000 = 48000
599audio_sample_rate_88200 = 88200
600audio_sample_rate_96000 = 96000
601
602# Chameleon audio channel modes.
603audio_channel_mode_mono = 1
604audio_channel_mode_stereo = 2
605audio_channel_mode_8 = 8
606
607# Chameleon time delays.
608delay_after_binding_seconds = 0.5
609delay_before_record_seconds = 0.5
610silence_wait_seconds = 5
611
612# Chameleon bus endpoints.
613fpga_linein_bus_endpoint = 'Chameleon FPGA line-in'
614headphone_bus_endpoint = 'Cros device headphone'
615
616### Chameleon Constants End ###
617
618# Begin logcat strings dict"""
619logcat_strings = {
620    "media_playback_vol_changed": "onRouteVolumeChanged",
621}
622
623# End logcat strings dict"""
624
625### Begin Service Discovery UUIDS ###
626# Values match the Bluetooth SIG defined values: """
627""" https://www.bluetooth.com/specifications/assigned-numbers/service-discovery """
628sig_uuid_constants = {
629    "BASE_UUID": "0000{}-0000-1000-8000-00805F9B34FB",
630    "SDP": "0001",
631    "UDP": "0002",
632    "RFCOMM": "0003",
633    "TCP": "0004",
634    "TCS-BIN": "0005",
635    "TCS-AT": "0006",
636    "ATT": "0007",
637    "OBEX": "0008",
638    "IP": "0009",
639    "FTP": "000A",
640    "HTTP": "000C",
641    "WSP": "000E",
642    "BNEP": "000F",
643    "UPNP": "0010",
644    "HIDP": "0011",
645    "HardcopyControlChannel": "0012",
646    "HardcopyDataChannel": "0014",
647    "HardcopyNotification": "0016",
648    "AVCTP": "0017",
649    "AVDTP": "0019",
650    "CMTP": "001B",
651    "MCAPControlChannel": "001E",
652    "MCAPDataChannel": "001F",
653    "L2CAP": "0100",
654    "ServiceDiscoveryServerServiceClassID": "1000",
655    "BrowseGroupDescriptorServiceClassID": "1001",
656    "SerialPort": "1101",
657    "LANAccessUsingPPP": "1102",
658    "DialupNetworking": "1103",
659    "IrMCSync": "1104",
660    "OBEXObjectPush": "1105",
661    "OBEXFileTransfer": "1106",
662    "IrMCSyncCommand": "1107",
663    "Headset": "1108",
664    "CordlessTelephony": "1109",
665    "AudioSource": "110A",
666    "AudioSink": "110B",
667    "A/V_RemoteControlTarget": "110C",
668    "AdvancedAudioDistribution": "110D",
669    "A/V_RemoteControl": "110E",
670    "A/V_RemoteControlController": "110F",
671    "Intercom": "1110",
672    "Fax": "1111",
673    "Headset - Audio Gateway (AG)": "1112",
674    "WAP": "1113",
675    "WAP_CLIENT": "1114",
676    "PANU": "1115",
677    "NAP": "1116",
678    "GN": "1117",
679    "DirectPrinting": "1118",
680    "ReferencePrinting": "1119",
681    "ImagingResponder": "111B",
682    "ImagingAutomaticArchive": "111C",
683    "ImagingReferencedObjects": "111D",
684    "Handsfree": "111E",
685    "HandsfreeAudioGateway": "111F",
686    "DirectPrintingReferenceObjectsService": "1120",
687    "ReflectedUI": "1121",
688    "BasicPrinting": "1122",
689    "PrintingStatus": "1123",
690    "HumanInterfaceDeviceService": "1124",
691    "HardcopyCableReplacement": "1125",
692    "HCR_Print": "1126",
693    "HCR_Scan": "1127",
694    "Common_ISDN_Access": "1128",
695    "SIM_Access": "112D",
696    "Phonebook Access - PCE": "112E",
697    "Phonebook Access - PSE": "112F",
698    "Phonebook Access": "1130",
699    "Headset - HS": "1131",
700    "Message Access Server": "1132",
701    "Message Notification Server": "1133",
702    "Message Access Profile": "1134",
703    "GNSS": "1135",
704    "GNSS_Server": "1136",
705    "PnPInformation": "1200",
706    "GenericNetworking": "1201",
707    "GenericFileTransfer": "1202",
708    "GenericAudio": "1203",
709    "GenericTelephony": "1204",
710    "UPNP_Service": "1205",
711    "UPNP_IP_Service": "1206",
712    "ESDP_UPNP_IP_PAN": "1300",
713    "ESDP_UPNP_IP_LAP": "1301",
714    "ESDP_UPNP_L2CAP": "1302",
715    "VideoSource": "1303",
716    "VideoSink": "1304",
717    "VideoDistribution": "1305",
718    "HDP": "1400"
719}
720
721### End Service Discovery UUIDS ###
722
723### Begin Appearance Constants ###
724# https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.gap.appearance.xml
725sig_appearance_constants = {
726    "UNKNOWN": 0,
727    "PHONE": 64,
728    "COMPUTER": 128,
729    "WATCH": 192,
730    "WATCH_SPORTS": 193,
731    "CLOCK": 256,
732    "DISPLAY": 320,
733    "REMOTE_CONTROL": 384,
734    "EYE_GLASSES": 448,
735    "TAG": 512,
736    "KEYRING": 576,
737    "MEDIA_PLAYER": 640,
738    "BARCODE_SCANNER": 704,
739    "THERMOMETER": 768,
740    "THERMOMETER_EAR": 769,
741    "HEART_RATE_SENSOR": 832,
742    "HEART_RATE_SENSOR_BELT": 833,
743    "BLOOD_PRESSURE": 896,
744    "BLOOD_PRESSURE_ARM": 897,
745    "BLOOD_PRESSURE_WRIST": 898,
746    "HID": 960,
747    "HID_KEYBOARD": 961,
748    "HID_MOUSE": 962,
749    "HID_JOYSTICK": 963,
750    "HID_GAMEPAD": 964,
751    "HID_DIGITIZER_TABLET": 965,
752    "HID_CARD_READER": 966,
753    "HID_DIGITAL_PEN": 967,
754    "HID_BARCODE_SCANNER": 968,
755    "GLUCOSE_METER": 1024,
756    "RUNNING_WALKING_SENSOR": 1088,
757    "RUNNING_WALKING_SENSOR_IN_SHOE": 1089,
758    "RUNNING_WALKING_SENSOR_ON_SHOE": 1090,
759    "RUNNING_WALKING_SENSOR_ON_HIP": 1091,
760    "CYCLING": 1152,
761    "CYCLING_COMPUTER": 1153,
762    "CYCLING_SPEED_SENSOR": 1154,
763    "CYCLING_CADENCE_SENSOR": 1155,
764    "CYCLING_POWER_SENSOR": 1156,
765    "CYCLING_SPEED_AND_CADENCE_SENSOR": 1157,
766    "PULSE_OXIMETER": 3136,
767    "PULSE_OXIMETER_FINGERTIP": 3137,
768    "PULSE_OXIMETER_WRIST": 3138,
769    "WEIGHT_SCALE": 3200,
770    "PERSONAL_MOBILITY": 3264,
771    "PERSONAL_MOBILITY_WHEELCHAIR": 3265,
772    "PERSONAL_MOBILITY_SCOOTER": 3266,
773    "GLUCOSE_MONITOR": 3328,
774    "SPORTS_ACTIVITY": 5184,
775    "SPORTS_ACTIVITY_LOCATION_DISPLAY": 5185,
776    "SPORTS_ACTIVITY_LOCATION_AND_NAV_DISPLAY": 5186,
777    "SPORTS_ACTIVITY_LOCATION_POD": 5187,
778    "SPORTS_ACTIVITY_LOCATION_AND_NAV_POD": 5188,
779}
780
781### End Appearance Constants ###
782
783# Attribute Record values from the Bluetooth Specification
784# Version 5, Vol 3, Part B
785bt_attribute_values = {
786    'ATTR_SERVICE_RECORD_HANDLE': 0x0000,
787    'ATTR_SERVICE_CLASS_ID_LIST': 0x0001,
788    'ATTR_SERVICE_RECORD_STATE': 0x0002,
789    'ATTR_SERVICE_ID': 0x0003,
790    'ATTR_PROTOCOL_DESCRIPTOR_LIST': 0x0004,
791    'ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LIST': 0x000D,
792    'ATTR_BROWSE_GROUP_LIST': 0x0005,
793    'ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST': 0x0006,
794    'ATTR_SERVICE_INFO_TIME_TO_LIVE': 0x0007,
795    'ATTR_SERVICE_AVAILABILITY': 0x0008,
796    'ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST': 0x0009,
797    'ATTR_A2DP_SUPPORTED_FEATURES': 0x0311,
798}
799