stm32wb_hci/vendor/command/
mod.rs1macro_rules! impl_params {
2 ($method:ident, $param_type:ident, $opcode:path) => {
3 async fn $method(&mut self, params: &$param_type) {
4 let mut bytes = [0; $param_type::LENGTH];
5 params.copy_into_slice(&mut bytes);
6
7 self.controller_write($opcode, &bytes).await
8 }
9 };
10}
11
12macro_rules! impl_value_params {
13 ($method:ident, $param_type:ident, $opcode:path) => {
14 async fn $method(&mut self, params: $param_type) {
15 let mut bytes = [0; $param_type::LENGTH];
16 params.copy_into_slice(&mut bytes);
17
18 self.controller_write($opcode, &bytes).await
19 }
20 };
21}
22
23macro_rules! impl_validate_params {
24 ($method:ident, $param_type:ident, $opcode:path) => {
25 async fn $method(&mut self, params: &$param_type) -> Result<(), Error> {
26 params.validate()?;
27
28 let mut bytes = [0; $param_type::LENGTH];
29 params.copy_into_slice(&mut bytes);
30
31 self.controller_write($opcode, &bytes).await;
32
33 Ok(())
34 }
35 };
36}
37
38macro_rules! impl_variable_length_params {
39 ($method:ident, $param_type:ident, $opcode:path) => {
40 async fn $method(&mut self, params: &$param_type) {
41 let mut bytes = [0; $param_type::MAX_LENGTH];
42 params.copy_into_slice(&mut bytes);
43
44 self.controller_write($opcode, &bytes).await
45 }
46 };
47 ($method:ident<$($genlife:lifetime),*>, $param_type:ident<$($lifetime:lifetime),*>, $opcode:path) => {
48 async fn $method<$($genlife),*>(
49 &mut self,
50 params: &$param_type<$($lifetime),*>
51 ) {
52 let mut bytes = [0; $param_type::MAX_LENGTH];
53 params.copy_into_slice(&mut bytes);
54
55 self.controller_write($opcode, &bytes).await;
56 }
57 };
58}
59
60macro_rules! impl_validate_variable_length_params {
61 ($method:ident, $param_type:ident, $opcode:path) => {
62 async fn $method(&mut self, params: &$param_type) -> Result<(), Error> {
63 params.validate()?;
64
65 let mut bytes = [0; $param_type::MAX_LENGTH];
66 let len = params.copy_into_slice(&mut bytes);
67
68 self.controller_write($opcode, &bytes[..len]).await;
69
70 Ok(())
71 }
72 };
73 ($method:ident<$($genlife:lifetime),*>, $param_type:ident<$($lifetime:lifetime),*>, $opcode:path) => {
74 async fn $method<$($genlife),*>(
75 &mut self,
76 params: &$param_type<$($lifetime),*>
77 ) -> Result<(), Error> {
78 params.validate()?;
79
80 let mut bytes = [0; $param_type::MAX_LENGTH];
81 let len = params.copy_into_slice(&mut bytes);
82
83 self.controller_write($opcode, &bytes[..len]).await;
84
85 Ok(())
86 }
87 };
88}
89
90pub mod gap;
91pub mod gatt;
92pub mod hal;
93pub mod l2cap;