1# Copyright 2023 The Pigweed Authors 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# https://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15# This file contains Emboss packet definitions for extensions to the Bluetooth 16# Host-Controller interface. These extensions are not standardized through the 17# Bluetooth SIG. 18# 19# NOTE: The definitions below are incomplete. They get added as needed. 20# This list will grow as we support more vendor features. 21 22import "pw_bluetooth/hci_common.emb" as hci 23 24[$default byte_order: "LittleEndian"] 25[(cpp) namespace: "pw::bluetooth::vendor::android_hci"] 26# ======================= Android HCI extensions =============================== 27# Documentation: https://source.android.com/devices/bluetooth/hci_requirements 28 29 30# ------------------------ HCI packet headers ---------------------------------- 31 32 33struct AndroidCommandHeader: 34 -- HCI Vendor Command packet header. 35 let hdr_size = hci.CommandHeader.$size_in_bytes 36 0 [+hdr_size] hci.CommandHeader header 37 $next [+1] UInt sub_opcode 38 39# ----------------------- Get Vendor Capabilities ------------------------------ 40 41 42enum Capability: 43 [maximum_bits: 8] 44 NOT_CAPABLE = 0x00 45 CAPABLE = 0x01 46 47 48struct LEGetVendorCapabilitiesCommand: 49 let hdr_size = hci.CommandHeader.$size_in_bytes 50 0 [+hdr_size] hci.CommandHeader header 51 52 53struct LEGetVendorCapabilitiesCommandCompleteEvent: 54 # NOTE: There can be various versions of this command complete event sent by 55 # the Controller. As fields are added, the version_supported field is 56 # incremented to signify which fields are available. The version_supported 57 # field was only introduced into the command in Version 0.95. Controllers that 58 # use the base version, Version 0.55, don't have the version_supported field. 59 # 60 # NOTE(https://pwrev.dev/203950): In a previous undertaking, we attempted to 61 # use Emboss' conditional fields feature to conditionally define fields based 62 # on the version they are included in. However, in practice 63 # (https://fxbug.dev/332924195#comment6), we've found vendors sometimes send 64 # the wrong number of bytes for the version they are claiming to send. To 65 # tolerate these types of errors without issue, we simply define all the 66 # fields in Emboss and do error checking more manually. 67 # 68 # NOTE: Android's definition for this command complete event is available in 69 # AOSP: LeGetVendorCapabilitiesComplete and friends 70 # https://cs.android.com/android/platform/superproject/+/main:packages/modules/Bluetooth/system/gd/hci/hci_packets.pdl 71 # 72 # NOTE: An example implementation of how this command is filled in by a 73 # Controller is available within AOSP: 74 # le_get_vendor_capabilities_handler(...) 75 # https://cs.android.com/android/platform/superproject/main/+/main:packages/modules/Bluetooth/system/gd/hci/controller.cc 76 let hdr_size = hci.CommandCompleteEvent.$size_in_bytes 77 0 [+hdr_size] hci.CommandCompleteEvent command_complete 78 # Version 0.55 79 # NOTE(https://github.com/google/emboss/issues/132): Emboss doesn't currently 80 # support using the $next keyword here. 81 let version_0_55_size = command_complete.$size_in_bytes+9 82 $next [+1] hci.StatusCode status 83 $next [+1] UInt max_advt_instances 84 -- Number of advertisement instances supported 85 -- Deprecated in Google feature spec v0.98 and higher 86 87 $next [+1] Capability offloaded_resolution_of_private_address 88 -- BT chip capability of RPA 89 -- Deprecated in Google feature spec v0.98 and higher 90 91 $next [+2] UInt total_scan_results_storage 92 -- Storage for scan results in bytes 93 94 $next [+1] UInt max_irk_list_sz 95 -- Number of IRK entries supported in the firmware 96 97 $next [+1] Capability filtering_support 98 -- Support for filtering in the controller 99 100 $next [+1] UInt max_filter 101 -- Number of filters supported 102 103 $next [+1] Capability activity_energy_info_support 104 -- Supports reporting of activity and energy information 105 106 # Version 0.95 107 let version_0_95_size = version_0_55_size+6 108 $next [+2] bits version_supported: 109 -- Specifies the version of the Google feature spec supported 110 0 [+8] UInt major_number 111 $next [+8] UInt minor_number 112 113 $next [+2] UInt total_num_of_advt_tracked 114 -- Total number of advertisers tracked for OnLost/OnFound purposes 115 116 $next [+1] Capability extended_scan_support 117 -- Supports extended scan window and interval 118 119 $next [+1] Capability debug_logging_supported 120 -- Supports logging of binary debug information from controller 121 122 # Version 0.96 123 let version_0_96_size = version_0_95_size+1 124 $next [+1] Capability le_address_generation_offloading_support 125 -- Deprecated in Google feature spec v0.98 and higher 126 127 # Version 0.98 128 let version_0_98_size = version_0_96_size+5 129 $next [+4] bits: 130 0 [+5] AudioCodecSupportMask a2dp_source_offload_capability_mask 131 132 $next [+1] Capability bluetooth_quality_report_support 133 -- Supports reporting of Bluetooth Quality events 134 135 # Version 1.03 136 let version_1_03_size = version_0_98_size+4 137 $next [+4] bits: 138 0 [+5] AudioCodecSupportMask dynamic_audio_buffer_support 139 140 # Version 1.04 141 let version_1_04_size = version_1_03_size+1 142 $next [+1] Capability a2dp_offload_v2_support 143 144# ----------------------- A2DP Offloading -------------------------------------- 145 146 147bits AudioCodecSupportMask: 148 0 [+1] Flag sbc 149 1 [+1] Flag aac 150 2 [+1] Flag aptx 151 3 [+1] Flag aptx_hd 152 4 [+1] Flag ldac 153 154 155enum A2dpCodecType: 156 [maximum_bits: 8] 157 SBC = 0x01 158 AAC = 0x02 159 APTX = 0x04 160 APTX_HD = 0x08 161 LDAC = 0x10 162 163 164struct A2dpScmsTEnable: 165 0 [+1] hci.GenericEnableParam enabled 166 $next [+1] UInt header 167 168 169enum A2dpSamplingFrequency: 170 [maximum_bits: 8] 171 HZ_44100 = 0x01 172 HZ_48000 = 0x02 173 HZ_88200 = 0x04 174 HZ_96000 = 0x08 175 176 177enum A2dpBitsPerSample: 178 [maximum_bits: 8] 179 BITS_PER_SAMPLE_16 = 0x01 180 BITS_PER_SAMPLE_24 = 0x02 181 BITS_PER_SAMPLE_32 = 0x04 182 183 184enum A2dpChannelMode: 185 [maximum_bits: 8] 186 MONO = 0x01 187 STEREO = 0x02 188 189 190enum SbcSamplingFrequency: 191 [maximum_bits: 4] 192 HZ_48000 = 0x01 193 HZ_44100 = 0x02 194 HZ_32000 = 0x04 195 HZ_16000 = 0x08 196 197 198enum SbcChannelMode: 199 [maximum_bits: 4] 200 JOINT_STEREO = 0x01 201 STEREO = 0x02 202 DUAL_CHANNEL = 0x04 203 MONO = 0x08 204 205 206enum SbcBlockLen: 207 [maximum_bits: 4] 208 BLOCK_LEN_16 = 0x01 209 BLOCK_LEN_12 = 0x02 210 BLOCK_LEN_8 = 0x04 211 BLOCK_LEN_4 = 0x08 212 213 214enum SbcSubBands: 215 [maximum_bits: 2] 216 SUBBANDS_8 = 0x01 217 SUBBANDS_4 = 0x02 218 219 220enum SbcAllocationMethod: 221 [maximum_bits: 2] 222 LOUDNESS = 0x01 223 SNR = 0x02 224 225 226enum AacEnableVariableBitRate: 227 -- 1-octet boolean "enable"/"disable" parameter for AAC variable bitrate 228 [maximum_bits: 8] 229 DISABLE = 0x00 230 ENABLE = 0x80 231 232 233enum LdacBitrateIndex: 234 -- Values 0x03 - 0x7E are reserved 235 -- Values 0x80 - 0xFF are reserved 236 [maximum_bits: 8] 237 HIGH = 0x00 238 MID = 0x01 239 LOW = 0x02 240 ADAPTIVE_BITRATE = 0x7F 241 242 243bits LdacChannelMode: 244 -- Bitmask values for LDAC Channel Mode 245 0 [+1] Flag stereo 246 1 [+1] Flag dual 247 2 [+1] Flag mono 248 249 250struct SbcCodecInformation: 251 0 [+1] bits: 252 0 [+2] SbcAllocationMethod allocation_method 253 $next [+2] SbcSubBands subbands 254 $next [+4] SbcBlockLen block_length 255 256 $next [+1] UInt min_bitpool_value 257 $next [+1] UInt max_bitpool_value 258 $next [+1] bits: 259 0 [+4] SbcChannelMode channel_mode 260 $next [+4] SbcSamplingFrequency sampling_frequency 261 262 $next [+28] UInt:8[28] reserved 263 264 265struct AacCodecInformation: 266 0 [+1] UInt object_type 267 $next [+1] AacEnableVariableBitRate variable_bit_rate 268 $next [+30] UInt:8[30] reserved 269 270 271struct LdacCodecInformation: 272 0 [+4] UInt vendor_id 273 -- Must always be set to kLdacVendorId 274 275 $next [+2] UInt codec_id 276 -- Must always be set to kLdacCodecId 277 -- All other values are reserved 278 279 $next [+1] LdacBitrateIndex bitrate_index 280 -- See enum class LdacBitrateIndex in this file for possible values 281 282 $next [+1] bits: 283 0 [+3] LdacChannelMode ldac_channel_mode 284 -- Bitmask: LDAC channel mode (see LdacChannelMode for bitmask values) 285 286 $next [+24] UInt:8[24] reserved 287 288 289struct AptxCodecInformation: 290 0 [+32] UInt:8[32] reserved 291 292 293enum A2dpOffloadSubOpcode: 294 START_LEGACY = 0x01 295 STOP_LEGACY = 0x02 296 START = 0x03 297 STOP = 0x04 298 299 300struct A2dpOffloadCommandCompleteEvent: 301 let hdr_size = hci.CommandCompleteEvent.$size_in_bytes 302 0 [+hdr_size] hci.CommandCompleteEvent command_complete 303 $next [+1] hci.StatusCode status 304 $next [+1] A2dpOffloadSubOpcode sub_opcode 305 306 307struct StartA2dpOffloadCommand: 308 -- TODO(b/321089008): This definition is actually the legacy version of this 309 -- command. There is a non-legacy version as well. We should rename this and 310 -- the other start/stop commands/events to indicate that it is the legacy 311 -- version. 312 313 let vendor_size = AndroidCommandHeader.$size_in_bytes 314 315 0 [+vendor_size] AndroidCommandHeader vendor_command 316 317 $next [+4] bits: 318 319 0 [+8] A2dpCodecType codec_type 320 -- See enum class A2dpCodecType in this file for possible values 321 322 $next [+2] UInt max_latency 323 -- Max latency allowed in ms. A value of zero disables flush. 324 325 $next [+2] A2dpScmsTEnable scms_t_enable 326 327 $next [+4] bits: 328 329 0 [+8] A2dpSamplingFrequency sampling_frequency 330 -- See enum class A2dpSamplingFrequency in this file for possible values 331 332 $next [+1] A2dpBitsPerSample bits_per_sample 333 -- See enum class A2dpBitsPerSample in this file for possible values 334 335 $next [+1] A2dpChannelMode channel_mode 336 -- See enum class A2dpChannelMode in this file for possible values 337 338 $next [+4] UInt encoded_audio_bitrate 339 -- The encoded audio bitrate in bits per second 340 -- 0x00000000 - The audio bitrate is not specified / unused 341 -- 0x00000001 - 0x00FFFFFF - Encoded audio bitrate in bits per second 342 -- 0x01000000 - 0xFFFFFFFF - Reserved 343 [requires: 0x00000000 <= this <= 0x00FFFFFF] 344 345 $next [+2] UInt connection_handle 346 -- Connection handle of A2DP connection being configured (only the lower 12-bits are meaningful) 347 -- Range: 0x0000 to 0x0EFF 348 [requires: 0x0000 <= this <= 0x0EFF] 349 350 $next [+2] UInt l2cap_channel_id 351 -- L2CAP channel ID to be used for this A2DP connection 352 353 $next [+2] UInt l2cap_mtu_size 354 -- Maximum size of L2CAP MTU containing encoded audio packets 355 356 if codec_type == A2dpCodecType.SBC: 357 28 [+32] SbcCodecInformation sbc_codec_information 358 359 if codec_type == A2dpCodecType.AAC: 360 28 [+32] AacCodecInformation aac_codec_information 361 362 if codec_type == A2dpCodecType.LDAC: 363 28 [+32] LdacCodecInformation ldac_codec_information 364 365 if codec_type == A2dpCodecType.APTX || codec_type == A2dpCodecType.APTX_HD: 366 28 [+32] AptxCodecInformation aptx_codec_information 367 368 369struct StopA2dpOffloadCommand: 370 -- TODO(b/321089008): This definition is actually the legacy version of this 371 -- command. There is a non-legacy version as well. We should rename this and 372 -- the other start/stop commands/events to indicate that it is the legacy 373 -- version. 374 let vendor_size = AndroidCommandHeader.$size_in_bytes 375 0 [+vendor_size] AndroidCommandHeader vendor_command 376 377# ----------------------- Bluetooth Quality Report command --------------------- 378 379 380enum BqrReportAction: 381 ADD = 0x00 382 DELETE = 0x01 383 CLEAR = 0x02 384 ONE_TIME_QUERY = 0x03 385 386 387bits BqrQualityEventMask: 388 0 [+1] Flag enable_quality_monitoring_mode 389 1 [+1] Flag enable_approaching_lsto_event 390 2 [+1] Flag enable_a2dp_audio_choppy_event 391 3 [+1] Flag enable_sco_voice_choppy_event 392 4 [+1] Flag enable_root_inflammation_event 393 5 [+1] Flag enable_energy_monitoring_mode 394 6 [+1] Flag enable_le_audio_choppy_event 395 7 [+1] Flag enable_connect_fail_event 396 8 [+1] Flag enable_advance_rf_stats_mode_event_trigger 397 9 [+1] Flag enable_advance_rf_stats_periodic_report 398 # 10 ~ 14 Reserved 399 15 [+1] Flag enable_vendor_specific_quality_events 400 16 [+1] Flag enable_lmp_ll_message_trace 401 17 [+1] Flag enable_bluetooth_multi_link_coex_scheduling_trace 402 18 [+1] Flag enable_controller_debug_information_mechanism 403 # 19 ~ 30 Reserved 404 31 [+1] Flag enable_vendor_specific_trace 405 406 407struct BluetoothQualityReportCommand: 408 0 [+hci.CommandHeader.$size_in_bytes] hci.CommandHeader header 409 410 $next [+1] BqrReportAction bqr_report_action 411 -- Action to add / delete reporting of quality event(s) set in 412 -- BQR_Quality_Event_Mask parameter, or clear all. 413 -- Delete will clear specific quality event(s) reporting. 414 -- Clear will clear all quality events reporting (BQR_Quality_Event_Mask 415 -- parameter can be ignored). 416 417 $next [+4] bits: 418 419 0 [+BqrQualityEventMask.$size_in_bits] BqrQualityEventMask bqr_quality_event_mask 420 421 $next [+2] UInt bqr_minimum_report_interval 422 -- Define the minimum time interval of quality event reporting for the 423 -- selected quality event(s). The controller Firmware should not report the 424 -- next event within the defined time interval. The interval setting shall 425 -- be respective and dedicated for the quality event(s) which are being 426 -- added. 427 -- 428 -- Unit: ms 429 -- Default: 0 (No limitation for the interval.) 430 -- Range: 0 ~ 65535 ms 431 [requires: 0 <= this <= 65535] 432 433 $next [+4] UInt bqr_vendor_specific_quality_event_mask 434 -- Bit masks for the selected vendor-specific quality event reporting. 435 -- This parameter is valid only when bit 15 of BQR_Quality_Event_Mask is 436 -- set. 437 438 $next [+4] UInt bqr_vendor_specific_trace_mask 439 -- Bit masks for the selected vendor-specific trace reporting. 440 -- This parameter is valid only when bit 31 of BQR_Quality_Event_Mask is 441 -- set. 442 443 $next [+4] UInt report_interval_multiple 444 -- The multiplier for BQR_Minimum_Report_Interval. When this value >= 1, 445 -- the BQR Report Interval follows the format BQR Report Interval = 446 -- BQR_Minimum_Report_Interval x Report_interval_multiple. The controller 447 -- Firmware must not report the next event within the defined time interval. 448 -- The interval setting is specifically dedicated for the added quality 449 -- event(s). 450 -- 451 -- Unit: ms 452 -- Default: 1 453 -- Range: 0 ~ 4294967295 (0: is equal set to 1) 454 -- 455 -- Note: if the setting of BQR_Report_Interval is larger than the ability 456 -- of the controller, the controller must return the maximum 457 -- BQR_Report_Interval time on the completion of the command. 458 459 460struct BluetoothQualityReportCommandCompleteEvent: 461 0 [+hci.CommandCompleteEvent.$size_in_bytes] hci.CommandCompleteEvent command_complete 462 $next [+1] hci.StatusCode status 463 $next [+4] bits: 464 0 [+BqrQualityEventMask.$size_in_bits] BqrQualityEventMask current_quality_event_mask 465 466 $next [+4] UInt current_vendor_specific_quality_event_mask 467 $next [+4] UInt current_vendor_specific_trace_mask 468 $next [+4] UInt bqr_report_interval 469 -- The setting of BQR_Report_interval. It must be the minimum value between 470 -- BQR_Minimum_Report_Interval * Report_interval_multiple or the maximum 471 -- support interval of the controller. 472 473# ----------------------- Multiple Advertising --------------------------------- 474 475 476enum LEMultiAdvtSubOpcode: 477 SET_ADVERTISING_PARAMETERS = 0x01 478 SET_ADVERTISING_DATA = 0x02 479 SET_SCAN_RESPONSE_DATA = 0x03 480 SET_RANDOM_ADDRESS = 0x04 481 ENABLE = 0x05 482 483 484struct LEMultiAdvtCommandCompleteEvent: 485 let hdr_size = hci.CommandCompleteEvent.$size_in_bytes 486 0 [+hdr_size] hci.CommandCompleteEvent command_complete 487 $next [+1] hci.StatusCode status 488 $next [+1] LEMultiAdvtSubOpcode sub_opcode 489 490 491struct LEMultiAdvtSetAdvtParamCommand: 492 let vendor_size = AndroidCommandHeader.$size_in_bytes 493 494 0 [+vendor_size] AndroidCommandHeader vendor_command 495 496 $next [+2] UInt adv_interval_min 497 -- Default: 0x0800 (1.28 s) 498 -- Time: N * 0.625 ms 499 -- Time Range: 20 ms to 10.24 s 500 [requires: 0x0020 <= this <= 0x4000] 501 502 $next [+2] UInt adv_interval_max 503 -- Default: 0x0800 (1.28 s) 504 -- Time: N * 0.625 ms 505 -- Time Range: 20 ms to 10.24 s 506 [requires: 0x0020 <= this <= 0x4000] 507 508 $next [+1] hci.LEAdvertisingType adv_type 509 -- Used to determine the packet type that is used for advertising when 510 -- advertising is enabled. 511 512 $next [+1] hci.LEOwnAddressType own_addr_type 513 514 $next [+hci.BdAddr.$size_in_bytes] hci.BdAddr own_address 515 -- Public Device Address, Random Device Address, Public Identity Address, or 516 -- Random (static) Identity Address of our address. 517 518 $next [+1] hci.LEPeerAddressTypeNoAnon peer_addr_type 519 520 $next [+hci.BdAddr.$size_in_bytes] hci.BdAddr peer_address 521 -- Public Device Address, Random Device Address, Public Identity Address, or 522 -- Random (static) Identity Address of the device to be connected. 523 524 $next [+1] bits: 525 526 0 [+3] hci.LEAdvertisingChannels adv_channel_map 527 -- Indicates the advertising channels that shall be used when transmitting 528 -- advertising packets. At least 1 channel must be enabled. 529 530 $next [+1] hci.LEAdvertisingFilterPolicy adv_filter_policy 531 -- This parameter shall be ignored when directed advertising is enabled. 532 533 $next [+1] UInt adv_handle 534 -- Handle used to identify an advertising set. 535 536 $next [+1] Int adv_tx_power 537 -- Transmit_Power, Unit: dBm 538 -- Range (-70 to +20) 539 [requires: -70 <= this <= 20] 540 541 542struct LEMultiAdvtSetAdvtDataCommand: 543 let vendor_size = AndroidCommandHeader.$size_in_bytes 544 0 [+vendor_size] AndroidCommandHeader vendor_command 545 $next [+1] UInt adv_data_length 546 -- Length of the advertising data included in this command packet, up to 547 -- kMaxLEAdvertisingDataLength bytes. 548 [requires: 0 <= this <= 31] 549 550 $next [+adv_data_length] UInt:8[adv_data_length] adv_data 551 $next [+1] UInt adv_handle 552 -- Handle used to identify an advertising set. 553 554 555struct LEMultiAdvtSetScanRespDataCommand: 556 let vendor_size = AndroidCommandHeader.$size_in_bytes 557 0 [+vendor_size] AndroidCommandHeader vendor_command 558 $next [+1] UInt scan_resp_length 559 -- Length of the scan response data included in this command packet, up to 560 -- kMaxLEAdvertisingDataLength bytes. 561 [requires: 0 <= this <= 31] 562 563 $next [+scan_resp_length] UInt:8[scan_resp_length] adv_data 564 $next [+1] UInt adv_handle 565 -- Handle used to identify an advertising set. 566 567 568struct LEMultiAdvtSetRandomAddrCommand: 569 let vendor_size = AndroidCommandHeader.$size_in_bytes 570 0 [+vendor_size] AndroidCommandHeader vendor_command 571 $next [+hci.BdAddr.$size_in_bytes] hci.BdAddr peer_address 572 $next [+1] UInt adv_handle 573 574 575struct LEMultiAdvtEnableCommand: 576 -- LE multi-advertising enable command. 577 let vendor_size = AndroidCommandHeader.$size_in_bytes 578 0 [+vendor_size] AndroidCommandHeader vendor_command 579 $next [+1] hci.GenericEnableParam enable 580 $next [+1] UInt advertising_handle 581 582 583struct LEMultiAdvtStateChangeSubevent: 584 -- LE multi-advertising state change subevent. 585 -- 586 -- This event indicates that an advertising instance has changed its state. At 587 -- this time, this event is only used to indicate which advertising instance 588 -- was stopped as a result of a connection. 589 let hdr_size = hci.VendorDebugEvent.$size_in_bytes 590 0 [+hdr_size] hci.VendorDebugEvent vendor_event 591 $next [+1] UInt advertising_handle 592 -- Handle used to identify an advertising set. 593 594 $next [+1] hci.StatusCode status 595 -- Reason for state change. Currently will always be 0x00. 596 -- 0x00: Connection received. 597 598 $next [+2] UInt connection_handle 599 -- Handle used to identify the connection that caused the state change (i.e. 600 -- advertising instance to be disabled). Value will be 0xFFFF if invalid. 601 602# ------------------ Advertising Packet Content Filter ------------------------- 603 604 605enum ApcfSubOpcode: 606 ENABLE = 0x00 607 SET_FILTERING_PARAMETERS = 0x01 608 BROADCAST_ADDRESS = 0x02 609 SERVICE_UUID = 0x03 610 SOLICITATION_UUID = 0x04 611 LOCAL_NAME = 0x05 612 MANUFACTURER_DATA = 0x06 613 SERVICE_DATA = 0x07 614 AD_TYPE_FILTER = 0x09 615 616 617enum ApcfAction: 618 [maximum_bits: 8] 619 ADD = 0x00 620 DELETE = 0x01 621 -- Delete will clear the specific filter along with associated feature 622 -- entries in other tables 623 624 CLEAR = 0x02 625 -- Clear will clear all the filters and associated entries in other tables 626 627 628bits ApcfFeature: 629 0 [+1] Flag broadcast_address 630 $next [+1] Flag service_data_change 631 $next [+1] Flag service_uuid 632 $next [+1] Flag service_solicitation_uuid 633 $next [+1] Flag local_name 634 $next [+1] Flag manufacturer_data 635 $next [+1] Flag service_data 636 $next [+1] Flag transport_discovery_service 637 $next [+1] Flag ad_type 638 639 640bits ApcfFeatureFilterLogic: 641 -- NOTE: These match bits 3 to 6 of ApcfFeature. 642 0 [+1] Flag unused_0 643 $next [+1] Flag unused_1 644 $next [+1] Flag unused_2 645 $next [+1] Flag service_solicitation_uuid 646 $next [+1] Flag local_name 647 $next [+1] Flag manufacturer_data 648 $next [+1] Flag service_data 649 650 651enum ApcfDeliveryMode: 652 [maximum_bits: 8] 653 654 IMMEDIATE = 0x00 655 -- Deliver a matching advertising packet immediately when the Controller sees 656 657 ON_FOUND = 0x01 658 -- Linger up to a configurable timeout (via onfound_timeout and 659 -- onfound_timeout_cnt) before delivering a matching advertising packet 660 661 BATCHED = 0x02 662 -- Deliver matching advertising packets in batch 663 664 665enum ApcfApplicationAddressType: 666 [maximum_bits: 8] 667 PUBLIC = 0x00 668 -- Public Device Address 669 670 RANDOM = 0x01 671 -- Random Device Address 672 673 NOT_APPLICABLE = 0x02 674 -- Address type not applicable 675 676 677struct LEApcfCommandCompleteEvent: 678 -- NOTE: The LEApcfCommandCompleteEvent applies to all commands except 679 -- LEApcfEnableCommand. LEApcfEnableCommand's command complete event is ever 680 -- so slightly different and has its own definition. 681 let hdr_size = hci.CommandCompleteEvent.$size_in_bytes 682 0 [+hdr_size] hci.CommandCompleteEvent command_complete 683 $next [+1] hci.StatusCode status 684 $next [+1] ApcfSubOpcode sub_opcode 685 $next [+1] ApcfAction action 686 -- Echo back of the action parameter provided in the original command 687 688 $next [+1] UInt available_spaces 689 -- Number of available entries in the Controller's filters table 690 691 692struct LEApcfEnableCommand: 693 let vendor_size = AndroidCommandHeader.$size_in_bytes 694 0 [+vendor_size] AndroidCommandHeader vendor_command 695 $next [+1] hci.GenericEnableParam enabled 696 697 698struct LEApcfEnableCommandCompleteEvent: 699 let hdr_size = hci.CommandCompleteEvent.$size_in_bytes 700 0 [+hdr_size] hci.CommandCompleteEvent command_complete 701 $next [+1] hci.StatusCode status 702 $next [+1] UInt sub_opcode 703 [requires: this == 0x00] 704 705 $next [+1] hci.GenericEnableParam enabled 706 -- Echo back of enable parameter provided in the original command 707 708 709struct LEApcfSetFilteringParametersCommand: 710 let vendor_size = AndroidCommandHeader.$size_in_bytes 711 712 0 [+vendor_size] AndroidCommandHeader vendor_command 713 714 $next [+1] ApcfAction action 715 716 $next [+1] UInt filter_index 717 -- Filter index used to identify an advertising packet content 718 -- filter. Filter indices are assigned on demand when used. 719 -- 720 -- NOTE: The maximum number of packet filters is published via the 721 -- max_filter attribute within LEGetVendorCapabilitiesCommandCompleteEvent. 722 -- 723 -- Range: (0, max_filter - 1) 724 725 $next [+2] bits: 726 727 0 [+ApcfFeature.$size_in_bits] ApcfFeature feature_selection 728 -- set of features to enable for this advertising packet content filter 729 730 $next [+2] bits: 731 732 0 [+ApcfFeature.$size_in_bits] ApcfFeature list_logic_type 733 -- Multiple instances of a filter are stored in a list within the 734 -- controller. There is a separate list for each filter type within 735 -- feature_selection. This field specifies the logic operation for each 736 -- feature selection (per-bit position) specified in 737 -- feature_selection. Valid only when a feature is enabled. 738 -- 739 -- Bit position value: 740 -- 0: OR 741 -- 1: AND 742 -- 743 -- NOTE: If AND logic is selected, an advertising packet will pass the 744 -- filter only if it contains all of the entries in the list. If OR logic is 745 -- selected, an advertising packet will pass the filter if it contains any 746 -- of the entries in the list. 747 748 $next [+1] bits: 749 750 0 [+ApcfFeatureFilterLogic.$size_in_bits] ApcfFeatureFilterLogic filter_logic_type 751 -- The controller supports multiple types of advertising packet content 752 -- filters. This field specifies the logic operation across advertising 753 -- packet content filters. 754 -- 755 -- Bit position value: 756 -- 0: OR 757 -- 1: AND 758 -- 759 -- NOTE: The logic type for the first three fields of ApcfFeatureFilterLogic is always 760 -- AND. This bitmask is only applicable for bits 3 to 6 (four fields) of 761 -- ApcfFeatureFilterLogic. 762 763 $next [+1] UInt rssi_high_threshold 764 -- An advertiser is considered seen only if the signal is higher than the 765 -- RSSI high threshold. RSSI values must use 2's complement to represent 766 -- negative values. 767 -- 768 -- Unit: dBm 769 770 $next [+1] ApcfDeliveryMode delivery_mode 771 772 $next [+2] UInt onfound_timeout 773 -- Timeout (in milliseconds) for Controller to linger and collect additional 774 -- advertisements before reporting an advertising packet. Valid only if 775 -- delivery_mode is ON_FOUND. 776 777 $next [+1] UInt onfound_timeout_count 778 -- Maximum number of advertisements that can linger unreported within the 779 -- Controller at any given time. The Controller will report lingering 780 -- advertising packets even in onfound_timeout hasn't been reached. Valid 781 -- only if delivery_mode is ON_FOUND. 782 783 $next [+1] UInt rssi_low_threshold 784 -- If the RSSI of the received packet is below the RSSI low threshold, the 785 -- advertising packet is considered as not seen. RSSI values must use 2's 786 -- complement to represent negative values. Valid 787 -- only if delivery_mode is ON_FOUND. 788 -- 789 -- Unit: dBm 790 791 $next [+2] UInt onlost_timeout 792 -- Timeout (in milliseconds) for Controller to report an advertisement as 793 -- being lost if, after being found, is not seen contiguously for the 794 -- timeout period. Valid only if delivery_mode is ON_FOUND. 795 796 $next [+2] UInt num_tracking_entries 797 -- Total number of advertisements to track per filter. Valid only if 798 -- delivery_mode is ON_FOUND. 799 800 801struct LEApcfBroadcastAddressCommand: 802 let vendor_size = AndroidCommandHeader.$size_in_bytes 803 804 0 [+vendor_size] AndroidCommandHeader vendor_command 805 806 $next [+1] ApcfAction action 807 808 $next [+1] UInt filter_index 809 -- Filter index used to identify an advertising packet content 810 -- filter. Filter indices are assigned on demand when used. 811 -- 812 -- NOTE: The maximum number of packet filters is published via the 813 -- max_filter attribute within LEGetVendorCapabilitiesCommandCompleteEvent. 814 -- 815 -- Range: (0, max_filter - 1) 816 817 $next [+hci.BdAddr.$size_in_bytes] hci.BdAddr broadcaster_address 818 -- Device address to add to or delete from the broadcaster address list 819 820 $next [+1] ApcfApplicationAddressType peer_addr_type 821 822 823struct LEApcfServiceUUIDCommand(uuid_size: UInt:8): 824 let vendor_size = AndroidCommandHeader.$size_in_bytes 825 826 0 [+vendor_size] AndroidCommandHeader vendor_command 827 828 $next [+1] ApcfAction action 829 830 $next [+1] UInt filter_index 831 -- Filter index used to identify an advertising packet content 832 -- filter. Filter indices are assigned on demand when used. 833 -- 834 -- NOTE: The maximum number of packet filters is published via the 835 -- max_filter attribute within LEGetVendorCapabilitiesCommandCompleteEvent. 836 -- 837 -- Range: (0, max_filter - 1) 838 839 $next [+uuid_size] UInt:8[uuid_size] uuid 840 -- The Service UUID (16-bit, 32-bit, or 128-bit) for adding to, or deleting 841 -- from, the list. 842 843 $next [+uuid_size] UInt:8[uuid_size] uuid_mask 844 -- The Service UUID Mask (16-bit, 32-bit, or 128-bit) to add to the list. 845 846 847struct LEApcfSolicitationUUIDCommand(uuid_size: UInt:8): 848 let vendor_size = AndroidCommandHeader.$size_in_bytes 849 850 0 [+vendor_size] AndroidCommandHeader vendor_command 851 852 $next [+1] ApcfAction action 853 854 $next [+1] UInt filter_index 855 -- Filter index used to identify an advertising packet content 856 -- filter. Filter indices are assigned on demand when used. 857 -- 858 -- NOTE: The maximum number of packet filters is published via the 859 -- max_filter attribute within LEGetVendorCapabilitiesCommandCompleteEvent. 860 -- 861 -- Range: (0, max_filter - 1) 862 863 $next [+uuid_size] UInt:8[uuid_size] uuid 864 -- The Solicitation UUID (16-bit, 32-bit, or 128-bit) for adding to, or 865 -- deleting from, the list. 866 867 $next [+uuid_size] UInt:8[uuid_size] uuid_mask 868 -- The Solicitation UUID Mask (16-bit, 32-bit, or 128-bit) to add to the 869 -- list. 870 871 872struct LEApcfLocalNameCommand(size: UInt:8): 873 let vendor_size = AndroidCommandHeader.$size_in_bytes 874 875 0 [+vendor_size] AndroidCommandHeader vendor_command 876 877 $next [+1] ApcfAction action 878 879 $next [+1] UInt filter_index 880 -- Filter index used to identify an advertising packet content 881 -- filter. Filter indices are assigned on demand when used. 882 -- 883 -- NOTE: The maximum number of packet filters is published via the 884 -- max_filter attribute within LEGetVendorCapabilitiesCommandCompleteEvent. 885 -- 886 -- Range: (0, max_filter - 1) 887 888 $next [+size] UInt:8[size] local_name 889 -- The character string to match against the local name. Currently, the 890 -- maximum number of bytes this field supports is kLEApcfMaxPDUValueLength. 891 -- 892 -- NOTE: This field is not null (0x00) terminated. The size of the packet 893 -- sent to the controller determines the length of the value. 894 -- 895 -- NOTE: This field is not applicable when the action above is 896 -- ApcfAction::Clear. 897 898 899struct LEApcfManufacturerDataCommand(size: UInt:8): 900 let vendor_size = AndroidCommandHeader.$size_in_bytes 901 902 0 [+vendor_size] AndroidCommandHeader vendor_command 903 904 $next [+1] ApcfAction action 905 906 $next [+1] UInt filter_index 907 -- Filter index used to identify an advertising packet content 908 -- filter. Filter indices are assigned on demand when used. 909 -- 910 -- NOTE: The maximum number of packet filters is published via the 911 -- max_filter attribute within LEGetVendorCapabilitiesCommandCompleteEvent. 912 -- 913 -- Range: (0, max_filter - 1) 914 915 $next [+size] UInt:8[size] manufacturer_data 916 -- The character string to match against the manufacturer data. Currently, 917 -- the maximum number of bytes this field supports is 918 -- kLEApcfMaxPDUValueLength. 919 -- 920 -- NOTE: This field is not null (0x00) terminated. The size of the packet 921 -- sent to the controller determines the length of the value. 922 -- 923 -- NOTE: This field is not applicable when the action above is 924 -- ApcfAction::Clear. 925 926 $next [+size] UInt:8[size] manufacturer_data_mask 927 -- The manufacturer data mask to add to the list. Manufacturer data is 928 -- variable in size and we may want to match against some given part of 929 -- it. The manufacturer_data_mask selects the bits which we match against 930 -- within the manufacturer_data field. 931 -- 932 -- NOTE: This field is not applicable when the action above is 933 -- ApcfAction::Clear. 934 935 936struct LEApcfServiceDataCommand(size: UInt:8): 937 let vendor_size = AndroidCommandHeader.$size_in_bytes 938 939 0 [+vendor_size] AndroidCommandHeader vendor_command 940 941 $next [+1] ApcfAction action 942 943 $next [+1] UInt filter_index 944 -- Filter index used to identify an advertising packet content 945 -- filter. Filter indices are assigned on demand when used. 946 -- 947 -- NOTE: The maximum number of packet filters is published via the 948 -- max_filter attribute within LEGetVendorCapabilitiesCommandCompleteEvent. 949 -- 950 -- Range: (0, max_filter - 1) 951 952 $next [+size] UInt:8[size] service_data 953 -- The character string to match against the manufacturer data. Currently, 954 -- the maximum number of bytes this field supports is 955 -- kLEApcfMaxPDUValueLength. 956 -- 957 -- NOTE: This field is not applicable when the action above is 958 -- ApcfAction::Clear. 959 960 $next [+size] UInt:8[size] service_data_mask 961 -- The service data mask to add to the list. Service data is variable in 962 -- size and we may want to match against some given part of it. The 963 -- service_data_mask selects the bits which we match against within the 964 -- service_data field. 965 -- 966 -- NOTE: This field is not applicable when the action above is 967 -- ApcfAction::Clear. 968 969 970struct LEApcfAdTypeCommand: 971 let vendor_size = AndroidCommandHeader.$size_in_bytes 972 973 0 [+vendor_size] AndroidCommandHeader vendor_command 974 975 $next [+1] ApcfAction action 976 977 $next [+1] UInt filter_index 978 -- Filter index used to identify an advertising packet content 979 -- filter. Filter indices are assigned on demand when used. 980 -- 981 -- NOTE: The maximum number of packet filters is published via the 982 -- max_filter attribute within LEGetVendorCapabilitiesCommandCompleteEvent. 983 -- 984 -- Range: (0, max_filter - 1) 985 986 $next [+1] hci.CommonDataType ad_type 987 -- The AD type to add or remove from the list. 988 989 $next [+1] UInt ad_data_length 990 [requires: 0 <= this <= 29] 991 992 $next [+ad_data_length] UInt:8[ad_data_length] ad_data 993 -- Byte string to match against advertisement data. Currently, the maximum 994 -- number of bytes this field supports is kLEApcfMaxPDUValueLength. 995 -- 996 -- NOTE: This field is not applicable when the action above is 997 -- ApcfAction::Clear. 998 999 $next [+ad_data_length] UInt:8[ad_data_length] ad_data_mask 1000 -- ad_data_mask selects the bits which we match against within the 1001 -- ad_data field. Size must be same as ad_data. 1002 -- 1003 -- NOTE: This field is not applicable when the action above is 1004 -- ApcfAction::Clear. 1005 1006# ------------------ HCI event (vendor-specific) ------------------------------- 1007 1008 1009enum QualityReportId: 1010 [maximum_bits: 8] 1011 QUALITY_REPORTING_ON_THE_MONITORING_MODE = 0x01 1012 APPROACHING_LSTO = 0x02 1013 A2DP_AUDIO_CHOPPY = 0x03 1014 ESCO_VOICE_CHOPPY = 0x04 1015 ROOT_INFLAMMATION = 0x05 1016 # Reserved = 0x06 1017 LE_AUDIO_CHOPPY = 0x07 1018 CONNECT_FAIL = 0x08 1019 # Reserved = 0x09 - 0x10 1020 LPM_LL_MESSAGE_TRACE = 0x11 1021 BLUETOOTH_MULTI_LINK_COEX_SCHEDULING_TRACE = 0x12 1022 CONTROLLER_DEBUG_INFORMATION_DATA_DUMP = 0x13 1023 1024 1025struct BluetoothQualityReportSubeventPrefix: 1026 [requires: vendor_event.subevent_code == 0x58] 1027 let hdr_size = hci.VendorDebugEvent.$size_in_bytes 1028 0 [+hdr_size] hci.VendorDebugEvent vendor_event 1029 $next [+1] QualityReportId quality_report_id 1030