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 #pragma once
16 // This file contains general opcode/number and static packet definitions for
17 // extensions to the Bluetooth Host-Controller interface. These extensions
18 // aren't standardized through the Bluetooth SIG and their documentation is
19 // available separately (linked below). Each packet payload structure contains
20 // parameter descriptions based on their respective documentation.
21 //
22 // Documentation links:
23 //
24 //    - Android: https://source.android.com/devices/bluetooth/hci_requirements
25 //
26 // NOTE: The definitions below are incomplete. They get added as needed. This
27 // list will grow as we support more vendor features.
28 
29 #include <pw_bluetooth/hci_android.emb.h>
30 
31 #include "pw_bluetooth_sapphire/internal/host/hci-spec/protocol.h"
32 
33 namespace bt::hci_spec::vendor::android {
34 
35 // ============================================================================
36 // LE Get Vendor Capabilities Command
37 constexpr OpCode kLEGetVendorCapabilities = VendorOpCode(0x153);
38 
39 // ============================================================================
40 // A2DP Offload Commands
41 
42 // The kA2dpOffloadCommand opcode is shared across all a2dp offloading HCI
43 // commands. To differentiate between the multiple commands, a subopcode field
44 // is included in the command payload.
45 constexpr OpCode kA2dpOffloadCommand = VendorOpCode(0x15D);
46 constexpr uint8_t kStartA2dpOffloadCommandSubopcode = 0x01;
47 constexpr uint8_t kStopA2dpOffloadCommandSubopcode = 0x02;
48 constexpr uint32_t kLdacVendorId = 0x0000012D;
49 constexpr uint16_t kLdacCodecId = 0x00AA;
50 
51 // ============================================================================
52 // Multiple Advertising
53 //
54 // NOTE: Multiple advertiser support is deprecated in the Google feature spec
55 // v0.98 and above. Users of the following vendor extension HCI commands should
56 // first ensure that the controller is using a compatible Google feature spec.
57 
58 // The kLEMultiAdvt opcode is shared across all multiple advertising HCI
59 // commands. To differentiate between the multiple commands, a subopcode field
60 // is included in the command payload.
61 constexpr OpCode kLEMultiAdvt = VendorOpCode(0x154);
62 constexpr uint8_t kLEMultiAdvtSetAdvtParamSubopcode = 0x01;
63 constexpr uint8_t kLEMultiAdvtSetAdvtDataSubopcode = 0x02;
64 constexpr uint8_t kLEMultiAdvtSetScanRespSubopcode = 0x03;
65 constexpr uint8_t kLEMultiAdvtSetRandomAddrSubopcode = 0x4;
66 constexpr uint8_t kLEMultiAdvtEnableSubopcode = 0x05;
67 constexpr EventCode kLEMultiAdvtStateChangeSubeventCode = 0x55;
68 
69 // ============================================================================
70 // Advertising Packet Content Filtering
71 
72 // The kLEApcf opcode is shared across all advertising packet content filtering
73 // HCI commands. To differentiate between the multiple commands, a subopcode
74 // field is included in the command payload. These subopcode fields must be set
75 // to a specific value.
76 constexpr OpCode kLEApcf = VendorOpCode(0x157);
77 constexpr uint8_t kLEApcfEnableSubopcode = 0x00;
78 constexpr uint8_t kLEApcfSetFilteringParametersSubopcode = 0x01;
79 constexpr uint8_t kLEApcfBroadcastAddressSubopcode = 0x02;
80 constexpr uint8_t kLEApcfServiceUUIDSubopcode = 0x03;
81 constexpr uint8_t kLEApcfServiceSolicitationUUIDSubopcode = 0x04;
82 constexpr uint8_t kLEApcfLocalNameSubopcode = 0x05;
83 constexpr uint8_t kLEApcfManufacturerDataSubopcode = 0x06;
84 constexpr uint8_t kLEApcfServiceDataSubopcode = 0x07;
85 constexpr uint8_t kLEApcfTransportDiscoveryService = 0x08;
86 constexpr uint8_t kLEApcfAdTypeFilter = 0x09;
87 constexpr uint8_t kLEApcfReadExtendedFeatures = 0xFF;
88 
89 // The maximum length of an advertising data field. The value 29 is selected
90 // because advertising data can be between 0 - 31 bytes wide.
91 //
92 //    - Byte 0: length of the advertising data itself.
93 //    - Byte 1: advertising data type (e.g. 0xFF for manufacturer data)
94 //
95 // With two bytes used, the rest of the payload size can only take up a maximum
96 // of 29 bytes.
97 constexpr uint8_t kLEApcfMaxPDUValueLength = 29;
98 
99 }  // namespace bt::hci_spec::vendor::android
100