stm32wb_hci/vendor/
opcode.rs

1use crate::Opcode;
2
3const fn ocf(cgid: u16, cid: u16) -> u16 {
4    ((cgid & 0b111) << 7) | (cid & 0b111_1111)
5}
6
7pub const VENDOR_OGF: u16 = 0x3F;
8
9macro_rules! vendor_opcodes {
10    (
11        $(
12            $_cgid_comment:ident = $cgid:expr;
13            {
14                $(pub const $var:ident = $cid:expr;)+
15            }
16        )+
17    ) => {
18        $($(
19            pub const $var: Opcode = Opcode::new(VENDOR_OGF, ocf($cgid, $cid));
20        )+)+
21    };
22}
23
24vendor_opcodes! {
25    Hal = 0x0;
26    {
27        pub const HAL_GET_FIRMWARE_REVISION = 0x00;
28        pub const HAL_WRITE_CONFIG_DATA = 0x0C;
29        pub const HAL_READ_CONFIG_DATA = 0x0D;
30        pub const HAL_SET_TX_POWER_LEVEL = 0x0F;
31        pub const HAL_DEVICE_STANDBY = 0x13;
32        pub const HAL_TX_TEST_PACKET_COUNT = 0x14;
33        pub const HAL_START_TONE = 0x15;
34        pub const HAL_STOP_TONE = 0x16;
35        pub const HAL_GET_LINK_STATUS = 0x17;
36        pub const HAL_SET_RADIO_ACTIVITY_MASK = 0x18;
37        // The documentation says the OCF is 0xF8 (0b1111_1000), but that does not fit the OCF
38        // length (7 bits). The C source code has 0x19, which is valid.
39        pub const HAL_GET_ANCHOR_PERIOD = 0x19;
40        pub const HAL_SET_EVENT_MASK = 0x1A;
41        pub const HAL_GET_PM_DEBUG_INFO = 0x1C;
42        pub const HAL_SET_PERIPHERAL_LATENCY = 0x20;
43        pub const HAL_READ_RSSI = 0x22;
44        pub const HAL_READ_RADIO_REG = 0x30;
45        pub const HAL_READ_RAW_RSSI = 0x32;
46        pub const HAL_RX_START = 0x33;
47        pub const HAL_RX_STOP = 0x34;
48        pub const HAL_STACK_RESET = 0x3B;
49    }
50    Gap = 0x1;
51    {
52        pub const GAP_SET_NONDISCOVERABLE = 0x01;
53        pub const GAP_SET_LIMITED_DISCOVERABLE = 0x02;
54        pub const GAP_SET_DISCOVERABLE = 0x03;
55        pub const GAP_SET_DIRECT_CONNECTABLE = 0x04;
56        pub const GAP_SET_IO_CAPABILITY = 0x05;
57        pub const GAP_SET_AUTHENTICATION_REQUIREMENT = 0x06;
58        pub const GAP_SET_AUTHORIZATION_REQUIREMENT = 0x07;
59        pub const GAP_PASS_KEY_RESPONSE = 0x08;
60        pub const GAP_AUTHORIZATION_RESPONSE = 0x09;
61        pub const GAP_INIT = 0x0A;
62        pub const GAP_SET_NONCONNECTABLE = 0x0B;
63        pub const GAP_SET_UNDIRECTED_CONNECTABLE = 0x0C;
64        pub const GAP_PERIPHERAL_SECURITY_REQUEST = 0x0D;
65        pub const GAP_UPDATE_ADVERTISING_DATA = 0x0E;
66        pub const GAP_DELETE_AD_TYPE = 0x0F;
67        pub const GAP_GET_SECURITY_LEVEL = 0x10;
68        pub const GAP_SET_EVENT_MASK = 0x11;
69        pub const GAP_CONFIGURE_WHITE_LIST = 0x12;
70        pub const GAP_TERMINATE = 0x13;
71        pub const GAP_CLEAR_SECURITY_DATABASE = 0x14;
72        pub const GAP_ALLOW_REBOND = 0x15;
73        pub const GAP_START_LIMITED_DISCOVERY_PROCEDURE = 0x16;
74        pub const GAP_START_GENERAL_DISCOVERY_PROCEDURE = 0x17;
75        pub const GAP_START_NAME_DISCOVERY_PROCEDURE = 0x18;
76        pub const GAP_START_AUTO_CONNECTION_ESTABLISHMENT = 0x19;
77        pub const GAP_START_GENERAL_CONNECTION_ESTABLISHMENT = 0x1A;
78        pub const GAP_START_SELECTIVE_CONNECTION_ESTABLISHMENT = 0x1B;
79        pub const GAP_CREATE_CONNECTION = 0x1C;
80        pub const GAP_TERMINATE_PROCEDURE = 0x1D;
81        pub const GAP_START_CONNECTION_UPDATE = 0x1E;
82        pub const GAP_SEND_PAIRING_REQUEST = 0x1F;
83        pub const GAP_RESOLVE_PRIVATE_ADDRESS = 0x20;
84        pub const GAP_SET_BROADCAST_MODE = 0x21;
85        pub const GAP_START_OBSERVATION_PROCEDURE = 0x22;
86        pub const GAP_GET_BONDED_DEVICES = 0x23;
87        pub const GAP_IS_DEVICE_BONDED = 0x24;
88        pub const GAP_NUMERIC_COMPARISON_VALUE_YES_NO = 0x25;
89        pub const GAP_PASSKEY_INPUT = 0x26;
90        pub const GAP_GET_OOB_DATA = 0x27;
91        pub const GAP_SET_OOB_DATA = 0x28;
92        pub const GAP_ADD_DEVICES_TO_RESOLVING_LIST = 0x29;
93        pub const GAP_REMOVE_BONDED_DEVICE = 0x2A;
94        pub const GAP_ADD_DEVICES_TO_LIST = 0x2B;
95        pub const GAP_ADDITIONAL_BEACON_START = 0x30;
96        pub const GAP_ADDITIONAL_BEACON_STOP = 0x31;
97        pub const GAP_ADDITIONAL_BEACON_SET_DATA = 0x32;
98        pub const GAP_ADV_SET_CONFIGURATION = 0x40;
99        pub const GAP_ADV_SET_ENABLE = 0x41;
100        pub const GAP_ADV_SET_ADV_DATA = 0x42;
101        pub const GAP_ADV_SET_SCAN_RESPONSE_DATA = 0x43;
102        pub const GAP_ADV_REMOVE_SET = 0x44;
103        pub const GAP_ADV_CLEAR_SETS = 0x45;
104        pub const GAP_ADV_SET_RANDOM_ADDRESS = 0x46;
105    }
106    Gatt = 0x2;
107    {
108        pub const GATT_INIT = 0x01;
109        pub const GATT_ADD_SERVICE = 0x02;
110        pub const GATT_INCLUDE_SERVICE = 0x03;
111        pub const GATT_ADD_CHARACTERISTIC = 0x04;
112        pub const GATT_ADD_CHARACTERISTIC_DESCRIPTOR = 0x05;
113        pub const GATT_UPDATE_CHARACTERISTIC_VALUE = 0x06;
114        pub const GATT_DELETE_CHARACTERISTIC = 0x07;
115        pub const GATT_DELETE_SERVICE = 0x08;
116        pub const GATT_DELETE_INCLUDED_SERVICE = 0x09;
117        pub const GATT_SET_EVENT_MASK = 0x0A;
118        pub const GATT_EXCHANGE_CONFIGURATION = 0x0B;
119        pub const GATT_FIND_INFORMATION_REQUEST = 0x0C;
120        pub const GATT_FIND_BY_TYPE_VALUE_REQUEST = 0x0D;
121        pub const GATT_READ_BY_TYPE_REQUEST = 0x0E;
122        pub const GATT_READ_BY_GROUP_TYPE_REQUEST = 0x0F;
123        pub const GATT_PREPARE_WRITE_REQUEST = 0x10;
124        pub const GATT_EXECUTE_WRITE_REQUEST = 0x11;
125        pub const GATT_DISCOVER_ALL_PRIMARY_SERVICES = 0x12;
126        pub const GATT_DISCOVER_PRIMARY_SERVICES_BY_UUID = 0x13;
127        pub const GATT_FIND_INCLUDED_SERVICES = 0x14;
128        pub const GATT_DISCOVER_ALL_CHARACTERISTICS_OF_SERVICE = 0x15;
129        pub const GATT_DISCOVER_CHARACTERISTICS_BY_UUID = 0x16;
130        pub const GATT_DISCOVER_ALL_CHARACTERISTIC_DESCRIPTORS = 0x17;
131        pub const GATT_READ_CHARACTERISTIC_VALUE = 0x18;
132        pub const GATT_READ_CHARACTERISTIC_BY_UUID = 0x19;
133        pub const GATT_READ_LONG_CHARACTERISTIC_VALUE = 0x1A;
134        pub const GATT_READ_MULTIPLE_CHARACTERISTIC_VALUES = 0x1B;
135        pub const GATT_WRITE_CHARACTERISTIC_VALUE = 0x1C;
136        pub const GATT_WRITE_LONG_CHARACTERISTIC_VALUE = 0x1D;
137        pub const GATT_WRITE_CHARACTERISTIC_VALUE_RELIABLY = 0x1E;
138        pub const GATT_WRITE_LONG_CHARACTERISTIC_DESCRIPTOR = 0x1F;
139        pub const GATT_READ_LONG_CHARACTERISTIC_DESCRIPTOR = 0x20;
140        pub const GATT_WRITE_CHARACTERISTIC_DESCRIPTOR = 0x21;
141        pub const GATT_READ_CHARACTERISTIC_DESCRIPTOR = 0x22;
142        pub const GATT_WRITE_WITHOUT_RESPONSE = 0x23;
143        pub const GATT_SIGNED_WRITE_WITHOUT_RESPONSE = 0x24;
144        pub const GATT_CONFIRM_INDICATION = 0x25;
145        pub const GATT_WRITE_RESPONSE = 0x26;
146        pub const GATT_ALLOW_READ = 0x27;
147        pub const GATT_SET_SECURITY_PERMISSION = 0x28;
148        pub const GATT_SET_DESCRIPTOR_VALUE = 0x29;
149        pub const GATT_READ_HANDLE_VALUE = 0x2A;
150        pub const GATT_READ_HANDLE_VALUE_OFFSET = 0x2B;
151        pub const GATT_UPDATE_LONG_CHARACTERISTIC_VALUE = 0x2C;
152        pub const GATT_DENY_READ = 0x2D;
153        pub const GATT_SET_ACCESS_PERMISSION = 0x2E;
154        pub const GATT_STORE_DB = 0x30;
155        pub const GATT_SEND_MULT_NOTIFICATION = 0x31;
156        pub const GATT_READ_MULTIPLE_VAR_CHAR_VALUE = 0x32;
157    }
158    L2Cap = 0x3;
159    {
160        pub const L2CAP_CONN_PARAM_UPDATE_REQ = 0x01;
161        pub const L2CAP_CONN_PARAM_UPDATE_RESP = 0x02;
162        pub const L2CAP_COC_CONNECT = 0x08;
163        pub const L2CAP_COC_CONNECT_CONFIRM = 0x09;
164        pub const L2CAP_COC_RECONFIG = 0x0A;
165        pub const L2CAP_COC_RECONFIG_CONFIRM = 0x0B;
166        pub const L2CAP_COC_DISCONNECT = 0x0C;
167        pub const L2CAP_COC_FLOW_CONTROL = 0x0D;
168        pub const L2CAP_COC_TX_DATA = 0x0E;
169    }
170}