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 service uuids for specific devices 286ble_uuids = { 287 "p_service": "0000feef-0000-1000-8000-00805f9b34fb", 288 "hr_service": "0000180d-0000-1000-8000-00805f9b34fb" 289} 290 291# Bluetooth Low Energy advertising error codes 292ble_advertise_error_code = { 293 "data_too_large": 1, 294 "too_many_advertisers": 2, 295 "advertisement_already_started": 3, 296 "bluetooth_internal_failure": 4, 297 "feature_not_supported": 5 298} 299 300### Bluetooth Low Energy Constants End ### 301 302### Bluetooth GATT Constants Begin ### 303 304# Gatt Callback error messages 305gatt_cb_err = { 306 "char_write_req_err": 307 "Characteristic Write Request event not found. Expected {}", 308 "char_write_err": "Characteristic Write event not found. Expected {}", 309 "desc_write_req_err": 310 "Descriptor Write Request event not found. Expected {}", 311 "desc_write_err": "Descriptor Write event not found. Expected {}", 312 "char_read_err": "Characteristic Read event not found. Expected {}", 313 "char_read_req_err": "Characteristic Read Request not found. Expected {}", 314 "desc_read_err": "Descriptor Read event not found. Expected {}", 315 "desc_read_req_err": 316 "Descriptor Read Request event not found. Expected {}", 317 "rd_remote_rssi_err": "Read Remote RSSI event not found. Expected {}", 318 "gatt_serv_disc_err": 319 "GATT Services Discovered event not found. Expected {}", 320 "serv_added_err": "Service Added event not found. Expected {}", 321 "mtu_changed_err": "MTU Changed event not found. Expected {}", 322 "mtu_serv_changed_err": "MTU Server Changed event not found. Expected {}", 323 "gatt_conn_changed_err": 324 "GATT Connection Changed event not found. Expected {}", 325 "char_change_err": 326 "GATT Characteristic Changed event not fond. Expected {}", 327 "phy_read_err": "Phy Read event not fond. Expected {}", 328 "phy_update_err": "Phy Update event not fond. Expected {}", 329 "exec_write_err": "GATT Execute Write event not found. Expected {}" 330} 331 332# GATT callback strings as defined in GattClientFacade.java and 333# GattServerFacade.java implemented callbacks. 334gatt_cb_strings = { 335 "char_write_req": "GattServer{}onCharacteristicWriteRequest", 336 "exec_write": "GattServer{}onExecuteWrite", 337 "char_write": "GattConnect{}onCharacteristicWrite", 338 "desc_write_req": "GattServer{}onDescriptorWriteRequest", 339 "desc_write": "GattConnect{}onDescriptorWrite", 340 "char_read": "GattConnect{}onCharacteristicRead", 341 "char_read_req": "GattServer{}onCharacteristicReadRequest", 342 "desc_read": "GattConnect{}onDescriptorRead", 343 "desc_read_req": "GattServer{}onDescriptorReadRequest", 344 "rd_remote_rssi": "GattConnect{}onReadRemoteRssi", 345 "gatt_serv_disc": "GattConnect{}onServicesDiscovered", 346 "serv_added": "GattServer{}onServiceAdded", 347 "mtu_changed": "GattConnect{}onMtuChanged", 348 "mtu_serv_changed": "GattServer{}onMtuChanged", 349 "gatt_conn_change": "GattConnect{}onConnectionStateChange", 350 "char_change": "GattConnect{}onCharacteristicChanged", 351 "phy_read": "GattConnect{}onPhyRead", 352 "phy_update": "GattConnect{}onPhyUpdate", 353 "serv_phy_read": "GattServer{}onPhyRead", 354 "serv_phy_update": "GattServer{}onPhyUpdate", 355} 356 357# GATT event dictionary of expected callbacks and errors. 358gatt_event = { 359 "char_write_req": { 360 "evt": gatt_cb_strings["char_write_req"], 361 "err": gatt_cb_err["char_write_req_err"] 362 }, 363 "exec_write": { 364 "evt": gatt_cb_strings["exec_write"], 365 "err": gatt_cb_err["exec_write_err"] 366 }, 367 "char_write": { 368 "evt": gatt_cb_strings["char_write"], 369 "err": gatt_cb_err["char_write_err"] 370 }, 371 "desc_write_req": { 372 "evt": gatt_cb_strings["desc_write_req"], 373 "err": gatt_cb_err["desc_write_req_err"] 374 }, 375 "desc_write": { 376 "evt": gatt_cb_strings["desc_write"], 377 "err": gatt_cb_err["desc_write_err"] 378 }, 379 "char_read": { 380 "evt": gatt_cb_strings["char_read"], 381 "err": gatt_cb_err["char_read_err"] 382 }, 383 "char_read_req": { 384 "evt": gatt_cb_strings["char_read_req"], 385 "err": gatt_cb_err["char_read_req_err"] 386 }, 387 "desc_read": { 388 "evt": gatt_cb_strings["desc_read"], 389 "err": gatt_cb_err["desc_read_err"] 390 }, 391 "desc_read_req": { 392 "evt": gatt_cb_strings["desc_read_req"], 393 "err": gatt_cb_err["desc_read_req_err"] 394 }, 395 "rd_remote_rssi": { 396 "evt": gatt_cb_strings["rd_remote_rssi"], 397 "err": gatt_cb_err["rd_remote_rssi_err"] 398 }, 399 "gatt_serv_disc": { 400 "evt": gatt_cb_strings["gatt_serv_disc"], 401 "err": gatt_cb_err["gatt_serv_disc_err"] 402 }, 403 "serv_added": { 404 "evt": gatt_cb_strings["serv_added"], 405 "err": gatt_cb_err["serv_added_err"] 406 }, 407 "mtu_changed": { 408 "evt": gatt_cb_strings["mtu_changed"], 409 "err": gatt_cb_err["mtu_changed_err"] 410 }, 411 "gatt_conn_change": { 412 "evt": gatt_cb_strings["gatt_conn_change"], 413 "err": gatt_cb_err["gatt_conn_changed_err"] 414 }, 415 "char_change": { 416 "evt": gatt_cb_strings["char_change"], 417 "err": gatt_cb_err["char_change_err"] 418 }, 419 "phy_read": { 420 "evt": gatt_cb_strings["phy_read"], 421 "err": gatt_cb_err["phy_read_err"] 422 }, 423 "phy_update": { 424 "evt": gatt_cb_strings["phy_update"], 425 "err": gatt_cb_err["phy_update_err"] 426 }, 427 "serv_phy_read": { 428 "evt": gatt_cb_strings["serv_phy_read"], 429 "err": gatt_cb_err["phy_read_err"] 430 }, 431 "serv_phy_update": { 432 "evt": gatt_cb_strings["serv_phy_update"], 433 "err": gatt_cb_err["phy_update_err"] 434 } 435} 436 437# Matches constants of connection states defined in BluetoothGatt.java 438gatt_connection_state = { 439 "disconnected": 0, 440 "connecting": 1, 441 "connected": 2, 442 "disconnecting": 3, 443 "closed": 4 444} 445 446# Matches constants of Bluetooth GATT Characteristic values as defined 447# in BluetoothGattCharacteristic.java 448gatt_characteristic = { 449 "property_broadcast": 0x01, 450 "property_read": 0x02, 451 "property_write_no_response": 0x04, 452 "property_write": 0x08, 453 "property_notify": 0x10, 454 "property_indicate": 0x20, 455 "property_signed_write": 0x40, 456 "property_extended_props": 0x80, 457 "permission_read": 0x01, 458 "permission_read_encrypted": 0x02, 459 "permission_read_encrypted_mitm": 0x04, 460 "permission_write": 0x10, 461 "permission_write_encrypted": 0x20, 462 "permission_write_encrypted_mitm": 0x40, 463 "permission_write_signed": 0x80, 464 "permission_write_signed_mitm": 0x100, 465 "write_type_default": 0x02, 466 "write_type_no_response": 0x01, 467 "write_type_signed": 0x04, 468} 469 470# Matches constants of Bluetooth GATT Characteristic values as defined 471# in BluetoothGattDescriptor.java 472gatt_descriptor = { 473 "enable_notification_value": [0x01, 0x00], 474 "enable_indication_value": [0x02, 0x00], 475 "disable_notification_value": [0x00, 0x00], 476 "permission_read": 0x01, 477 "permission_read_encrypted": 0x02, 478 "permission_read_encrypted_mitm": 0x04, 479 "permission_write": 0x10, 480 "permission_write_encrypted": 0x20, 481 "permission_write_encrypted_mitm": 0x40, 482 "permission_write_signed": 0x80, 483 "permission_write_signed_mitm": 0x100 484} 485 486# https://www.bluetooth.com/specifications/gatt/descriptors 487gatt_char_desc_uuids = { 488 "char_ext_props": '00002900-0000-1000-8000-00805f9b34fb', 489 "char_user_desc": '00002901-0000-1000-8000-00805f9b34fb', 490 "client_char_cfg": '00002902-0000-1000-8000-00805f9b34fb', 491 "server_char_cfg": '00002903-0000-1000-8000-00805f9b34fb', 492 "char_fmt_uuid": '00002904-0000-1000-8000-00805f9b34fb', 493 "char_agreg_fmt": '00002905-0000-1000-8000-00805f9b34fb', 494 "char_valid_range": '00002906-0000-1000-8000-00805f9b34fb', 495 "external_report_reference": '00002907-0000-1000-8000-00805f9b34fb', 496 "report_reference": '00002908-0000-1000-8000-00805f9b34fb' 497} 498 499# https://www.bluetooth.com/specifications/gatt/characteristics 500gatt_char_types = { 501 "device_name": '00002a00-0000-1000-8000-00805f9b34fb', 502 "appearance": '00002a01-0000-1000-8000-00805f9b34fb', 503 "peripheral_priv_flag": '00002a02-0000-1000-8000-00805f9b34fb', 504 "reconnection_address": '00002a03-0000-1000-8000-00805f9b34fb', 505 "peripheral_pref_conn": '00002a04-0000-1000-8000-00805f9b34fb', 506 "service_changed": '00002a05-0000-1000-8000-00805f9b34fb', 507 "system_id": '00002a23-0000-1000-8000-00805f9b34fb', 508 "model_number_string": '00002a24-0000-1000-8000-00805f9b34fb', 509 "serial_number_string": '00002a25-0000-1000-8000-00805f9b34fb', 510 "firmware_revision_string": '00002a26-0000-1000-8000-00805f9b34fb', 511 "hardware_revision_string": '00002a27-0000-1000-8000-00805f9b34fb', 512 "software_revision_string": '00002a28-0000-1000-8000-00805f9b34fb', 513 "manufacturer_name_string": '00002a29-0000-1000-8000-00805f9b34fb', 514 "pnp_id": '00002a50-0000-1000-8000-00805f9b34fb', 515} 516 517# Matches constants of Bluetooth GATT Characteristic values as defined 518# in BluetoothGattCharacteristic.java 519gatt_characteristic_value_format = { 520 "string": 0x1, 521 "byte": 0x2, 522 "sint8": 0x21, 523 "uint8": 0x11, 524 "sint16": 0x22, 525 "unit16": 0x12, 526 "sint32": 0x24, 527 "uint32": 0x14 528} 529 530# Matches constants of Bluetooth Gatt Service types as defined in 531# BluetoothGattService.java 532gatt_service_types = {"primary": 0, "secondary": 1} 533 534# Matches constants of Bluetooth Gatt Connection Priority values as defined in 535# BluetoothGatt.java 536gatt_connection_priority = {"balanced": 0, "high": 1, "low_power": 2} 537 538# Min and max MTU values 539gatt_mtu_size = {"min": 23, "max": 217} 540 541# Gatt Characteristic attribute lengths 542gatt_characteristic_attr_length = {"attr_1": 1, "attr_2": 3, "attr_3": 15} 543 544# Matches constants of Bluetooth Gatt operations status as defined in 545# BluetoothGatt.java 546gatt_status = {"success": 0, "failure": 0x101} 547 548# Matches constants of Bluetooth transport values as defined in 549# BluetoothDevice.java 550gatt_transport = {"auto": 0x00, "bredr": 0x01, "le": 0x02} 551 552# Matches constants of Bluetooth physical channeling values as defined in 553# BluetoothDevice.java 554gatt_phy = {"1m": 1, "2m": 2, "le_coded": 3} 555 556# Matches constants of Bluetooth physical channeling bitmask values as defined 557# in BluetoothDevice.java 558gatt_phy_mask = {"1m_mask": 1, "2m_mask": 2, "coded_mask": 4} 559 560# Values as defiend in the Bluetooth GATT specification 561gatt_server_responses = { 562 "GATT_SUCCESS": 0x0, 563 "GATT_FAILURE": 0x1, 564 "GATT_READ_NOT_PERMITTED": 0x2, 565 "GATT_WRITE_NOT_PERMITTED": 0x3, 566 "GATT_INVALID_PDU": 0x4, 567 "GATT_INSUFFICIENT_AUTHENTICATION": 0x5, 568 "GATT_REQUEST_NOT_SUPPORTED": 0x6, 569 "GATT_INVALID_OFFSET": 0x7, 570 "GATT_INSUFFICIENT_AUTHORIZATION": 0x8, 571 "GATT_INVALID_ATTRIBUTE_LENGTH": 0xd, 572 "GATT_INSUFFICIENT_ENCRYPTION": 0xf, 573 "GATT_CONNECTION_CONGESTED": 0x8f, 574 "GATT_13_ERR": 0x13, 575 "GATT_12_ERR": 0x12, 576 "GATT_0C_ERR": 0x0C, 577 "GATT_16": 0x16 578} 579 580### Bluetooth GATT Constants End ### 581 582### Chameleon Constants Begin ### 583 584# Chameleon audio bits per sample. 585audio_bits_per_sample_16 = 16 586audio_bits_per_sample_24 = 24 587audio_bits_per_sample_32 = 32 588 589# Chameleon audio sample rates. 590audio_sample_rate_44100 = 44100 591audio_sample_rate_48000 = 48000 592audio_sample_rate_88200 = 88200 593audio_sample_rate_96000 = 96000 594 595# Chameleon audio channel modes. 596audio_channel_mode_mono = 1 597audio_channel_mode_stereo = 2 598audio_channel_mode_8 = 8 599 600# Chameleon time delays. 601delay_after_binding_seconds = 0.5 602delay_before_record_seconds = 0.5 603silence_wait_seconds = 5 604 605# Chameleon bus endpoints. 606fpga_linein_bus_endpoint = 'Chameleon FPGA line-in' 607headphone_bus_endpoint = 'Cros device headphone' 608 609### Chameleon Constants End ### 610 611# Begin logcat strings dict""" 612logcat_strings = { 613 "media_playback_vol_changed": "onRouteVolumeChanged", 614} 615 616# End logcat strings dict""" 617 618### Begin Service Discovery UUIDS ### 619# Values match the Bluetooth SIG defined values: """ 620""" https://www.bluetooth.com/specifications/assigned-numbers/service-discovery """ 621sig_uuid_constants = { 622 "BASE_UUID": "0000{}-0000-1000-8000-00805F9B34FB", 623 "SDP": "0001", 624 "UDP": "0002", 625 "RFCOMM": "0003", 626 "TCP": "0004", 627 "TCS-BIN": "0005", 628 "TCS-AT": "0006", 629 "ATT": "0007", 630 "OBEX": "0008", 631 "IP": "0009", 632 "FTP": "000A", 633 "HTTP": "000C", 634 "WSP": "000E", 635 "BNEP": "000F", 636 "UPNP": "0010", 637 "HIDP": "0011", 638 "HardcopyControlChannel": "0012", 639 "HardcopyDataChannel": "0014", 640 "HardcopyNotification": "0016", 641 "AVCTP": "0017", 642 "AVDTP": "0019", 643 "CMTP": "001B", 644 "MCAPControlChannel": "001E", 645 "MCAPDataChannel": "001F", 646 "L2CAP": "0100", 647 "ServiceDiscoveryServerServiceClassID": "1000", 648 "BrowseGroupDescriptorServiceClassID": "1001", 649 "SerialPort": "1101", 650 "LANAccessUsingPPP": "1102", 651 "DialupNetworking": "1103", 652 "IrMCSync": "1104", 653 "OBEXObjectPush": "1105", 654 "OBEXFileTransfer": "1106", 655 "IrMCSyncCommand": "1107", 656 "Headset": "1108", 657 "CordlessTelephony": "1109", 658 "AudioSource": "110A", 659 "AudioSink": "110B", 660 "A/V_RemoteControlTarget": "110C", 661 "AdvancedAudioDistribution": "110D", 662 "A/V_RemoteControl": "110E", 663 "A/V_RemoteControlController": "110F", 664 "Intercom": "1110", 665 "Fax": "1111", 666 "Headset - Audio Gateway (AG)": "1112", 667 "WAP": "1113", 668 "WAP_CLIENT": "1114", 669 "PANU": "1115", 670 "NAP": "1116", 671 "GN": "1117", 672 "DirectPrinting": "1118", 673 "ReferencePrinting": "1119", 674 "ImagingResponder": "111B", 675 "ImagingAutomaticArchive": "111C", 676 "ImagingReferencedObjects": "111D", 677 "Handsfree": "111E", 678 "HandsfreeAudioGateway": "111F", 679 "DirectPrintingReferenceObjectsService": "1120", 680 "ReflectedUI": "1121", 681 "BasicPrinting": "1122", 682 "PrintingStatus": "1123", 683 "HumanInterfaceDeviceService": "1124", 684 "HardcopyCableReplacement": "1125", 685 "HCR_Print": "1126", 686 "HCR_Scan": "1127", 687 "Common_ISDN_Access": "1128", 688 "SIM_Access": "112D", 689 "Phonebook Access - PCE": "112E", 690 "Phonebook Access - PSE": "112F", 691 "Phonebook Access": "1130", 692 "Headset - HS": "1131", 693 "Message Access Server": "1132", 694 "Message Notification Server": "1133", 695 "Message Access Profile": "1134", 696 "GNSS": "1135", 697 "GNSS_Server": "1136", 698 "PnPInformation": "1200", 699 "GenericNetworking": "1201", 700 "GenericFileTransfer": "1202", 701 "GenericAudio": "1203", 702 "GenericTelephony": "1204", 703 "UPNP_Service": "1205", 704 "UPNP_IP_Service": "1206", 705 "ESDP_UPNP_IP_PAN": "1300", 706 "ESDP_UPNP_IP_LAP": "1301", 707 "ESDP_UPNP_L2CAP": "1302", 708 "VideoSource": "1303", 709 "VideoSink": "1304", 710 "VideoDistribution": "1305", 711 "HDP": "1400" 712} 713 714### End Service Discovery UUIDS ### 715 716### Begin Appearance Constants ### 717# https://www.bluetooth.com/wp-content/uploads/Sitecore-Media-Library/Gatt/Xml/Characteristics/org.bluetooth.characteristic.gap.appearance.xml 718sig_appearance_constants = { 719 "UNKNOWN": 0, 720 "PHONE": 64, 721 "COMPUTER": 128, 722 "WATCH": 192, 723 "WATCH_SPORTS": 193, 724 "CLOCK": 256, 725 "DISPLAY": 320, 726 "REMOTE_CONTROL": 384, 727 "EYE_GLASSES": 448, 728 "TAG": 512, 729 "KEYRING": 576, 730 "MEDIA_PLAYER": 640, 731 "BARCODE_SCANNER": 704, 732 "THERMOMETER": 768, 733 "THERMOMETER_EAR": 769, 734 "HEART_RATE_SENSOR": 832, 735 "HEART_RATE_SENSOR_BELT": 833, 736 "BLOOD_PRESSURE": 896, 737 "BLOOD_PRESSURE_ARM": 897, 738 "BLOOD_PRESSURE_WRIST": 898, 739 "HID": 960, 740 "HID_KEYBOARD": 961, 741 "HID_MOUSE": 962, 742 "HID_JOYSTICK": 963, 743 "HID_GAMEPAD": 964, 744 "HID_DIGITIZER_TABLET": 965, 745 "HID_CARD_READER": 966, 746 "HID_DIGITAL_PEN": 967, 747 "HID_BARCODE_SCANNER": 968, 748 "GLUCOSE_METER": 1024, 749 "RUNNING_WALKING_SENSOR": 1088, 750 "RUNNING_WALKING_SENSOR_IN_SHOE": 1089, 751 "RUNNING_WALKING_SENSOR_ON_SHOE": 1090, 752 "RUNNING_WALKING_SENSOR_ON_HIP": 1091, 753 "CYCLING": 1152, 754 "CYCLING_COMPUTER": 1153, 755 "CYCLING_SPEED_SENSOR": 1154, 756 "CYCLING_CADENCE_SENSOR": 1155, 757 "CYCLING_POWER_SENSOR": 1156, 758 "CYCLING_SPEED_AND_CADENCE_SENSOR": 1157, 759 "PULSE_OXIMETER": 3136, 760 "PULSE_OXIMETER_FINGERTIP": 3137, 761 "PULSE_OXIMETER_WRIST": 3138, 762 "WEIGHT_SCALE": 3200, 763 "PERSONAL_MOBILITY": 3264, 764 "PERSONAL_MOBILITY_WHEELCHAIR": 3265, 765 "PERSONAL_MOBILITY_SCOOTER": 3266, 766 "GLUCOSE_MONITOR": 3328, 767 "SPORTS_ACTIVITY": 5184, 768 "SPORTS_ACTIVITY_LOCATION_DISPLAY": 5185, 769 "SPORTS_ACTIVITY_LOCATION_AND_NAV_DISPLAY": 5186, 770 "SPORTS_ACTIVITY_LOCATION_POD": 5187, 771 "SPORTS_ACTIVITY_LOCATION_AND_NAV_POD": 5188, 772} 773 774### End Appearance Constants ### 775 776# Attribute Record values from the Bluetooth Specification 777# Version 5, Vol 3, Part B 778bt_attribute_values = { 779 'ATTR_SERVICE_RECORD_HANDLE': 0x0000, 780 'ATTR_SERVICE_CLASS_ID_LIST': 0x0001, 781 'ATTR_SERVICE_RECORD_STATE': 0x0002, 782 'ATTR_SERVICE_ID': 0x0003, 783 'ATTR_PROTOCOL_DESCRIPTOR_LIST': 0x0004, 784 'ATTR_ADDITIONAL_PROTOCOL_DESCRIPTOR_LIST': 0x000D, 785 'ATTR_BROWSE_GROUP_LIST': 0x0005, 786 'ATTR_LANGUAGE_BASE_ATTRIBUTE_ID_LIST': 0x0006, 787 'ATTR_SERVICE_INFO_TIME_TO_LIVE': 0x0007, 788 'ATTR_SERVICE_AVAILABILITY': 0x0008, 789 'ATTR_BLUETOOTH_PROFILE_DESCRIPTOR_LIST': 0x0009, 790 'ATTR_A2DP_SUPPORTED_FEATURES': 0x0311, 791} 792