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 = { 200 'DISABLED': -1, 201 'DEFAULT': 0, 202 'HIGHEST': 1000000 203} 204 205sample_rates = { 206 'NONE': 0, 207 '44100': 0x1 << 0, 208 '48000': 0x1 << 1, 209 '88200': 0x1 << 2, 210 '96000': 0x1 << 3, 211 '176400': 0x1 << 4, 212 '192000': 0x1 << 5 213} 214 215bits_per_samples = { 216 'NONE': 0, 217 '16': 0x1 << 0, 218 '24': 0x1 << 1, 219 '32': 0x1 << 2 220} 221 222channel_modes = { 223 'NONE': 0, 224 'MONO': 0x1 << 0, 225 'STEREO': 0x1 << 1 226} 227 228# Bluetooth HID constants. 229hid_connection_timeout = 5 230 231# Bluetooth HID EventFacade constants. 232hid_on_set_report_event = "onSetReport" 233hid_on_get_report_event = "onGetReport" 234hid_on_set_protocol_event = "onSetProtocol" 235hid_on_intr_data_event = "onInterruptData" 236hid_on_virtual_cable_unplug_event = "onVirtualCableUnplug" 237hid_id_keyboard = 1 238hid_id_mouse = 2 239hid_default_event_timeout = 15 240hid_default_set_report_payload = "Haha" 241 242### Bluetooth Constants End ### 243 244### Bluetooth Low Energy Constants Begin ### 245 246# Bluetooth Low Energy scan callback types 247ble_scan_settings_callback_types = { 248 "all_matches": 1, 249 "first_match": 2, 250 "match_lost": 4, 251 "found_and_lost": 6 252} 253 254# Bluetooth Low Energy scan settings match mode 255ble_scan_settings_match_modes = {"aggresive": 1, "sticky": 2} 256 257# Bluetooth Low Energy scan settings match nums 258ble_scan_settings_match_nums = {"one": 1, "few": 2, "max": 3} 259 260# Bluetooth Low Energy scan settings result types 261ble_scan_settings_result_types = {"full": 0, "abbreviated": 1} 262 263# Bluetooth Low Energy scan settings mode 264ble_scan_settings_modes = { 265 "opportunistic": -1, 266 "low_power": 0, 267 "balanced": 1, 268 "low_latency": 2 269} 270 271# Bluetooth Low Energy scan settings report delay millis 272ble_scan_settings_report_delay_milli_seconds = { 273 "min": 0, 274 "max": 9223372036854775807 275} 276 277# Bluetooth Low Energy scan settings phy 278ble_scan_settings_phys = {"1m": 1, "coded": 3, "all_supported": 255} 279 280# Bluetooth Low Energy advertise settings types 281ble_advertise_settings_types = {"non_connectable": 0, "connectable": 1} 282 283# Bluetooth Low Energy advertise settings modes 284ble_advertise_settings_modes = { 285 "low_power": 0, 286 "balanced": 1, 287 "low_latency": 2 288} 289 290# Bluetooth Low Energy advertise settings tx power 291ble_advertise_settings_tx_powers = { 292 "ultra_low": 0, 293 "low": 1, 294 "medium": 2, 295 "high": 3 296} 297 298# Bluetooth Low Energy service uuids for specific devices 299ble_uuids = { 300 "p_service": "0000feef-0000-1000-8000-00805f9b34fb", 301 "hr_service": "0000180d-0000-1000-8000-00805f9b34fb" 302} 303 304# Bluetooth Low Energy advertising error codes 305ble_advertise_error_code = { 306 "data_too_large": 1, 307 "too_many_advertisers": 2, 308 "advertisement_already_started": 3, 309 "bluetooth_internal_failure": 4, 310 "feature_not_supported": 5 311} 312 313### Bluetooth Low Energy Constants End ### 314 315### Bluetooth GATT Constants Begin ### 316 317# Gatt Callback error messages 318gatt_cb_err = { 319 "char_write_req_err": 320 "Characteristic Write Request event not found. Expected {}", 321 "char_write_err": 322 "Characteristic Write event not found. Expected {}", 323 "desc_write_req_err": 324 "Descriptor Write Request event not found. Expected {}", 325 "desc_write_err": 326 "Descriptor Write event not found. Expected {}", 327 "char_read_err": 328 "Characteristic Read event not found. Expected {}", 329 "char_read_req_err": 330 "Characteristic Read Request not found. Expected {}", 331 "desc_read_err": 332 "Descriptor Read event not found. Expected {}", 333 "desc_read_req_err": 334 "Descriptor Read Request event not found. Expected {}", 335 "rd_remote_rssi_err": 336 "Read Remote RSSI event not found. Expected {}", 337 "gatt_serv_disc_err": 338 "GATT Services Discovered event not found. Expected {}", 339 "serv_added_err": 340 "Service Added event not found. Expected {}", 341 "mtu_changed_err": 342 "MTU Changed event not found. Expected {}", 343 "mtu_serv_changed_err": 344 "MTU Server Changed event not found. Expected {}", 345 "gatt_conn_changed_err": 346 "GATT Connection Changed event not found. Expected {}", 347 "char_change_err": 348 "GATT Characteristic Changed event not fond. Expected {}", 349 "phy_read_err": 350 "Phy Read event not fond. Expected {}", 351 "phy_update_err": 352 "Phy Update event not fond. Expected {}", 353 "exec_write_err": 354 "GATT Execute Write event not found. Expected {}" 355} 356 357# GATT callback strings as defined in GattClientFacade.java and 358# GattServerFacade.java implemented callbacks. 359gatt_cb_strings = { 360 "char_write_req": "GattServer{}onCharacteristicWriteRequest", 361 "exec_write": "GattServer{}onExecuteWrite", 362 "char_write": "GattConnect{}onCharacteristicWrite", 363 "desc_write_req": "GattServer{}onDescriptorWriteRequest", 364 "desc_write": "GattConnect{}onDescriptorWrite", 365 "char_read": "GattConnect{}onCharacteristicRead", 366 "char_read_req": "GattServer{}onCharacteristicReadRequest", 367 "desc_read": "GattConnect{}onDescriptorRead", 368 "desc_read_req": "GattServer{}onDescriptorReadRequest", 369 "rd_remote_rssi": "GattConnect{}onReadRemoteRssi", 370 "gatt_serv_disc": "GattConnect{}onServicesDiscovered", 371 "serv_added": "GattServer{}onServiceAdded", 372 "mtu_changed": "GattConnect{}onMtuChanged", 373 "mtu_serv_changed": "GattServer{}onMtuChanged", 374 "gatt_conn_change": "GattConnect{}onConnectionStateChange", 375 "char_change": "GattConnect{}onCharacteristicChanged", 376 "phy_read": "GattConnect{}onPhyRead", 377 "phy_update": "GattConnect{}onPhyUpdate", 378 "serv_phy_read": "GattServer{}onPhyRead", 379 "serv_phy_update": "GattServer{}onPhyUpdate", 380} 381 382# GATT event dictionary of expected callbacks and errors. 383gatt_event = { 384 "char_write_req": { 385 "evt": gatt_cb_strings["char_write_req"], 386 "err": gatt_cb_err["char_write_req_err"] 387 }, 388 "exec_write": { 389 "evt": gatt_cb_strings["exec_write"], 390 "err": gatt_cb_err["exec_write_err"] 391 }, 392 "char_write": { 393 "evt": gatt_cb_strings["char_write"], 394 "err": gatt_cb_err["char_write_err"] 395 }, 396 "desc_write_req": { 397 "evt": gatt_cb_strings["desc_write_req"], 398 "err": gatt_cb_err["desc_write_req_err"] 399 }, 400 "desc_write": { 401 "evt": gatt_cb_strings["desc_write"], 402 "err": gatt_cb_err["desc_write_err"] 403 }, 404 "char_read": { 405 "evt": gatt_cb_strings["char_read"], 406 "err": gatt_cb_err["char_read_err"] 407 }, 408 "char_read_req": { 409 "evt": gatt_cb_strings["char_read_req"], 410 "err": gatt_cb_err["char_read_req_err"] 411 }, 412 "desc_read": { 413 "evt": gatt_cb_strings["desc_read"], 414 "err": gatt_cb_err["desc_read_err"] 415 }, 416 "desc_read_req": { 417 "evt": gatt_cb_strings["desc_read_req"], 418 "err": gatt_cb_err["desc_read_req_err"] 419 }, 420 "rd_remote_rssi": { 421 "evt": gatt_cb_strings["rd_remote_rssi"], 422 "err": gatt_cb_err["rd_remote_rssi_err"] 423 }, 424 "gatt_serv_disc": { 425 "evt": gatt_cb_strings["gatt_serv_disc"], 426 "err": gatt_cb_err["gatt_serv_disc_err"] 427 }, 428 "serv_added": { 429 "evt": gatt_cb_strings["serv_added"], 430 "err": gatt_cb_err["serv_added_err"] 431 }, 432 "mtu_changed": { 433 "evt": gatt_cb_strings["mtu_changed"], 434 "err": gatt_cb_err["mtu_changed_err"] 435 }, 436 "gatt_conn_change": { 437 "evt": gatt_cb_strings["gatt_conn_change"], 438 "err": gatt_cb_err["gatt_conn_changed_err"] 439 }, 440 "char_change": { 441 "evt": gatt_cb_strings["char_change"], 442 "err": gatt_cb_err["char_change_err"] 443 }, 444 "phy_read": { 445 "evt": gatt_cb_strings["phy_read"], 446 "err": gatt_cb_err["phy_read_err"] 447 }, 448 "phy_update": { 449 "evt": gatt_cb_strings["phy_update"], 450 "err": gatt_cb_err["phy_update_err"] 451 }, 452 "serv_phy_read": { 453 "evt": gatt_cb_strings["serv_phy_read"], 454 "err": gatt_cb_err["phy_read_err"] 455 }, 456 "serv_phy_update": { 457 "evt": gatt_cb_strings["serv_phy_update"], 458 "err": gatt_cb_err["phy_update_err"] 459 } 460} 461 462# Matches constants of connection states defined in BluetoothGatt.java 463gatt_connection_state = { 464 "disconnected": 0, 465 "connecting": 1, 466 "connected": 2, 467 "disconnecting": 3, 468 "closed": 4 469} 470 471# Matches constants of Bluetooth GATT Characteristic values as defined 472# in BluetoothGattCharacteristic.java 473gatt_characteristic = { 474 "property_broadcast": 0x01, 475 "property_read": 0x02, 476 "property_write_no_response": 0x04, 477 "property_write": 0x08, 478 "property_notify": 0x10, 479 "property_indicate": 0x20, 480 "property_signed_write": 0x40, 481 "property_extended_props": 0x80, 482 "permission_read": 0x01, 483 "permission_read_encrypted": 0x02, 484 "permission_read_encrypted_mitm": 0x04, 485 "permission_write": 0x10, 486 "permission_write_encrypted": 0x20, 487 "permission_write_encrypted_mitm": 0x40, 488 "permission_write_signed": 0x80, 489 "permission_write_signed_mitm": 0x100, 490 "write_type_default": 0x02, 491 "write_type_no_response": 0x01, 492 "write_type_signed": 0x04, 493} 494 495# Matches constants of Bluetooth GATT Characteristic values as defined 496# in BluetoothGattDescriptor.java 497gatt_descriptor = { 498 "enable_notification_value": [0x01, 0x00], 499 "enable_indication_value": [0x02, 0x00], 500 "disable_notification_value": [0x00, 0x00], 501 "permission_read": 0x01, 502 "permission_read_encrypted": 0x02, 503 "permission_read_encrypted_mitm": 0x04, 504 "permission_write": 0x10, 505 "permission_write_encrypted": 0x20, 506 "permission_write_encrypted_mitm": 0x40, 507 "permission_write_signed": 0x80, 508 "permission_write_signed_mitm": 0x100 509} 510 511# https://www.bluetooth.com/specifications/gatt/descriptors 512gatt_char_desc_uuids = { 513 "char_ext_props": '00002900-0000-1000-8000-00805f9b34fb', 514 "char_user_desc": '00002901-0000-1000-8000-00805f9b34fb', 515 "client_char_cfg": '00002902-0000-1000-8000-00805f9b34fb', 516 "server_char_cfg": '00002903-0000-1000-8000-00805f9b34fb', 517 "char_fmt_uuid": '00002904-0000-1000-8000-00805f9b34fb', 518 "char_agreg_fmt": '00002905-0000-1000-8000-00805f9b34fb', 519 "char_valid_range": '00002906-0000-1000-8000-00805f9b34fb', 520 "external_report_reference": '00002907-0000-1000-8000-00805f9b34fb', 521 "report_reference": '00002908-0000-1000-8000-00805f9b34fb' 522} 523 524# https://www.bluetooth.com/specifications/gatt/characteristics 525gatt_char_types = { 526 "device_name": '00002a00-0000-1000-8000-00805f9b34fb', 527 "appearance": '00002a01-0000-1000-8000-00805f9b34fb', 528 "peripheral_priv_flag": '00002a02-0000-1000-8000-00805f9b34fb', 529 "reconnection_address": '00002a03-0000-1000-8000-00805f9b34fb', 530 "peripheral_pref_conn": '00002a04-0000-1000-8000-00805f9b34fb', 531 "service_changed": '00002a05-0000-1000-8000-00805f9b34fb', 532 "system_id": '00002a23-0000-1000-8000-00805f9b34fb', 533 "model_number_string": '00002a24-0000-1000-8000-00805f9b34fb', 534 "serial_number_string": '00002a25-0000-1000-8000-00805f9b34fb', 535 "firmware_revision_string": '00002a26-0000-1000-8000-00805f9b34fb', 536 "hardware_revision_string": '00002a27-0000-1000-8000-00805f9b34fb', 537 "software_revision_string": '00002a28-0000-1000-8000-00805f9b34fb', 538 "manufacturer_name_string": '00002a29-0000-1000-8000-00805f9b34fb', 539 "pnp_id": '00002a50-0000-1000-8000-00805f9b34fb', 540} 541 542# Matches constants of Bluetooth GATT Characteristic values as defined 543# in BluetoothGattCharacteristic.java 544gatt_characteristic_value_format = { 545 "string": 0x1, 546 "byte": 0x2, 547 "sint8": 0x21, 548 "uint8": 0x11, 549 "sint16": 0x22, 550 "unit16": 0x12, 551 "sint32": 0x24, 552 "uint32": 0x14 553} 554 555# Matches constants of Bluetooth Gatt Service types as defined in 556# BluetoothGattService.java 557gatt_service_types = {"primary": 0, "secondary": 1} 558 559# Matches constants of Bluetooth Gatt Connection Priority values as defined in 560# BluetoothGatt.java 561gatt_connection_priority = {"balanced": 0, "high": 1, "low_power": 2} 562 563# Min and max MTU values 564gatt_mtu_size = {"min": 23, "max": 217} 565 566# Gatt Characteristic attribute lengths 567gatt_characteristic_attr_length = {"attr_1": 1, "attr_2": 3, "attr_3": 15} 568 569# Matches constants of Bluetooth Gatt operations status as defined in 570# BluetoothGatt.java 571gatt_status = {"success": 0, "failure": 0x101} 572 573# Matches constants of Bluetooth transport values as defined in 574# BluetoothDevice.java 575gatt_transport = {"auto": 0x00, "bredr": 0x01, "le": 0x02} 576 577# Matches constants of Bluetooth physical channeling values as defined in 578# BluetoothDevice.java 579gatt_phy = {"1m": 1, "2m": 2, "le_coded": 3} 580 581# Matches constants of Bluetooth physical channeling bitmask values as defined 582# in BluetoothDevice.java 583gatt_phy_mask = {"1m_mask": 1, "2m_mask": 2, "coded_mask": 4} 584 585# Values as defiend in the Bluetooth GATT specification 586gatt_server_responses = { 587 "GATT_SUCCESS": 0x0, 588 "GATT_FAILURE": 0x1, 589 "GATT_READ_NOT_PERMITTED": 0x2, 590 "GATT_WRITE_NOT_PERMITTED": 0x3, 591 "GATT_INVALID_PDU": 0x4, 592 "GATT_INSUFFICIENT_AUTHENTICATION": 0x5, 593 "GATT_REQUEST_NOT_SUPPORTED": 0x6, 594 "GATT_INVALID_OFFSET": 0x7, 595 "GATT_INSUFFICIENT_AUTHORIZATION": 0x8, 596 "GATT_INVALID_ATTRIBUTE_LENGTH": 0xd, 597 "GATT_INSUFFICIENT_ENCRYPTION": 0xf, 598 "GATT_CONNECTION_CONGESTED": 0x8f, 599 "GATT_13_ERR": 0x13, 600 "GATT_12_ERR": 0x12, 601 "GATT_0C_ERR": 0x0C, 602 "GATT_16": 0x16 603} 604 605### Bluetooth GATT Constants End ### 606 607### Chameleon Constants Begin ### 608 609# Chameleon audio bits per sample. 610audio_bits_per_sample_16 = 16 611audio_bits_per_sample_24 = 24 612audio_bits_per_sample_32 = 32 613 614# Chameleon audio sample rates. 615audio_sample_rate_44100 = 44100 616audio_sample_rate_48000 = 48000 617audio_sample_rate_88200 = 88200 618audio_sample_rate_96000 = 96000 619 620# Chameleon audio channel modes. 621audio_channel_mode_mono = 1 622audio_channel_mode_stereo = 2 623audio_channel_mode_8 = 8 624 625# Chameleon time delays. 626delay_after_binding_seconds = 0.5 627delay_before_record_seconds = 0.5 628silence_wait_seconds = 5 629 630# Chameleon bus endpoints. 631fpga_linein_bus_endpoint = 'Chameleon FPGA line-in' 632headphone_bus_endpoint = 'Cros device headphone' 633 634### Chameleon Constants End ### 635 636# Begin logcat strings dict""" 637logcat_strings = { 638 "media_playback_vol_changed": "onRouteVolumeChanged", 639} 640 641# End logcat strings dict""" 642 643### Begin Service Discovery UUIDS ### 644# Values match the Bluetooth SIG defined values: """ 645""" https://www.bluetooth.com/specifications/assigned-numbers/service-discovery """ 646sig_uuid_constants = { 647 "BASE_UUID": "0000{}-0000-1000-8000-00805F9B34FB", 648 "SDP": "0001", 649 "UDP": "0002", 650 "RFCOMM": "0003", 651 "TCP": "0004", 652 "TCS-BIN": "0005", 653 "TCS-AT": "0006", 654 "ATT": "0007", 655 "OBEX": "0008", 656 "IP": "0009", 657 "FTP": "000A", 658 "HTTP": "000C", 659 "WSP": "000E", 660 "BNEP": "000F", 661 "UPNP": "0010", 662 "HIDP": "0011", 663 "HardcopyControlChannel": "0012", 664 "HardcopyDataChannel": "0014", 665 "HardcopyNotification": "0016", 666 "AVCTP": "0017", 667 "AVDTP": "0019", 668 "CMTP": "001B", 669 "MCAPControlChannel": "001E", 670 "MCAPDataChannel": "001F", 671 "L2CAP": "0100", 672 "ServiceDiscoveryServerServiceClassID": "1000", 673 "BrowseGroupDescriptorServiceClassID": "1001", 674 "SerialPort": "1101", 675 "LANAccessUsingPPP": "1102", 676 "DialupNetworking": "1103", 677 "IrMCSync": "1104", 678 "OBEXObjectPush": "1105", 679 "OBEXFileTransfer": "1106", 680 "IrMCSyncCommand": "1107", 681 "Headset": "1108", 682 "CordlessTelephony": "1109", 683 "AudioSource": "110A", 684 "AudioSink": "110B", 685 "A/V_RemoteControlTarget": "110C", 686 "AdvancedAudioDistribution": "110D", 687 "A/V_RemoteControl": "110E", 688 "A/V_RemoteControlController": "110F", 689 "Intercom": "1110", 690 "Fax": "1111", 691 "Headset - Audio Gateway (AG)": "1112", 692 "WAP": "1113", 693 "WAP_CLIENT": "1114", 694 "PANU": "1115", 695 "NAP": "1116", 696 "GN": "1117", 697 "DirectPrinting": "1118", 698 "ReferencePrinting": "1119", 699 "ImagingResponder": "111B", 700 "ImagingAutomaticArchive": "111C", 701 "ImagingReferencedObjects": "111D", 702 "Handsfree": "111E", 703 "HandsfreeAudioGateway": "111F", 704 "DirectPrintingReferenceObjectsService": "1120", 705 "ReflectedUI": "1121", 706 "BasicPrinting": "1122", 707 "PrintingStatus": "1123", 708 "HumanInterfaceDeviceService": "1124", 709 "HardcopyCableReplacement": "1125", 710 "HCR_Print": "1126", 711 "HCR_Scan": "1127", 712 "Common_ISDN_Access": "1128", 713 "SIM_Access": "112D", 714 "Phonebook Access - PCE": "112E", 715 "Phonebook Access - PSE": "112F", 716 "Phonebook Access": "1130", 717 "Headset - HS": "1131", 718 "Message Access Server": "1132", 719 "Message Notification Server": "1133", 720 "Message Access Profile": "1134", 721 "GNSS": "1135", 722 "GNSS_Server": "1136", 723 "PnPInformation": "1200", 724 "GenericNetworking": "1201", 725 "GenericFileTransfer": "1202", 726 "GenericAudio": "1203", 727 "GenericTelephony": "1204", 728 "UPNP_Service": "1205", 729 "UPNP_IP_Service": "1206", 730 "ESDP_UPNP_IP_PAN": "1300", 731 "ESDP_UPNP_IP_LAP": "1301", 732 "ESDP_UPNP_L2CAP": "1302", 733 "VideoSource": "1303", 734 "VideoSink": "1304", 735 "VideoDistribution": "1305", 736 "HDP": "1400" 737} 738 739### End Service Discovery UUIDS ### 740 741 742# Attribute Record values from the Bluetooth Specification 743# Version 5, Vol 3, Part B 744bt_attribute_values = { 745 'ATTR_SERVICE_RECORD_HANDLE': 0x0000, 746 'ATTR_SERVICE_CLASS_ID_LIST': 0x0001, 747 'ATTR_SERVICE_RECORD_STATE': 0x0002, 748 'ATTR_SERVICE_ID': 0x0003, 749 'ATTR_PROTOCOL_DESCRIPTOR_LIST': 0x0004, 750 'ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LIST': 0x000D, 751 'ATTR_BROWSE_GROUP_LIST': 0x0005, 752 'ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST': 0x0006, 753 'ATTR_SERVICE_INFO_TIME_TO_LIVE': 0x0007, 754 'ATTR_SERVICE_AVAILABILITY': 0x0008, 755 'ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST': 0x0009, 756 'ATTR_A2DP_SUPPORTED_FEATURES': 0x0311, 757} 758