Skip to main content

bt_hci/cmd/
le.rs

1//! LE Controller commands [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-0f07d2b9-81e3-6508-ee08-8c808e468fed)
2
3use core::mem;
4
5use crate::param::{
6    AddrKind, AdvChannelMap, AdvEventProps, AdvFilterPolicy, AdvHandle, AdvKind, AdvPhyOptions, AdvSet, AllPhys,
7    BdAddr, BigHandle, BroadcastCode, ChannelMap, CigId, CisConfig, CisConfigTest, CisConnConfig, CodecId, ConnHandle,
8    ConnIntervalGroup, CteKind, CteMask, DataPathDirection, DataPathId, Duration, DurationU8, EncryptionMode,
9    ExtDuration, FilterDuplicates, Framing, InitiatingPhy, LeDataRelatedAddrChangeReasons, LeEventMask, LeFeatureMask,
10    LePeriodicAdvCreateSyncOptions, LePeriodicAdvReceiveEnable, LePeriodicAdvSubeventData,
11    LePeriodicAdvSyncTransferMode, LeScanKind, Operation, Packing, PayloadType, PeriodicAdvProps, PhyKind, PhyMask,
12    PhyOptions, PhyParams, PrivacyMode, RemoteConnectionParamsRejectReason, ScanningFilterPolicy, ScanningPhy,
13    SpacingTypes, SwitchingSamplingRates, SyncHandle,
14};
15use crate::{cmd, WriteHci};
16
17cmd! {
18    /// LE Set Event Mask command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-8d6890a5-79b9-ba8a-2079-4efa3128263c)
19    LeSetEventMask(LE, 0x0001) {
20        Params = LeEventMask;
21        Return = ();
22    }
23}
24
25cmd! {
26    /// LE Read Buffer Size command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-1446fd8f-af42-e54c-890d-3cc275ed372f)
27    LeReadBufferSize(LE, 0x0002) {
28        Params = ();
29        LeReadBufferSizeReturn {
30            le_acl_data_packet_length: u16,
31            total_num_le_acl_data_packets: u8,
32        }
33    }
34}
35
36cmd! {
37    /// LE Read Local Supported Features command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-3ad76ac5-3812-cca4-a4f5-f73e96cebcba)
38    LeReadLocalSupportedFeatures(LE, 0x0003) {
39        Params = ();
40        Return = LeFeatureMask;
41    }
42}
43
44cmd! {
45    /// LE Set Random Address command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-89d45457-bdb5-cade-32c5-a27240733659)
46    LeSetRandomAddr(LE, 0x0005) {
47        Params = BdAddr;
48        Return = ();
49    }
50}
51
52cmd! {
53    /// LE Set Advertising Parameters command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-d33351b8-bd92-76f5-47b7-2051fc6e7379)
54    LeSetAdvParams(LE, 0x0006) {
55        LeSetAdvParamsParams {
56            adv_interval_min: Duration<625>,
57            adv_interval_max: Duration<625>,
58            adv_kind: AdvKind,
59            own_addr_kind: AddrKind,
60            peer_addr_kind: AddrKind,
61            peer_addr: BdAddr,
62            adv_channel_map: AdvChannelMap,
63            adv_filter_policy: AdvFilterPolicy,
64        }
65        Return = ();
66    }
67}
68
69cmd! {
70    /// LE Read Advertising Physical Channel Tx Power command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-9b984fde-3e9f-05f3-d698-054ca618bcf3)
71    LeReadAdvPhysicalChannelTxPower(LE, 0x0007) {
72        Params = ();
73        Return = i8;
74    }
75}
76
77cmd! {
78    /// LE Set Advertising Data command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-7b83376f-e321-e7ce-3bf1-2af187798be4)
79    LeSetAdvData(LE, 0x0008) {
80        LeSetAdvDataParams {
81            data_len: u8,
82            data: [u8; 31],
83        }
84        Return = ();
85    }
86}
87
88cmd! {
89    /// LE Set Scan Response Data command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-7f9e3a5b-fa09-5292-b64e-1a5304b6a255)
90    LeSetScanResponseData(LE, 0x0009) {
91        LeSetScanResponseDataParams {
92            data_len: u8,
93            data: [u8; 31],
94        }
95        Return = ();
96    }
97}
98
99cmd! {
100    /// LE Set Advertising Enable command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-79bb990c-0338-9c1e-e615-7be8508c8e12)
101    LeSetAdvEnable(LE, 0x000a) {
102        Params = bool;
103        Return = ();
104    }
105}
106
107cmd! {
108    /// LE Set Scan Parameters command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-28d28698-0fd7-d273-2e31-7a6731617c77)
109    LeSetScanParams(LE, 0x000b) {
110        LeSetScanParamsParams {
111            le_scan_kind: LeScanKind,
112            le_scan_interval: Duration<625>,
113            le_scan_window: Duration<625>,
114            own_addr_kind: AddrKind,
115            scanning_filter_policy: ScanningFilterPolicy,
116        }
117        Return = ();
118    }
119}
120
121cmd! {
122    /// LE Set Scan Enable command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-10327f75-4024-80df-14bc-68fe1e42b9e0)
123    LeSetScanEnable(LE, 0x000c) {
124        LeSetScanEnableParams {
125            enable: bool,
126            filter_duplicates: bool,
127        }
128        Return = ();
129    }
130}
131
132cmd! {
133    /// LE Create Connection command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-dc5080f3-63c3-ac48-23d1-2d35c6393ac2)
134    LeCreateConn(LE, 0x000d) {
135        LeCreateConnParams {
136            le_scan_interval: Duration<625>,
137            le_scan_window: Duration<625>,
138            use_filter_accept_list: bool,
139            peer_addr_kind: AddrKind,
140            peer_addr: BdAddr,
141            own_addr_kind: AddrKind,
142            conn_interval_min: Duration<1_250>,
143            conn_interval_max: Duration<1_250>,
144            max_latency: u16,
145            supervision_timeout: Duration<10_000>,
146            min_ce_length: Duration<625>,
147            max_ce_length: Duration<625>,
148        }
149    }
150}
151
152cmd! {
153    /// LE Create Connection Cancel command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-37a5c913-6abe-c7b6-9fc8-0d94c8cd266d)
154    LeCreateConnCancel(LE, 0x000e) {
155        Params = ();
156        Return = ();
157    }
158}
159
160cmd! {
161    /// LE Read Filter Accept List Size command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-453b3a49-0aba-3f5e-ee16-5919bea4903d)
162    LeReadFilterAcceptListSize(LE, 0x000f) {
163        Params = ();
164        Return = u8;
165    }
166}
167
168cmd! {
169    /// LE Clear Filter Accept List command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-85c43f7b-9100-63a2-1e97-4def7f859861)
170    LeClearFilterAcceptList(LE, 0x0010) {
171        Params = ();
172        Return = ();
173    }
174}
175
176cmd! {
177    /// LE Add Device To Filter Accept List command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-80115d56-8927-4ad8-8da7-b9c5ed728c3d)
178    LeAddDeviceToFilterAcceptList(LE, 0x0011) {
179        LeAddDeviceToFilterAcceptListParams {
180            addr_kind: AddrKind,
181            addr: BdAddr,
182        }
183        Return = ();
184    }
185}
186
187cmd! {
188    /// LE Remove Device From Filter Accept List command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-7e2ae96c-2231-3fe0-603e-c4e2d27e7448)
189    LeRemoveDeviceFromFilterAcceptList(LE, 0x0012) {
190        LeRemoveDeviceFromFilterAcceptListParams {
191            addr_kind: AddrKind,
192            addr: BdAddr,
193        }
194        Return = ();
195    }
196}
197
198cmd! {
199    /// LE Connection Update command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-9d9b11a8-7762-8a3a-5204-0b7f27eea504)
200    LeConnUpdate(LE, 0x0013) {
201        LeConnUpdateParams {
202            handle: ConnHandle,
203            conn_interval_min: Duration<1_250>,
204            conn_interval_max: Duration<1_250>,
205            max_latency: u16,
206            supervision_timeout: Duration<10_000>,
207            min_ce_length: Duration<625>,
208            max_ce_length: Duration<625>,
209        }
210    }
211}
212
213cmd! {
214    /// LE Set Host Channel Classification command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-d76b3c58-aa23-3e1f-d771-fbc347ab29b5)
215    LeSetHostChannelClassification(LE, 0x0014) {
216        Params = ChannelMap;
217        Return = ();
218    }
219}
220
221cmd! {
222    /// LE Read Channel Map command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-adaea68c-13d3-4d3d-dc76-317d6f7f606b)
223    LeReadChannelMap(LE, 0x0015) {
224        Params = ConnHandle;
225        LeReadChannelMapReturn {
226            channel_map: ChannelMap,
227        }
228        Handle = handle: ConnHandle;
229    }
230}
231
232cmd! {
233    /// LE Read Remote Features command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-5cef6d01-c629-c784-03a5-490eb9b0408e)
234    LeReadRemoteFeatures(LE, 0x0016) {
235        Params = ConnHandle;
236    }
237}
238
239cmd! {
240    /// LE Encrypt command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-a902995a-d073-7d20-bede-01bf748323e7)
241    LeEncrypt(LE, 0x0017) {
242        LeEncryptParams {
243            key: [u8; 16],
244            plaintext: [u8; 16],
245        }
246        Return = [u8; 16];
247    }
248}
249
250cmd! {
251    /// LE Rand command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-71fbbee4-dc3f-4c0e-2170-b7c25e22f18d)
252    LeRand(LE, 0x0018) {
253        Params = ();
254        Return = [u8; 8];
255    }
256}
257
258cmd! {
259    /// LE Enable Encryption command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-d4c636e4-5e0c-39ca-09ec-43b7d229efa0)
260    LeEnableEncryption(LE, 0x0019) {
261        LeEnableEncryptionParams {
262            handle: ConnHandle,
263            random: [u8; 8],
264            encrypted_diversifier: u16,
265            long_term_key: [u8; 16],
266        }
267    }
268}
269
270cmd! {
271    /// LE Receiver Test command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-d5d30b61-e8be-8fa5-a04b-7d505a74ea9d)
272    LeReceiverTest(LE, 0x001d) {
273        LeReceiverTestParams {
274            rx_frequency: u8,
275        }
276        Return = ();
277    }
278}
279
280cmd! {
281    /// LE Remote Connection Parameter Request Reply  [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-31f1114e-a57b-bcff-812f-d68f95bdec2f)
282    LeRemoteConnectionParameterRequestReply(LE, 0x0020) {
283        LeRemoteConnectionParameterRequestReplyParams {
284            handle: ConnHandle,
285            interval_min: Duration<1_250>,
286            interval_max: Duration<1_250>,
287            max_latency: u16,
288            supervision_timeout: Duration<10_000>,
289            min_ce_length: Duration<625>,
290            max_ce_length: Duration<625>,
291        }
292    }
293}
294
295cmd! {
296    /// LE Remote Connection Parameter Request Negative Reply  [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-44860832-db97-c092-97e7-ea02011f08b0)
297    LeRemoteConnectionParameterRequestNegativeReply(LE, 0x0021) {
298        LeRemoteConnectionParameterRequestNegativeReplyParams {
299            handle: ConnHandle,
300            reason: RemoteConnectionParamsRejectReason,
301        }
302    }
303}
304
305cmd! {
306    /// LE Long Term Key Request Reply command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-e89a5372-a7cd-ae2b-5c8d-e281694793ae)
307    LeLongTermKeyRequestReply(LE, 0x001a) {
308        LeLongTermKeyRequestReplyParams {
309            long_term_key: [u8; 16],
310        }
311        Return = ConnHandle;
312        Handle = handle: ConnHandle;
313    }
314}
315
316cmd! {
317    /// LE Long Term Key Request Negative Reply command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-e64f1aa8-6c23-0d70-c11d-4ac00fb2abe7)
318    LeLongTermKeyRequestNegativeReply(LE, 0x001b) {
319        Params = ConnHandle;
320        Return = ConnHandle;
321        Handle = ConnHandle;
322    }
323}
324
325cmd! {
326    /// LE Read Supported States command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-69afd9a8-4d1a-18fe-ccd0-adf5080328f5)
327    LeReadSupportedStates(LE, 0x001c) {
328        Params = ();
329        Return = [u8; 8];
330    }
331}
332
333cmd! {
334    /// LE Transmitter Test command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-15c2cfce-06a0-5da7-5cbb-45c1896cca8d)
335    LeTransmitterTest(LE, 0x001c) {
336        LeTransmitterTestParams {
337            tx_frequency: u8,
338            length_of_test_data: u8,
339            packet_payload: u8,
340        }
341        Return = ();
342    }
343}
344
345cmd! {
346    /// LE Test End command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-cafabb90-1522-7ad5-8def-5d6dc5a8dabd)
347    LeTestEnd(LE, 0x001f) {
348        Params = ();
349        Return = u16;
350    }
351}
352
353cmd! {
354    /// LE Set Data Length command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-242f8446-8cd1-8293-a341-b09354bae550)
355    LeSetDataLength(LE, 0x0022) {
356        LeSetDataLengthParams {
357            tx_octets: u16,
358            tx_time: u16,
359        }
360        Return = ConnHandle;
361        Handle = handle: ConnHandle;
362    }
363}
364
365cmd! {
366    /// LE Read Suggested Default Data Length command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-63da6c78-1392-4471-9a11-a31567c10655)
367    LeReadSuggestedDefaultDataLength(LE, 0x0023) {
368        Params = ();
369        LeReadSuggestedDefaultDataLengthReturn {
370            suggested_max_tx_octets: u16,
371            suggested_max_tx_time: u16,
372        }
373    }
374}
375
376cmd! {
377    /// LE Write Suggested Default Data Length command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-ab836cdb-5055-0155-37fe-e480ac02bd20)
378    LeWriteSuggestedDefaultDataLength(LE, 0x0024) {
379        LeWriteSuggestedDefaultDataLengthParams {
380            suggested_max_tx_octets: u16,
381            suggested_max_tx_time: u16,
382        }
383        Return = ();
384    }
385}
386
387cmd! {
388    /// LE Add Device To Resolving List command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-d9a635b2-e7bc-359b-2e6a-5e8b45b38df3)
389    LeAddDeviceToResolvingList(LE, 0x0027) {
390        LeAddDeviceToResolvingListParams {
391            peer_id_addr_kind: AddrKind,
392            peer_id_addr: BdAddr,
393            peer_irk: [u8; 16],
394            local_irk: [u8; 16],
395        }
396        Return = ();
397    }
398}
399
400cmd! {
401    /// LE Remove Device From Resolving List command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-4e58626c-6af2-3797-18f1-7ccf643377d8)
402    LeRemoveDeviceFromResolvingList(LE, 0x0028) {
403        LeRemoveDeviceFromResolvingListParams {
404            peer_id_addr_kind: AddrKind,
405            peer_id_addr: BdAddr,
406        }
407        Return = ();
408    }
409}
410
411cmd! {
412    /// LE Clear Resolving List command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-7db0d65f-6851-c005-634b-6e7c31835a2e)
413    LeClearResolvingList(LE, 0x0029) {
414        Params = ();
415        Return = ();
416    }
417}
418
419cmd! {
420    /// LE Read Resolving List Size command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-dc9dd4cf-11ac-ed84-5101-d7c80ba06f2e)
421    LeReadResolvingListSize(LE, 0x002a) {
422        Params = ();
423        Return = u8;
424    }
425}
426
427cmd! {
428    /// LE Set Address Resolution Enable command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-ff994d82-39b7-a0a3-dab9-d145d42a35bf)
429    LeSetAddrResolutionEnable(LE, 0x002d) {
430        Params = bool;
431        Return = ();
432    }
433}
434
435cmd! {
436    /// LE Set Resolvable Private Address Timeout command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-f539d523-751b-6ffa-fa0c-e9633f0d7cc9)
437    LeSetResolvablePrivateAddrTimeout(LE, 0x002e) {
438        Params = Duration<1_000_000>;
439        Return = ();
440    }
441}
442
443cmd! {
444    /// LE Read Maximum Data Length command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-467bd8e9-d61a-7a76-593f-02cfe246d126)
445    LeReadMaxDataLength(LE, 0x002f) {
446        Params = ();
447        LeReadMaxDataLengthReturn {
448            supported_max_tx_octets: u16,
449            supported_max_tx_time: u16,
450            supported_max_rx_octets: u16,
451            supported_max_rx_time: u16,
452        }
453    }
454}
455
456cmd! {
457    /// LE Read PHY command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-d5598779-e01d-73fc-143f-749484029046)
458    LeReadPhy(LE, 0x0030) {
459        Params = ConnHandle;
460        LeReadPhyReturn {
461            tx_phy: PhyKind,
462            rx_phy: PhyKind,
463        }
464        Handle = handle: ConnHandle;
465    }
466}
467
468cmd! {
469    /// LE Set Default PHY command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-f0d3d393-85fa-9083-d9c0-589b3800a153)
470    LeSetDefaultPhy(LE, 0x0031) {
471        LeSetDefaultPhyParams {
472            all_phys: AllPhys,
473            tx_phys: PhyMask,
474            rx_phys: PhyMask,
475        }
476        Return = ();
477    }
478}
479
480cmd! {
481    /// LE Set PHY command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-8b2521a7-2192-15c2-1815-bcd8fa11da15)
482    LeSetPhy(LE, 0x0032) {
483        LeSetPhyParams {
484            handle: ConnHandle,
485            all_phys: AllPhys,
486            tx_phys: PhyMask,
487            rx_phys: PhyMask,
488            phy_options: PhyOptions,
489        }
490    }
491}
492
493cmd! {
494    /// LE Receiver Test V2 command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-d5d30b61-e8be-8fa5-a04b-7d505a74ea9d)
495    LeReceiverTestV2(LE, 0x0033) {
496        LeReceiverTestV2Params {
497            rx_frequency: u8,
498            phy: u8,
499            modulation_index: u8,
500        }
501        Return = ();
502    }
503}
504
505cmd! {
506    /// LE Transmitter Test V2 command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-15c2cfce-06a0-5da7-5cbb-45c1896cca8d)
507    LeTransmitterTestV2(LE, 0x0034) {
508        LeTransmitterTestV2Params {
509            tx_frequency: u8,
510            length_of_test_data: u8,
511            packet_payload: u8,
512            phy: u8,
513        }
514        Return = ();
515    }
516}
517
518cmd! {
519    /// LE Set Advertising Set Random Address command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-7c76cb49-d60d-1b5a-09ba-e3637d96d41d)
520    LeSetAdvSetRandomAddr(LE, 0x0035) {
521        LeSetAdvSetRandomAddrParams {
522            adv_handle: AdvHandle,
523            random_addr: BdAddr,
524        }
525        Return = ();
526    }
527}
528
529cmd! {
530    /// LE Set Extended Advertising Parameters command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-2d5f3e1f-6666-baa9-dcc2-5d8af3709dac)
531    LeSetExtAdvParams(LE, 0x0036) {
532        LeSetExtAdvParamsParams {
533                adv_handle: AdvHandle,
534                adv_event_props: AdvEventProps,
535                primary_adv_interval_min: ExtDuration<625>,
536                primary_adv_interval_max: ExtDuration<625>,
537                primary_adv_channel_map: AdvChannelMap,
538                own_addr_kind: AddrKind,
539                peer_addr_kind: AddrKind,
540                peer_addr: BdAddr,
541                adv_filter_policy: AdvFilterPolicy,
542                adv_tx_power: i8,
543                primary_adv_phy: PhyKind,
544                secondary_adv_max_skip: u8,
545                secondary_adv_phy: PhyKind,
546                adv_sid: u8,
547                scan_request_notification_enable: bool,
548        }
549        Return = i8;
550    }
551}
552
553cmd! {
554    /// LE Set Extended Advertising Parameters command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-2d5f3e1f-6666-baa9-dcc2-5d8af3709dac)
555    LeSetExtAdvParamsV2(LE, 0x007F) {
556        LeSetExtAdvParamsV2Params {
557                adv_handle: AdvHandle,
558                adv_event_props: AdvEventProps,
559                primary_adv_interval_min: ExtDuration<625>,
560                primary_adv_interval_max: ExtDuration<625>,
561                primary_adv_channel_map: AdvChannelMap,
562                own_addr_kind: AddrKind,
563                peer_addr_kind: AddrKind,
564                peer_addr: BdAddr,
565                adv_filter_policy: AdvFilterPolicy,
566                adv_tx_power: i8,
567                primary_adv_phy: PhyKind,
568                secondary_adv_max_skip: u8,
569                secondary_adv_phy: PhyKind,
570                adv_sid: u8,
571                scan_request_notification_enable: bool,
572                primary_adv_phy_options: AdvPhyOptions,
573                secondary_adv_phy_options: AdvPhyOptions,
574        }
575        Return = i8;
576    }
577}
578
579cmd! {
580    /// LE Set Extended Advertising Data command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-b63f0c30-a14d-ffdf-8a57-73cfe903c539)
581    LeSetExtAdvData(LE, 0x0037) {
582        LeSetExtAdvDataParams<'d> {
583            adv_handle: AdvHandle,
584            operation: Operation,
585            fragment_preference: bool,
586            adv_data: &'d [u8],
587        }
588        Return = ();
589    }
590}
591
592cmd! {
593    /// LE Set Extended Scan Response Data command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-e3dc6edb-4cde-4655-8186-cbde281bcb53)
594    LeSetExtScanResponseData(LE, 0x0038) {
595        LeSetExtScanResponseDataParams<'d> {
596            adv_handle: AdvHandle,
597            operation: Operation,
598            fragment_preference: bool,
599            scan_response_data: &'d [u8],
600        }
601        Return = ();
602    }
603}
604
605cmd! {
606    /// LE Set Extended Advertising Enable command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-d05d4cfe-f0b5-b0e2-1a63-672c960dc088)
607    LeSetExtAdvEnable(LE, 0x0039) {
608        LeSetExtAdvEnableParams<'a> {
609            enable: bool,
610            sets: &'a [AdvSet],
611        }
612        Return = ();
613    }
614}
615
616cmd! {
617    /// LE Read Maximum Advertising Data Length command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-762a3b37-a74d-a5b8-31ea-2d1ad02f257d)
618    LeReadMaxAdvDataLength(LE, 0x003a) {
619        Params = ();
620        Return = u16;
621    }
622}
623
624cmd! {
625    /// LE Read Number of Supported Advertising Sets command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-2b7bf2df-474b-031d-35c5-74623905cfe8)
626    LeReadNumberOfSupportedAdvSets(LE, 0x003b) {
627        Params = ();
628        Return = u8;
629    }
630}
631
632cmd! {
633    /// LE Remove Advertising Set command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-eaf84df1-f597-9d23-067d-29931a2bdac9)
634    LeRemoveAdvSet(LE, 0x003c) {
635        Params = AdvHandle;
636        Return = ();
637    }
638}
639
640cmd! {
641    /// LE Clear Advertising Sets command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-6b002f0a-b5b7-cb02-bc4d-deb80c9bab77)
642    LeClearAdvSets(LE, 0x003d) {
643        Params = ();
644        Return = ();
645    }
646}
647
648cmd! {
649    /// LE Set Periodic Advertising Parameters (v1) command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-e0bc9abb-d57e-8a02-b515-428c7f30e7d2)
650    LeSetPeriodicAdvParams(LE, 0x003e) {
651        LeSetPeriodicAdvParamsParams {
652            adv_handle: AdvHandle,
653            periodic_adv_interval_min: Duration<1_250>,
654            periodic_adv_interval_max: Duration<1_250>,
655            periodic_adv_props: PeriodicAdvProps,
656        }
657        Return = ();
658    }
659}
660
661cmd! {
662    /// LE Set Periodic Advertising Parameters (v2) command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-e0bc9abb-d57e-8a02-b515-428c7f30e7d2)
663    LeSetPeriodicAdvParamsV2(LE, 0x0086) {
664        LeSetPeriodicAdvParamsV2Params {
665            periodic_adv_interval_min: Duration<1_250>,
666            periodic_adv_interval_max: Duration<1_250>,
667            periodic_adv_props: PeriodicAdvProps,
668            num_subevents: u8,
669            subevent_interval: u8, // * 1.25ms
670            response_slot_delay: u8, // * 1.25ms
671            response_slot_spacing: u8, // * 0.125ms
672            num_response_slots: u8,
673        }
674        Return = AdvHandle;
675        Handle = adv_handle: AdvHandle;
676    }
677}
678
679cmd! {
680    /// LE Set Periodic Advertising Data command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-6154cdf5-c004-4eb1-7bdf-13ecda5bba78)
681    LeSetPeriodicAdvData(LE, 0x003f) {
682        LeSetPeriodicAdvDataParams<'a> {
683            adv_handle: AdvHandle,
684            operation: Operation,
685            adv_data: &'a [u8],
686        }
687        Return = ();
688    }
689}
690
691cmd! {
692    /// LE Set Periodic Advertising Enable command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-f69a3383-9839-e8f2-5339-a1e9327d5bf8)
693    LeSetPeriodicAdvEnable(LE, 0x0040) {
694        LeSetPeriodicAdvEnableParams {
695            enable: bool,
696            adv_handle: AdvHandle,
697        }
698        Return = ();
699    }
700}
701
702cmd! {
703    BASE
704    /// LE Set Extended Scan Parameters command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-431e2ed0-fe1f-17bd-6e6a-91ff801c6063)
705    LeSetExtScanParams(LE, 0x0041) {
706        Params = LeSetExtScanParamsParams;
707        Return = ();
708      }
709}
710
711impl LeSetExtScanParams {
712    /// Create a new instance of scan parameters.
713    pub fn new(
714        own_addr_kind: AddrKind,
715        scanning_filter_policy: ScanningFilterPolicy,
716        scanning_phys: PhyParams<ScanningPhy>,
717    ) -> Self {
718        Self(LeSetExtScanParamsParams {
719            own_addr_kind,
720            scanning_filter_policy,
721            scanning_phys,
722        })
723    }
724}
725
726/// Parameters for LE Set Extended Scan Parameters command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-431e2ed0-fe1f-17bd-6e6a-91ff801c6063)
727#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
728#[cfg_attr(feature = "defmt", derive(defmt::Format))]
729pub struct LeSetExtScanParamsParams {
730    /// Kind of address for self.
731    pub own_addr_kind: AddrKind,
732    /// Scanning filter policy.
733    pub scanning_filter_policy: ScanningFilterPolicy,
734    /// Phys used when scanning.
735    pub scanning_phys: PhyParams<ScanningPhy>,
736}
737
738impl WriteHci for LeSetExtScanParamsParams {
739    #[inline(always)]
740    fn size(&self) -> usize {
741        self.own_addr_kind.size() + self.scanning_filter_policy.size() + self.scanning_phys.size()
742    }
743
744    fn write_hci<W: embedded_io::Write>(&self, mut writer: W) -> Result<(), W::Error> {
745        self.own_addr_kind.write_hci(&mut writer)?;
746        self.scanning_filter_policy.write_hci(&mut writer)?;
747        self.scanning_phys.write_hci(writer)
748    }
749
750    async fn write_hci_async<W: embedded_io_async::Write>(&self, mut writer: W) -> Result<(), W::Error> {
751        self.own_addr_kind.write_hci_async(&mut writer).await?;
752        self.scanning_filter_policy.write_hci_async(&mut writer).await?;
753        self.scanning_phys.write_hci_async(writer).await
754    }
755}
756
757cmd! {
758    /// LE Set Extended Scan Enable command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-bfe8407c-4def-2ded-51dd-e47cf9e8916c)
759    LeSetExtScanEnable(LE, 0x0042) {
760        LeSetExtScanEnableParams {
761            enable: bool,
762            filter_duplicates: FilterDuplicates,
763            duration: Duration<10_000>,
764            period: Duration<1_280_000>,
765        }
766        Return = ();
767    }
768}
769
770cmd! {
771    BASE
772    /// LE Extended Create Connection (v1) command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-1dad213e-f660-2937-c94d-7a3162e94105)
773    LeExtCreateConn(LE, 0x0043) {
774        Params = LeExtCreateConnParams;
775    }
776}
777
778impl LeExtCreateConn {
779    /// Create a new instance of this command.
780    pub fn new(
781        initiator_filter_policy: bool,
782        own_addr_kind: AddrKind,
783        peer_addr_kind: AddrKind,
784        peer_addr: BdAddr,
785        initiating_phys: PhyParams<InitiatingPhy>,
786    ) -> Self {
787        Self(LeExtCreateConnParams {
788            initiator_filter_policy,
789            own_addr_kind,
790            peer_addr_kind,
791            peer_addr,
792            initiating_phys,
793        })
794    }
795}
796
797/// Parameters for LE Extended Create Connection (v1) command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-1dad213e-f660-2937-c94d-7a3162e94105)
798#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
799#[cfg_attr(feature = "defmt", derive(defmt::Format))]
800pub struct LeExtCreateConnParams {
801    /// Should use the initiator filter policy or not.
802    pub initiator_filter_policy: bool,
803    /// What kind of address for self.
804    pub own_addr_kind: AddrKind,
805    /// What kind of address for peer.
806    pub peer_addr_kind: AddrKind,
807    /// The peer address to connect to.
808    pub peer_addr: BdAddr,
809    /// Which phys used for connecting.
810    pub initiating_phys: PhyParams<InitiatingPhy>,
811}
812
813impl WriteHci for LeExtCreateConnParams {
814    #[inline(always)]
815    fn size(&self) -> usize {
816        self.initiator_filter_policy.size()
817            + self.own_addr_kind.size()
818            + self.peer_addr_kind.size()
819            + self.peer_addr.size()
820            + self.initiating_phys.size()
821    }
822
823    fn write_hci<W: embedded_io::Write>(&self, mut writer: W) -> Result<(), W::Error> {
824        self.initiator_filter_policy.write_hci(&mut writer)?;
825        self.own_addr_kind.write_hci(&mut writer)?;
826        self.peer_addr_kind.write_hci(&mut writer)?;
827        self.peer_addr.write_hci(&mut writer)?;
828        self.initiating_phys.write_hci(writer)
829    }
830
831    async fn write_hci_async<W: embedded_io_async::Write>(&self, mut writer: W) -> Result<(), W::Error> {
832        self.initiator_filter_policy.write_hci_async(&mut writer).await?;
833        self.own_addr_kind.write_hci_async(&mut writer).await?;
834        self.peer_addr_kind.write_hci_async(&mut writer).await?;
835        self.peer_addr.write_hci_async(&mut writer).await?;
836        self.initiating_phys.write_hci_async(writer).await
837    }
838}
839
840cmd! {
841    BASE
842    /// LE Extended Create Connection (v2) command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-1dad213e-f660-2937-c94d-7a3162e94105)
843    LeExtCreateConnV2(LE, 0x0085) {
844        Params = LeExtCreateConnV2Params;
845    }
846}
847
848impl LeExtCreateConnV2 {
849    /// Create a new instance.
850    pub fn new(
851        adv_handle: AdvHandle,
852        subevent: u8,
853        initiator_filter_policy: bool,
854        own_addr_kind: AddrKind,
855        peer_addr_kind: AddrKind,
856        peer_addr: BdAddr,
857        initiating_phys: PhyParams<InitiatingPhy>,
858    ) -> Self {
859        Self(LeExtCreateConnV2Params {
860            adv_handle,
861            subevent,
862            initiator_filter_policy,
863            own_addr_kind,
864            peer_addr_kind,
865            peer_addr,
866            initiating_phys,
867        })
868    }
869}
870
871/// LE Extended Create Connection (v2) command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-1dad213e-f660-2937-c94d-7a3162e94105)
872#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
873#[cfg_attr(feature = "defmt", derive(defmt::Format))]
874pub struct LeExtCreateConnV2Params {
875    /// The advertising handle to use.
876    pub adv_handle: AdvHandle,
877    /// Use connection sub-events.
878    pub subevent: u8,
879    /// Should use the initiator filter policy or not.
880    pub initiator_filter_policy: bool,
881    /// What kind of address for self.
882    pub own_addr_kind: AddrKind,
883    /// What kind of address for peer.
884    pub peer_addr_kind: AddrKind,
885    /// The peer address to connect to.
886    pub peer_addr: BdAddr,
887    /// Which phys used for connecting.
888    pub initiating_phys: PhyParams<InitiatingPhy>,
889}
890
891impl WriteHci for LeExtCreateConnV2Params {
892    #[inline(always)]
893    fn size(&self) -> usize {
894        self.adv_handle.size()
895            + self.subevent.size()
896            + self.initiator_filter_policy.size()
897            + self.own_addr_kind.size()
898            + self.peer_addr_kind.size()
899            + self.peer_addr.size()
900            + self.initiating_phys.size()
901    }
902
903    fn write_hci<W: embedded_io::Write>(&self, mut writer: W) -> Result<(), W::Error> {
904        self.adv_handle.write_hci(&mut writer)?;
905        self.subevent.write_hci(&mut writer)?;
906        self.initiator_filter_policy.write_hci(&mut writer)?;
907        self.own_addr_kind.write_hci(&mut writer)?;
908        self.peer_addr_kind.write_hci(&mut writer)?;
909        self.peer_addr.write_hci(&mut writer)?;
910        self.initiating_phys.write_hci(writer)
911    }
912
913    async fn write_hci_async<W: embedded_io_async::Write>(&self, mut writer: W) -> Result<(), W::Error> {
914        self.adv_handle.write_hci_async(&mut writer).await?;
915        self.subevent.write_hci_async(&mut writer).await?;
916        self.initiator_filter_policy.write_hci_async(&mut writer).await?;
917        self.own_addr_kind.write_hci_async(&mut writer).await?;
918        self.peer_addr_kind.write_hci_async(&mut writer).await?;
919        self.peer_addr.write_hci_async(&mut writer).await?;
920        self.initiating_phys.write_hci_async(writer).await
921    }
922}
923
924cmd! {
925    /// LE Periodic Advertising Create Sync command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-29188ef0-bf80-7807-2c96-385e7d9782ed)
926    LePeriodicAdvCreateSync(LE, 0x0044) {
927        LePeriodicAdvCreateSyncParams {
928            options: LePeriodicAdvCreateSyncOptions,
929            adv_sid: u8,
930            adv_addr_kind: AddrKind,
931            adv_addr: BdAddr,
932            skip: u16,
933            sync_timeout: Duration<10_000>,
934            sync_cte_kind: CteMask,
935        }
936    }
937}
938
939cmd! {
940    /// LE Periodic Advertising Create Sync Cancel command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-203d8b19-9d3f-65b2-82c7-96c6abdc5928)
941    LePeriodicAdvCreateSyncCancel(LE, 0x0045) {
942        Params = ();
943        Return = ();
944    }
945}
946
947cmd! {
948    /// LE Periodic Advertising Terminate Sync command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-c47f3b5c-e6db-f151-3a45-203bfe8b4fb9)
949    LePeriodicAdvTerminateSync(LE, 0x0046) {
950        Params = SyncHandle;
951        Return = ();
952    }
953}
954
955cmd! {
956    /// LE Add Device To Periodic Advertiser List command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-f73da323-a9c4-78cc-669d-6ebf05029416)
957    LeAddDeviceToPeriodicAdvList(LE, 0x0047) {
958        LeAddDeviceToPeriodicAdvListParams {
959            adv_addr_kind: AddrKind,
960            adv_addr: BdAddr,
961            adv_sid: u8,
962        }
963        Return = ();
964    }
965}
966
967cmd! {
968    /// LE Remove Device From Periodic Advertiser List command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-2f419914-71e3-3886-cecb-c9b5da98b538)
969    LeRemoveDeviceFromPeriodicAdvList(LE, 0x0048) {
970        LeRemoveDeviceFromPeriodicAdvListParams {
971            adv_addr_kind: AddrKind,
972            adv_addr: BdAddr,
973            adv_sid: u8,
974        }
975        Return = ();
976    }
977}
978
979cmd! {
980    /// LE Clear Periodic Advertiser List command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-049826bb-cdb2-df43-7c18-c5232ad99ef8)
981    LeClearPeriodicAdvList(LE, 0x0049) {
982        Params = ();
983        Return = ();
984    }
985}
986
987cmd! {
988    /// LE Read Periodic Advertiser List Size command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-3212f6f2-a838-872c-9ead-dd81ac4b7a66)
989    LeReadPeriodicAdvListSize(LE, 0x004a) {
990        Params = ();
991        Return = u8;
992    }
993}
994
995cmd! {
996    /// LE Read Transmit Power command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-66ee9869-6f38-c57f-0ab5-b5228ff5302c)
997    LeReadTransmitPower(LE, 0x004b) {
998        Params = ();
999        LeReadTransmitPowerReturn {
1000            min_tx_power: i8,
1001            max_tx_power: i8,
1002        }
1003    }
1004}
1005
1006cmd! {
1007    /// LE Read RF Path Compensation command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-8bba170c-e42b-8b42-f44b-64a0bc73af1d)
1008    LeReadRfPathCompensation(LE, 0x004c) {
1009        Params = ();
1010        LeReadRfPathCompensationReturn {
1011            rf_tx_path_compensation_value: i16,
1012            rf_rx_path_compenstaion_value: i16,
1013        }
1014    }
1015}
1016
1017cmd! {
1018    /// LE Write RF Path Compensation command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-85f69948-b4de-6b55-8282-77208c43f3aa)
1019    LeWriteRfPathCompensation(LE, 0x004d) {
1020        LeWriteRfPathCompensationParams {
1021            rf_tx_path_compensation_value: i16,
1022            rf_rx_path_compensation_value: i16,
1023        }
1024        Return = ();
1025    }
1026}
1027
1028cmd! {
1029    /// LE Set Privacy Mode command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-6a48bb1b-af90-9620-22c8-a4b9297d257c)
1030    LeSetPrivacyMode(LE, 0x004e) {
1031        LeSetPrivacyModeParams {
1032            peer_id_addr_kind: AddrKind,
1033            peer_id_addr: BdAddr,
1034            privacy_mode: PrivacyMode,
1035        }
1036        Return = ();
1037    }
1038}
1039
1040cmd! {
1041    /// LE Set Connectionless CTE Transmit Parameters command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-53d42c3c-cefd-aff5-f3f4-a27d02c8d46e)
1042    LeSetConnectionlessCteTransmitParams(LE, 0x0051) {
1043        LeSetConnectionlessCteTransmitParamsParams<'a> {
1044            adv_handle: AdvHandle,
1045            cte_length: u8,
1046            cte_kind: CteKind,
1047            cte_count: u8,
1048            switching_pattern: &'a [u8],
1049        }
1050        Return = ();
1051    }
1052}
1053
1054cmd! {
1055    /// LE Set Connectionless CTE Transmit Enable command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-f816ec0f-6970-7548-4370-b009c693259f)
1056    LeSetConnectionlessCteTransmitEnable(LE, 0x0052) {
1057        LeSetConnectionlessCteTransmitEnableParams {
1058            adv_handle: AdvHandle,
1059            cte_enable: bool,
1060        }
1061        Return = ();
1062    }
1063}
1064
1065cmd! {
1066    /// LE Set Connection CTE Transmit Parameters command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-a8cd66e1-b702-2d8e-c027-4f0a89d4f8a1)
1067    LeSetConnCteTransmitParams(LE, 0x0055) {
1068        LeSetConnCteTransmitParamsParams<'a> {
1069            cte_kinds: CteMask,
1070            switching_pattern: &'a [u8],
1071        }
1072        Return = ConnHandle;
1073        Handle = handle: ConnHandle;
1074    }
1075}
1076
1077cmd! {
1078    /// LE Connection CTE Response Enable command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-cbb39f47-1d2f-e229-ff9e-d716111b38a8)
1079    LeConnCteResponseEnable(LE, 0x0057) {
1080        LeConnCteResponseEnableParams {
1081            enable: bool,
1082        }
1083        Return = ConnHandle;
1084        Handle = handle: ConnHandle;
1085    }
1086}
1087
1088cmd! {
1089    /// LE Read Antenna Information command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-7a80c226-cea1-de43-ff2b-2503b2e7f91e)
1090    LeReadAntennaInformation(LE, 0x0058) {
1091        Params = ();
1092        LeReadAntennaInformationReturn {
1093            supported_switching_sampling_rates: SwitchingSamplingRates,
1094            num_antennae: u8,
1095            max_switching_pattern_len: u8,
1096            max_cte_len: u8,
1097        }
1098    }
1099}
1100
1101cmd! {
1102    /// LE Set Periodic Advertising Receive Enable command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-b055b724-7607-bf63-3862-3e164dfc2251)
1103    LeSetPeriodicAdvReceiveEnable(LE, 0x0059) {
1104        LeSetPeriodicAdvReceiveEnableParams {
1105            sync_handle: SyncHandle,
1106            enable: LePeriodicAdvReceiveEnable,
1107        }
1108        Return = ();
1109    }
1110}
1111
1112cmd! {
1113    /// LE Read Buffer Size command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-1446fd8f-af42-e54c-890d-3cc275ed372f)
1114    LeReadBufferSizeV2(LE, 0x0060) {
1115        Params = ();
1116        LeReadBufferSizeV2Return {
1117            le_acl_data_packet_length: u16,
1118            total_num_le_acl_data_packets: u8,
1119            iso_data_packet_length: u16,
1120            total_num_iso_data_packets: u16,
1121        }
1122    }
1123}
1124
1125cmd! {
1126    /// LE Periodic Advertising Sync Transfer command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-28bd445b-503e-6c1e-7d80-7bf4c8bd5e8d)
1127    LePeriodicAdvSyncTransfer(LE, 0x005a) {
1128        LePeriodicAdvSyncTransferParams {
1129            service_data: u16,
1130            sync_handle: SyncHandle,
1131        }
1132        Return = ConnHandle;
1133        Handle = handle: ConnHandle;
1134    }
1135}
1136
1137cmd! {
1138    /// LE Periodic Advertising Set Info Transfer command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-b1707675-34fd-4375-7c1c-354098a52db6)
1139    LePeriodicAdvSetInfoTransfer(LE, 0x005b) {
1140        LePeriodicAdvSetInfoTransferParams {
1141            service_data: u16,
1142            adv_handle: AdvHandle,
1143        }
1144        Return = ConnHandle;
1145        Handle = handle: ConnHandle;
1146    }
1147}
1148
1149cmd! {
1150    /// LE Set Periodic Advertising Sync Transfer Parameters command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-5ae627f7-febe-a209-e4fb-275a35572ae7)
1151    LeSetPeriodicAdvSyncTransferParams(LE, 0x005c) {
1152        LeSetPeriodicAdvSyncTransferParamsParams {
1153            mode: LePeriodicAdvSyncTransferMode,
1154            skip: u16,
1155            sync_timeout: Duration<10_000>,
1156            cte_kind: CteMask,
1157        }
1158        Return = ConnHandle;
1159        Handle = handle: ConnHandle;
1160    }
1161}
1162
1163cmd! {
1164    /// LE Set Default Periodic Advertising Sync Transfer Parameters command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-5c2a7c01-0658-1b94-ae09-16a436c9ef4f)
1165    LeSetDefaultPeriodicAdvSyncTransferParams(LE, 0x005d) {
1166        LeSetDefaultPeriodicAdvSyncTransferParamsParams {
1167            mode: LePeriodicAdvSyncTransferMode,
1168            skip: u16,
1169            sync_timeout: Duration<10_000>,
1170            cte_kind: CteMask,
1171        }
1172        Return = ();
1173    }
1174}
1175
1176cmd! {
1177    /// LE Request Peer SCA command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-4960a916-5311-968d-b432-8537b2dd12ed)
1178    LeRequestPeerSca(LE, 0x006d) {
1179        Params = ConnHandle;
1180    }
1181}
1182
1183cmd! {
1184    /// LE Set Host Feature command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-873282cd-6e49-e9aa-cf6f-02fb4c0ea924)
1185    LeSetHostFeature(LE, 0x0074) {
1186        LeSetHostFeatureParams {
1187            bit_number: u8,
1188            bit_value: u8,
1189        }
1190        Return = ();
1191    }
1192}
1193
1194cmd! {
1195    /// LE Enhanced Read Transmit Power Level command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-9460c908-2c3d-5915-e04b-25ce98dda7a8)
1196    LeEnhancedReadTransmitPowerLevel(LE, 0x0076) {
1197        LeEnhancedReadTransmitPowerLevelParams {
1198            phy: PhyKind,
1199        }
1200        LeEnhancedReadTransmitPowerLevelReturn {
1201            phy: PhyKind,
1202            current_tx_power_level: i8,
1203            max_tx_power_level: i8,
1204        }
1205        Handle = handle: ConnHandle;
1206    }
1207}
1208
1209cmd! {
1210    /// LE Read Remote Transmit Power Level command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-e0399448-0f93-7fcf-73ed-43171e6627ea)
1211    LeReadRemoteTransmitPowerLevel(LE, 0x0077) {
1212        LeReadRemoteTransmitPowerLevelParams {
1213            handle: ConnHandle,
1214            phy: PhyKind,
1215        }
1216    }
1217}
1218
1219cmd! {
1220    /// LE Set Path Loss Reporting Parameters command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-40bf69ec-6834-33a5-2978-4bec08e281f2)
1221    LeSetPathLossReportingParams(LE, 0x0078) {
1222        LeSetPathLossReportingParamsParams {
1223            high_threshold: i8,
1224            high_hysteresis: i8,
1225            low_threshold: i8,
1226            low_hysteresis: i8,
1227            min_time_spent: u16,
1228        }
1229        Return = ConnHandle;
1230        Handle = handle: ConnHandle;
1231    }
1232}
1233
1234cmd! {
1235    /// LE Set Path Loss Reporting Enable command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-fd9496a1-33de-7228-a0c1-44b9024daae1)
1236    LeSetPathLossReportingEnable(LE, 0x0079) {
1237        LeSetPathLossReportingEnableParams {
1238            enable: bool,
1239        }
1240        Return = ConnHandle;
1241        Handle = handle: ConnHandle;
1242    }
1243}
1244
1245cmd! {
1246    /// LE Set Transmit Power Reporting Enable command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-cdc834a7-3f30-7329-01d8-44a457aae980)
1247    LeSetTransmitPowerReportingEnable(LE, 0x007a) {
1248        LeSetTransmitPowerReportingEnableParams {
1249            local_enable: bool,
1250            remote_enable: bool,
1251        }
1252        Return = ConnHandle;
1253        Handle = handle: ConnHandle;
1254    }
1255}
1256
1257cmd! {
1258    /// LE Set Data Related Address Changes command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-cd6cc02d-3496-3d16-22cb-37f39c2df763)
1259    LeSetDataRelatedAddrChanges(LE, 0x007c) {
1260        LeSetDataRelatedAddrChangesParams {
1261            adv_handle: AdvHandle,
1262            change_reasons: LeDataRelatedAddrChangeReasons,
1263        }
1264        Return = ();
1265    }
1266}
1267
1268cmd! {
1269    /// LE Set Default Subrate command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-60/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-d486bcfd-562a-3bef-e705-676715c6c3cc)
1270    LeSetDefaultSubrate(LE, 0x007d) {
1271        LeSetDefaultSubrateParams {
1272            subrate_min: u16,
1273            subrate_max: u16,
1274            max_latency: u16,
1275            continuation_number: u16,
1276            supervision_timeout: Duration<10_000>,
1277        }
1278        Return = ();
1279    }
1280}
1281
1282cmd! {
1283    /// LE Subrate Request command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-60/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-e8e89250-dd32-6ec9-5aa4-04678fee288b)
1284    LeSubrateRequest(LE, 0x007e) {
1285        LeSubrateRequestParams {
1286            handle: ConnHandle,
1287            subrate_min: u16,
1288            subrate_max: u16,
1289            max_latency: u16,
1290            continuation_number: u16,
1291            supervision_timeout: Duration<10_000>,
1292        }
1293    }
1294}
1295
1296cmd! {
1297    BASE
1298    /// LE Set Periodic Advertising Subevent Data command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-927cb8c3-4a12-6154-d2f2-384f4a10f0a4)
1299    LeSetPeriodicAdvSubeventData(LE, 0x0082) {
1300        Params<'a> = LeSetPeriodicAdvSubeventDataParams<'a, 'a>;
1301        Return = AdvHandle;
1302    }
1303}
1304
1305impl<'a> LeSetPeriodicAdvSubeventData<'a> {
1306    /// Create a new instance.
1307    pub fn new(adv_handle: AdvHandle, subevent: &'a [LePeriodicAdvSubeventData<'a>]) -> Self {
1308        Self(LeSetPeriodicAdvSubeventDataParams { adv_handle, subevent })
1309    }
1310}
1311
1312/// Parameters for LE Set Periodic Advertising Subevent Data command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-927cb8c3-4a12-6154-d2f2-384f4a10f0a4)
1313#[derive(Default, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
1314#[cfg_attr(feature = "defmt", derive(defmt::Format))]
1315pub struct LeSetPeriodicAdvSubeventDataParams<'a, 'b> {
1316    /// Which advertising handle to use.
1317    pub adv_handle: AdvHandle,
1318    /// List of sub events used.
1319    pub subevent: &'b [LePeriodicAdvSubeventData<'a>],
1320}
1321
1322impl WriteHci for LeSetPeriodicAdvSubeventDataParams<'_, '_> {
1323    #[inline(always)]
1324    fn size(&self) -> usize {
1325        self.adv_handle.size() + self.subevent.size()
1326    }
1327
1328    #[inline(always)]
1329    fn write_hci<W: ::embedded_io::Write>(&self, mut writer: W) -> Result<(), W::Error> {
1330        self.adv_handle.write_hci(&mut writer)?;
1331        self.subevent.write_hci(&mut writer)?;
1332        Ok(())
1333    }
1334
1335    #[inline(always)]
1336    async fn write_hci_async<W: ::embedded_io_async::Write>(&self, mut writer: W) -> Result<(), W::Error> {
1337        self.adv_handle.write_hci_async(&mut writer).await?;
1338        self.subevent.write_hci_async(&mut writer).await?;
1339        Ok(())
1340    }
1341}
1342
1343cmd! {
1344    /// LE Set Periodic Advertising Response Data command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-8ada75aa-8e1f-c742-6441-8dd1164fc646)
1345    LeSetPeriodicAdvResponseData(LE, 0x0083) {
1346        LeSetPeriodicAdvResponseDataParams<'a> {
1347            adv_handle: SyncHandle,
1348            request_event: u16,
1349            request_subevent: u8,
1350            response_subevent: u8,
1351            response_slot: u8,
1352            response_data: &'a [u8],
1353        }
1354        Return = SyncHandle;
1355    }
1356}
1357
1358cmd! {
1359    /// LE Set Periodic Sync Subevent command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-e3b9bdd9-b435-9adf-2516-ad94e14ece70)
1360    LeSetPeriodicSyncSubevent(LE, 0x0084) {
1361        LeSetPeriodicSyncSubeventParams<'a> {
1362            adv_handle: SyncHandle,
1363            periodic_adv_props: PeriodicAdvProps,
1364            subevents: &'a [u8],
1365        }
1366        Return = SyncHandle;
1367    }
1368}
1369
1370cmd! {
1371    /// LE Set Host Feature V2 command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-60/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-c8e1603a-50b7-6ba6-2867-d9c78fd5c89d)
1372    LeSetHostFeatureV2(LE, 0x0097) {
1373        LeSetHostFeatureV2Params {
1374            bit_number: u16,
1375            bit_value: u8,
1376        }
1377        Return = ();
1378    }
1379}
1380
1381cmd! {
1382    /// LE Frame Space Update command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-60/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-d13d94d2-5a3c-66a9-9a17-89659b5dbda6)
1383    LeFrameSpaceUpdate(LE, 0x009D) {
1384        LeFrameSpaceUpdateParams {
1385            handle: ConnHandle,
1386            frame_space_min: Duration<1>,
1387            frame_space_max: Duration<1>,
1388            phy: PhyMask,
1389            spacing_types: SpacingTypes,
1390        }
1391        Return = ();
1392    }
1393}
1394
1395cmd! {
1396    /// LE Connection Rate Request command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-62/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-d09bc90b-2b78-6a0b-c33d-cc086e4e7e66)
1397    LeConnectionRateRequest(LE, 0x00A1) {
1398        LeConnectionRateRequestParams {
1399            handle: ConnHandle,
1400            conn_interval_min: Duration<125>,
1401            conn_interval_max: Duration<125>,
1402            subrate_min: u16,
1403            subrate_max: u16,
1404            max_latency: u16,
1405            continuation_number: u16,
1406            supervision_timeout: Duration<10_000>,
1407            min_ce_length: Duration<125>,
1408            max_ce_length: Duration<125>,
1409        }
1410        Return = ();
1411    }
1412}
1413
1414cmd! {
1415    /// LE Set Default Rate Parameters command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-62/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-4d7dcf09-f740-e58a-d0ea-41f29e7bed37)
1416    LeSetDefaultRateParameters(LE, 0x00A2) {
1417        LeSetDefaultRateParametersParams {
1418            conn_interval_min: Duration<125>,
1419            conn_interval_max: Duration<125>,
1420            subrate_min: u16,
1421            subrate_max: u16,
1422            max_latency: u16,
1423            continuation_number: u16,
1424            supervision_timeout: Duration<10_000>,
1425            min_ce_length: Duration<125>,
1426            max_ce_length: Duration<125>,
1427        }
1428        Return = ();
1429    }
1430}
1431
1432cmd! {
1433    /// LE Read Minimum Supported Connection Interval command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-62/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-1cb9e115-3445-39f6-38de-cc3fc5dcb4c7)
1434    LeReadMinimumSupportedConnectionInterval(LE, 0x00A3) {
1435        Params = ();
1436        LeReadMinimumSupportedConnectionIntervalReturn {
1437            minimum_supported_connection_interval: DurationU8<125>,
1438            num_groups: u8,
1439            groups: [ConnIntervalGroup; 255],
1440        }
1441    }
1442}
1443
1444// ============================================================================
1445// ISO / LE Audio commands (Bluetooth Core Specification v5.4+)
1446// ============================================================================
1447
1448cmd! {
1449    /// LE Read ISO TX Sync command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-cf634e13-b00c-6cfc-0b17-207ac33e6b61)
1450    LeReadIsoTxSync(LE, 0x0061) {
1451        Params = ConnHandle;
1452        LeReadIsoTxSyncReturn {
1453            packet_sequence_number: u16,
1454            tx_time_stamp: u32,
1455            time_offset: ExtDuration<1>,
1456        }
1457        Handle = handle: ConnHandle;
1458    }
1459}
1460
1461cmd! {
1462    /// LE Set CIG Parameters command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-9b09845e-f6b6-d9a5-229e-67c56ef64bbd)
1463    LeSetCigParameters(LE, 0x0062) {
1464        LeSetCigParametersParams<'a> {
1465            cig_id: CigId,
1466            sdu_interval_c_to_p: ExtDuration<1>,
1467            sdu_interval_p_to_c: ExtDuration<1>,
1468            ft_c_to_p: u8,
1469            ft_p_to_c: u8,
1470            iso_interval: u16,
1471            worst_case_sca: u8,
1472            packing: Packing,
1473            framing: Framing,
1474            cis_configs: &'a [CisConfig],
1475        }
1476        LeSetCigParametersReturn {
1477            cig_id: CigId,
1478            num_cis: u8,
1479            cis_handles: [ConnHandle; 31],
1480        }
1481    }
1482}
1483
1484cmd! {
1485    /// LE Set CIG Parameters Test command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-7e0787ab-982b-5f41-25d9-36b34a0296ec)
1486    LeSetCigParametersTest(LE, 0x0063) {
1487        LeSetCigParametersTestParams<'a> {
1488            cig_id: CigId,
1489            sdu_interval_c_to_p: ExtDuration<1>,
1490            sdu_interval_p_to_c: ExtDuration<1>,
1491            ft_c_to_p: u8,
1492            ft_p_to_c: u8,
1493            iso_interval: u16,
1494            worst_case_sca: u8,
1495            packing: Packing,
1496            framing: Framing,
1497            cis_configs: &'a [CisConfigTest],
1498        }
1499        LeSetCigParametersTestReturn {
1500            cig_id: CigId,
1501            num_cis: u8,
1502            cis_handles: [ConnHandle; 31],
1503        }
1504    }
1505}
1506
1507cmd! {
1508    /// LE Create CIS command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-4c126319-a7b1-6765-ab23-04777e78599f)
1509    LeCreateCis(LE, 0x0064) {
1510        LeCreateCisParams<'a> {
1511            cig_id: CigId,
1512            cis_configs: &'a [CisConnConfig],
1513        }
1514    }
1515}
1516
1517cmd! {
1518    /// LE Remove CIG command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-0d4fd619-7ae9-67ef-8f00-70264a5b3a0c)
1519    LeRemoveCig(LE, 0x0065) {
1520        Params = CigId;
1521        LeRemoveCigReturn {
1522            cig_id: CigId,
1523        }
1524    }
1525}
1526
1527cmd! {
1528    /// LE Accept CIS Request command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-999840ef-fb58-166d-2822-14b10a259d20)
1529    LeAcceptCisRequest(LE, 0x0066) {
1530        Params = ConnHandle;
1531    }
1532}
1533
1534cmd! {
1535    /// LE Reject CIS Request command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-bb5d147e-a5d2-9fd0-b7a2-a2e9827a965a)
1536    LeRejectCisRequest(LE, 0x0067) {
1537        LeRejectCisRequestParams {
1538            reason: u8,
1539        }
1540        Return = ConnHandle;
1541        Handle = handle: ConnHandle;
1542    }
1543}
1544
1545cmd! {
1546    /// LE Create BIG command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-b085cd32-0c2b-9b20-acfa-c825ee69820f)
1547    LeCreateBig(LE, 0x0068) {
1548        LeCreateBigParams {
1549            big_handle: u8,
1550            adv_handle: AdvHandle,
1551            num_bis: u8,
1552            sdu_interval: ExtDuration<1>,
1553            max_sdu: u16,
1554            max_transport_latency: u16,
1555            rtn: u8,
1556            phy: PhyMask,
1557            packing: Packing,
1558            framing: Framing,
1559            encryption: EncryptionMode,
1560            broadcast_code: BroadcastCode,
1561        }
1562    }
1563}
1564
1565cmd! {
1566    BASE
1567    /// LE Create BIG Test command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-a15005d1-019f-e827-284b-e8ee558d9a69)
1568    LeCreateBigTest(LE, 0x0069) {
1569        Params<'a> = LeCreateBigTestParams<'a>;
1570    }
1571}
1572
1573impl<'a> LeCreateBigTest<'a> {
1574    /// Create a new instance.
1575    #[allow(clippy::too_many_arguments)]
1576    pub fn new(
1577        big_handle: u8,
1578        adv_handle: AdvHandle,
1579        num_bis: u8,
1580        sdu_interval: ExtDuration<1>,
1581        iso_interval: u16,
1582        nse: u8,
1583        max_sdu: u16,
1584        max_pdu: u16,
1585        phy: PhyMask,
1586        packing: Packing,
1587        framing: Framing,
1588        bn: u8,
1589        irc: u8,
1590        pto: u8,
1591        encryption: EncryptionMode,
1592        broadcast_code: BroadcastCode,
1593        bis_handles: &'a [ConnHandle],
1594    ) -> Self {
1595        Self(LeCreateBigTestParams {
1596            big_handle,
1597            adv_handle,
1598            num_bis,
1599            sdu_interval,
1600            iso_interval,
1601            nse,
1602            max_sdu,
1603            max_pdu,
1604            phy,
1605            packing,
1606            framing,
1607            bn,
1608            irc,
1609            pto,
1610            encryption,
1611            broadcast_code,
1612            bis_handles,
1613        })
1614    }
1615}
1616
1617/// Parameters for LE Create BIG Test command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html)
1618#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
1619#[cfg_attr(feature = "defmt", derive(defmt::Format))]
1620pub struct LeCreateBigTestParams<'a> {
1621    /// BIG handle.
1622    pub big_handle: u8,
1623    /// Advertising handle.
1624    pub adv_handle: AdvHandle,
1625    /// Number of BIS.
1626    pub num_bis: u8,
1627    /// SDU interval.
1628    pub sdu_interval: ExtDuration<1>,
1629    /// ISO interval.
1630    pub iso_interval: u16,
1631    /// Number of subevents.
1632    pub nse: u8,
1633    /// Maximum SDU.
1634    pub max_sdu: u16,
1635    /// Maximum PDU.
1636    pub max_pdu: u16,
1637    /// PHY.
1638    pub phy: PhyMask,
1639    /// Packing.
1640    pub packing: Packing,
1641    /// Framing.
1642    pub framing: Framing,
1643    /// Burst number.
1644    pub bn: u8,
1645    /// Immediate repetition count.
1646    pub irc: u8,
1647    /// Pre-transmission offset.
1648    pub pto: u8,
1649    /// Encryption mode.
1650    pub encryption: EncryptionMode,
1651    /// Broadcast code.
1652    pub broadcast_code: BroadcastCode,
1653    /// BIS handles.
1654    pub bis_handles: &'a [ConnHandle],
1655}
1656
1657impl WriteHci for LeCreateBigTestParams<'_> {
1658    #[inline(always)]
1659    fn size(&self) -> usize {
1660        1 + 1 + 1 + 3 + 2 + 1 + 2 + 2 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 16 + mem::size_of_val(self.bis_handles)
1661    }
1662
1663    #[inline(always)]
1664    fn write_hci<W: embedded_io::Write>(&self, mut writer: W) -> Result<(), W::Error> {
1665        self.big_handle.write_hci(&mut writer)?;
1666        self.adv_handle.write_hci(&mut writer)?;
1667        self.num_bis.write_hci(&mut writer)?;
1668        self.sdu_interval.write_hci(&mut writer)?;
1669        self.iso_interval.write_hci(&mut writer)?;
1670        self.nse.write_hci(&mut writer)?;
1671        self.max_sdu.write_hci(&mut writer)?;
1672        self.max_pdu.write_hci(&mut writer)?;
1673        self.phy.write_hci(&mut writer)?;
1674        self.packing.write_hci(&mut writer)?;
1675        self.framing.write_hci(&mut writer)?;
1676        self.bn.write_hci(&mut writer)?;
1677        self.irc.write_hci(&mut writer)?;
1678        self.pto.write_hci(&mut writer)?;
1679        self.encryption.write_hci(&mut writer)?;
1680        self.broadcast_code.write_hci(&mut writer)?;
1681        for h in self.bis_handles {
1682            h.write_hci(&mut writer)?;
1683        }
1684        Ok(())
1685    }
1686
1687    #[inline(always)]
1688    async fn write_hci_async<W: embedded_io_async::Write>(&self, mut writer: W) -> Result<(), W::Error> {
1689        self.big_handle.write_hci_async(&mut writer).await?;
1690        self.adv_handle.write_hci_async(&mut writer).await?;
1691        self.num_bis.write_hci_async(&mut writer).await?;
1692        self.sdu_interval.write_hci_async(&mut writer).await?;
1693        self.iso_interval.write_hci_async(&mut writer).await?;
1694        self.nse.write_hci_async(&mut writer).await?;
1695        self.max_sdu.write_hci_async(&mut writer).await?;
1696        self.max_pdu.write_hci_async(&mut writer).await?;
1697        self.phy.write_hci_async(&mut writer).await?;
1698        self.packing.write_hci_async(&mut writer).await?;
1699        self.framing.write_hci_async(&mut writer).await?;
1700        self.bn.write_hci_async(&mut writer).await?;
1701        self.irc.write_hci_async(&mut writer).await?;
1702        self.pto.write_hci_async(&mut writer).await?;
1703        self.encryption.write_hci_async(&mut writer).await?;
1704        self.broadcast_code.write_hci_async(&mut writer).await?;
1705        for h in self.bis_handles {
1706            h.write_hci_async(&mut writer).await?;
1707        }
1708        Ok(())
1709    }
1710}
1711
1712cmd! {
1713    /// LE Terminate BIG command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-aa21e86e-aeb9-35a3-dbf4-15d48fc30491)
1714    LeTerminateBig(LE, 0x006a) {
1715        LeTerminateBigParams {
1716            big_handle: u8,
1717            reason: u8,
1718        }
1719    }
1720}
1721
1722cmd! {
1723    BASE
1724    /// LE BIG Create Sync command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-19c7d386-e227-0e12-cd0b-eb567f3c7d18)
1725    LeBigCreateSync(LE, 0x006b) {
1726        Params<'a> = LeBigCreateSyncParams<'a>;
1727    }
1728}
1729
1730impl<'a> LeBigCreateSync<'a> {
1731    /// Create a new instance.
1732    pub fn new(
1733        big_sync_handle: BigHandle,
1734        encryption: EncryptionMode,
1735        broadcast_code: BroadcastCode,
1736        mse: u8,
1737        big_sync_timeout: u16,
1738        num_bis: u8,
1739        bis: &'a [u8],
1740    ) -> Self {
1741        Self(LeBigCreateSyncParams {
1742            big_sync_handle,
1743            encryption,
1744            broadcast_code,
1745            mse,
1746            big_sync_timeout,
1747            num_bis,
1748            bis,
1749        })
1750    }
1751}
1752
1753/// Parameters for LE BIG Create Sync command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html)
1754#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
1755#[cfg_attr(feature = "defmt", derive(defmt::Format))]
1756pub struct LeBigCreateSyncParams<'a> {
1757    /// BIG sync handle.
1758    pub big_sync_handle: BigHandle,
1759    /// Encryption mode.
1760    pub encryption: EncryptionMode,
1761    /// Broadcast code.
1762    pub broadcast_code: BroadcastCode,
1763    /// Maximum subevents.
1764    pub mse: u8,
1765    /// BIG sync timeout.
1766    pub big_sync_timeout: u16,
1767    /// Number of BIS.
1768    pub num_bis: u8,
1769    /// BIS indices.
1770    pub bis: &'a [u8],
1771}
1772
1773impl WriteHci for LeBigCreateSyncParams<'_> {
1774    #[inline(always)]
1775    fn size(&self) -> usize {
1776        2 + 1 + 16 + 1 + 2 + 1 + self.bis.len()
1777    }
1778
1779    #[inline(always)]
1780    fn write_hci<W: embedded_io::Write>(&self, mut writer: W) -> Result<(), W::Error> {
1781        self.big_sync_handle.write_hci(&mut writer)?;
1782        self.encryption.write_hci(&mut writer)?;
1783        self.broadcast_code.write_hci(&mut writer)?;
1784        self.mse.write_hci(&mut writer)?;
1785        self.big_sync_timeout.write_hci(&mut writer)?;
1786        self.num_bis.write_hci(&mut writer)?;
1787        writer.write_all(self.bis)
1788    }
1789
1790    #[inline(always)]
1791    async fn write_hci_async<W: embedded_io_async::Write>(&self, mut writer: W) -> Result<(), W::Error> {
1792        self.big_sync_handle.write_hci_async(&mut writer).await?;
1793        self.encryption.write_hci_async(&mut writer).await?;
1794        self.broadcast_code.write_hci_async(&mut writer).await?;
1795        self.mse.write_hci_async(&mut writer).await?;
1796        self.big_sync_timeout.write_hci_async(&mut writer).await?;
1797        self.num_bis.write_hci_async(&mut writer).await?;
1798        writer.write_all(self.bis).await
1799    }
1800}
1801
1802cmd! {
1803    /// LE BIG Terminate Sync command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-94cd26e9-d16d-2b51-a84e-90fca3d503a9)
1804    LeBigTerminateSync(LE, 0x006c) {
1805        Params = BigHandle;
1806        Return = BigHandle;
1807        Handle = BigHandle;
1808    }
1809}
1810
1811cmd! {
1812    BASE
1813    /// LE Setup ISO Data Path command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-d93e717d-07ab-4342-fe66-c09383326a37)
1814    LeSetupIsoDataPath(LE, 0x006e) {
1815        Params<'a> = LeSetupIsoDataPathParams<'a>;
1816        Return = ConnHandle;
1817        Handle = ConnHandle;
1818    }
1819}
1820
1821impl<'a> LeSetupIsoDataPath<'a> {
1822    /// Create a new instance.
1823    pub fn new(
1824        handle: ConnHandle,
1825        data_path_direction: DataPathDirection,
1826        data_path_id: DataPathId,
1827        codec_id: CodecId,
1828        controller_delay: ExtDuration<1>,
1829        codec_configuration: &'a [u8],
1830    ) -> Self {
1831        Self(LeSetupIsoDataPathParams {
1832            handle,
1833            data_path_direction,
1834            data_path_id,
1835            codec_id,
1836            controller_delay,
1837            codec_configuration,
1838        })
1839    }
1840
1841    fn handle(&self) -> ConnHandle {
1842        self.0.handle
1843    }
1844}
1845
1846/// Parameters for LE Setup ISO Data Path command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html)
1847#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
1848#[cfg_attr(feature = "defmt", derive(defmt::Format))]
1849pub struct LeSetupIsoDataPathParams<'a> {
1850    /// Connection handle.
1851    pub handle: ConnHandle,
1852    /// Data path direction.
1853    pub data_path_direction: DataPathDirection,
1854    /// Data path ID.
1855    pub data_path_id: DataPathId,
1856    /// Codec ID.
1857    pub codec_id: CodecId,
1858    /// Controller delay.
1859    pub controller_delay: ExtDuration<1>,
1860    /// Codec configuration.
1861    pub codec_configuration: &'a [u8],
1862}
1863
1864impl WriteHci for LeSetupIsoDataPathParams<'_> {
1865    #[inline(always)]
1866    fn size(&self) -> usize {
1867        2 + 1 + 1 + 5 + 3 + 1 + self.codec_configuration.len()
1868    }
1869
1870    #[inline(always)]
1871    fn write_hci<W: embedded_io::Write>(&self, mut writer: W) -> Result<(), W::Error> {
1872        self.handle.write_hci(&mut writer)?;
1873        self.data_path_direction.write_hci(&mut writer)?;
1874        self.data_path_id.write_hci(&mut writer)?;
1875        self.codec_id.write_hci(&mut writer)?;
1876        self.controller_delay.write_hci(&mut writer)?;
1877        (self.codec_configuration.len() as u8).write_hci(&mut writer)?;
1878        writer.write_all(self.codec_configuration)
1879    }
1880
1881    #[inline(always)]
1882    async fn write_hci_async<W: embedded_io_async::Write>(&self, mut writer: W) -> Result<(), W::Error> {
1883        self.handle.write_hci_async(&mut writer).await?;
1884        self.data_path_direction.write_hci_async(&mut writer).await?;
1885        self.data_path_id.write_hci_async(&mut writer).await?;
1886        self.codec_id.write_hci_async(&mut writer).await?;
1887        self.controller_delay.write_hci_async(&mut writer).await?;
1888        (self.codec_configuration.len() as u8)
1889            .write_hci_async(&mut writer)
1890            .await?;
1891        writer.write_all(self.codec_configuration).await
1892    }
1893}
1894
1895cmd! {
1896    /// LE Remove ISO Data Path command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-13ba6ab3-ba00-3bde-f665-cbe23031e3dd)
1897    LeRemoveIsoDataPath(LE, 0x006f) {
1898        LeRemoveIsoDataPathParams {
1899            data_path_direction: DataPathDirection,
1900        }
1901        Return = ConnHandle;
1902        Handle = handle: ConnHandle;
1903    }
1904}
1905
1906cmd! {
1907    /// LE ISO Transmit Test command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-7a343577-d006-456f-0351-9ff745b156ff)
1908    LeIsoTransmitTest(LE, 0x0070) {
1909        LeIsoTransmitTestParams {
1910            payload_type: PayloadType,
1911        }
1912        Return = ConnHandle;
1913        Handle = handle: ConnHandle;
1914    }
1915}
1916
1917cmd! {
1918    /// LE ISO Receive Test command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-ec377f99-b758-f458-701b-a2e7c02468b0)
1919    LeIsoReceiveTest(LE, 0x0071) {
1920        LeIsoReceiveTestParams {
1921            payload_type: PayloadType,
1922        }
1923        Return = ConnHandle;
1924        Handle = handle: ConnHandle;
1925    }
1926}
1927
1928cmd! {
1929    /// LE ISO Read Test Counters command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-11231b0e-6027-2024-f2dc-8338dfc3bf5b)
1930    LeIsoReadTestCounters(LE, 0x0072) {
1931        Params = ConnHandle;
1932        LeIsoReadTestCountersReturn {
1933            received_sdu_count: u32,
1934            missed_sdu_count: u32,
1935            failed_sdu_count: u32,
1936        }
1937        Handle = handle: ConnHandle;
1938    }
1939}
1940
1941cmd! {
1942    /// LE ISO Test End command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-a406d2c9-513e-03d9-854b-5bc0974373dc)
1943    LeIsoTestEnd(LE, 0x0073) {
1944        Params = ConnHandle;
1945        LeIsoTestEndReturn {
1946            received_sdu_count: u32,
1947            missed_sdu_count: u32,
1948            failed_sdu_count: u32,
1949        }
1950        Handle = handle: ConnHandle;
1951    }
1952}
1953
1954cmd! {
1955    /// LE Read ISO Link Quality command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-4f70cb64-62e9-0b89-90ba-7f3c033f1f72)
1956    LeReadIsoLinkQuality(LE, 0x0075) {
1957        Params = ConnHandle;
1958        LeReadIsoLinkQualityReturn {
1959            tx_unacked_packets: u32,
1960            tx_flushed_packets: u32,
1961            tx_last_sdu_subevent_packets: u32,
1962            retx_packets: u32,
1963            crc_error_packets: u32,
1964            rx_unreceived_packets: u32,
1965            duplicate_packets: u32,
1966        }
1967        Handle = handle: ConnHandle;
1968    }
1969}
1970
1971// ============================================================================
1972// Missing test-mode commands
1973// ============================================================================
1974
1975cmd! {
1976    BASE
1977    /// LE Transmitter Test V3 command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-15c2cfce-06a0-5da7-5cbb-45c1896cca8d)
1978    LeTransmitterTestV3(LE, 0x005e) {
1979        Params<'a> = LeTransmitterTestV3Params<'a>;
1980        Return = ();
1981    }
1982}
1983
1984impl<'a> LeTransmitterTestV3<'a> {
1985    /// Create a new instance.
1986    pub fn new(
1987        tx_channel: u8,
1988        test_data_length: u8,
1989        packet_payload: u8,
1990        phy: PhyMask,
1991        cte_length: u8,
1992        cte_type: CteKind,
1993        switching_pattern: &'a [u8],
1994    ) -> Self {
1995        Self(LeTransmitterTestV3Params {
1996            tx_channel,
1997            test_data_length,
1998            packet_payload,
1999            phy,
2000            cte_length,
2001            cte_type,
2002            switching_pattern,
2003        })
2004    }
2005}
2006
2007/// Parameters for LE Transmitter Test V3 command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html)
2008#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
2009#[cfg_attr(feature = "defmt", derive(defmt::Format))]
2010pub struct LeTransmitterTestV3Params<'a> {
2011    /// TX channel.
2012    pub tx_channel: u8,
2013    /// Test data length.
2014    pub test_data_length: u8,
2015    /// Packet payload.
2016    pub packet_payload: u8,
2017    /// PHY.
2018    pub phy: PhyMask,
2019    /// CTE length.
2020    pub cte_length: u8,
2021    /// CTE type.
2022    pub cte_type: CteKind,
2023    /// Antenna switching pattern.
2024    pub switching_pattern: &'a [u8],
2025}
2026
2027impl WriteHci for LeTransmitterTestV3Params<'_> {
2028    #[inline(always)]
2029    fn size(&self) -> usize {
2030        1 + 1 + 1 + 1 + 1 + 1 + 1 + self.switching_pattern.len()
2031    }
2032
2033    #[inline(always)]
2034    fn write_hci<W: embedded_io::Write>(&self, mut writer: W) -> Result<(), W::Error> {
2035        self.tx_channel.write_hci(&mut writer)?;
2036        self.test_data_length.write_hci(&mut writer)?;
2037        self.packet_payload.write_hci(&mut writer)?;
2038        self.phy.write_hci(&mut writer)?;
2039        self.cte_length.write_hci(&mut writer)?;
2040        self.cte_type.write_hci(&mut writer)?;
2041        (self.switching_pattern.len() as u8).write_hci(&mut writer)?;
2042        writer.write_all(self.switching_pattern)
2043    }
2044
2045    #[inline(always)]
2046    async fn write_hci_async<W: embedded_io_async::Write>(&self, mut writer: W) -> Result<(), W::Error> {
2047        self.tx_channel.write_hci_async(&mut writer).await?;
2048        self.test_data_length.write_hci_async(&mut writer).await?;
2049        self.packet_payload.write_hci_async(&mut writer).await?;
2050        self.phy.write_hci_async(&mut writer).await?;
2051        self.cte_length.write_hci_async(&mut writer).await?;
2052        self.cte_type.write_hci_async(&mut writer).await?;
2053        (self.switching_pattern.len() as u8)
2054            .write_hci_async(&mut writer)
2055            .await?;
2056        writer.write_all(self.switching_pattern).await
2057    }
2058}
2059
2060cmd! {
2061    BASE
2062    /// LE Receiver Test V3 command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html#UUID-d5d30b61-e8be-8fa5-a04b-7d505a74ea9d)
2063    LeReceiverTestV3(LE, 0x005f) {
2064        Params<'a> = LeReceiverTestV3Params<'a>;
2065        Return = ();
2066    }
2067}
2068
2069impl<'a> LeReceiverTestV3<'a> {
2070    /// Create a new instance.
2071    pub fn new(
2072        rx_channel: u8,
2073        phy: PhyMask,
2074        modulation_index: u8,
2075        expected_cte_length: u8,
2076        expected_cte_type: CteKind,
2077        slot_durations: u8,
2078        switching_pattern: &'a [u8],
2079    ) -> Self {
2080        Self(LeReceiverTestV3Params {
2081            rx_channel,
2082            phy,
2083            modulation_index,
2084            expected_cte_length,
2085            expected_cte_type,
2086            slot_durations,
2087            switching_pattern,
2088        })
2089    }
2090}
2091
2092/// Parameters for LE Receiver Test V3 command [📖](https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host-controller-interface/host-controller-interface-functional-specification.html)
2093#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
2094#[cfg_attr(feature = "defmt", derive(defmt::Format))]
2095pub struct LeReceiverTestV3Params<'a> {
2096    /// RX channel.
2097    pub rx_channel: u8,
2098    /// PHY.
2099    pub phy: PhyMask,
2100    /// Modulation index.
2101    pub modulation_index: u8,
2102    /// Expected CTE length.
2103    pub expected_cte_length: u8,
2104    /// Expected CTE type.
2105    pub expected_cte_type: CteKind,
2106    /// Slot durations.
2107    pub slot_durations: u8,
2108    /// Antenna switching pattern.
2109    pub switching_pattern: &'a [u8],
2110}
2111
2112impl WriteHci for LeReceiverTestV3Params<'_> {
2113    #[inline(always)]
2114    fn size(&self) -> usize {
2115        1 + 1 + 1 + 1 + 1 + 1 + 1 + self.switching_pattern.len()
2116    }
2117
2118    #[inline(always)]
2119    fn write_hci<W: embedded_io::Write>(&self, mut writer: W) -> Result<(), W::Error> {
2120        self.rx_channel.write_hci(&mut writer)?;
2121        self.phy.write_hci(&mut writer)?;
2122        self.modulation_index.write_hci(&mut writer)?;
2123        self.expected_cte_length.write_hci(&mut writer)?;
2124        self.expected_cte_type.write_hci(&mut writer)?;
2125        self.slot_durations.write_hci(&mut writer)?;
2126        (self.switching_pattern.len() as u8).write_hci(&mut writer)?;
2127        writer.write_all(self.switching_pattern)
2128    }
2129
2130    #[inline(always)]
2131    async fn write_hci_async<W: embedded_io_async::Write>(&self, mut writer: W) -> Result<(), W::Error> {
2132        self.rx_channel.write_hci_async(&mut writer).await?;
2133        self.phy.write_hci_async(&mut writer).await?;
2134        self.modulation_index.write_hci_async(&mut writer).await?;
2135        self.expected_cte_length.write_hci_async(&mut writer).await?;
2136        self.expected_cte_type.write_hci_async(&mut writer).await?;
2137        self.slot_durations.write_hci_async(&mut writer).await?;
2138        (self.switching_pattern.len() as u8)
2139            .write_hci_async(&mut writer)
2140            .await?;
2141        writer.write_all(self.switching_pattern).await
2142    }
2143}