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