1#[derive(Clone, Copy, Debug, PartialEq, Eq)]
5#[cfg_attr(feature = "defmt", derive(defmt::Format))]
6pub struct Opcode(pub u16);
7
8impl Opcode {
9 pub const fn new(ogf: u16, ocf: u16) -> Opcode {
11 Opcode((ogf << 10) | (ocf & 0x03ff))
12 }
13
14 pub fn ogf(&self) -> u16 {
16 self.0 >> 10
17 }
18
19 pub fn ocf(&self) -> u16 {
21 self.0 & 0x03ff
22 }
23}
24
25macro_rules! opcodes {
26 (
27 $(
28 $_ogf_comment:ident = $ogf:expr;
29 {
30 $(pub const $var:ident = $ocf:expr;)+
31 }
32 )+
33 ) => {
34 $($(
35 pub const $var: Opcode = Opcode::new($ogf, $ocf);
36 )+)+
37 }
38}
39
40opcodes! {
41 LinkControl = 0x0001;
42 {
43 pub const DISCONNECT = 0x0006;
44 pub const READ_REMOTE_VERSION_INFO = 0x001D;
45 }
46
47 ControllerOrBaseband = 0x0003;
48 {
49 pub const SET_EVENT_MASK = 0x0001;
50 pub const RESET = 0x0003;
51 pub const READ_TX_POWER_LEVEL = 0x002D;
52 pub const SET_CONTROLLER_TO_HOST_FLOW_CONTROL = 0x031;
53 pub const HOST_BUFFER_SIZE = 0x033;
54 pub const NUMBER_OF_COMPLETED_PACKETS = 0x035;
55 }
56
57 InfoParam = 0x0004;
58 {
59 pub const READ_LOCAL_VERSION_INFO = 0x0001;
60 pub const READ_LOCAL_SUPPORTED_COMMANDS = 0x0002;
61 pub const READ_LOCAL_SUPPORTED_FEATURES = 0x0003;
62 pub const READ_BD_ADDR = 0x0009;
63 }
64
65 StatusParam = 0x0005;
66 {
67 pub const READ_RSSI = 0x0005;
68 }
69
70 LeCommands = 0x0008;
71 {
72 pub const LE_SET_EVENT_MASK = 0x0001;
73 pub const LE_READ_BUFFER_SIZE = 0x0002;
74 pub const LE_READ_LOCAL_SUPPORTED_FEATURES = 0x0003;
75 pub const LE_SET_RANDOM_ADDRESS = 0x0005;
76 pub const LE_SET_ADVERTISING_PARAMETERS = 0x0006;
77 pub const LE_READ_ADVERTISING_CHANNEL_TX_POWER = 0x0007;
78 pub const LE_SET_ADVERTISING_DATA = 0x0008;
79 pub const LE_SET_SCAN_RESPONSE_DATA = 0x0009;
80 pub const LE_SET_ADVERTISE_ENABLE = 0x000A;
81 pub const LE_SET_SCAN_PARAMETERS = 0x000B;
82 pub const LE_SET_SCAN_ENABLE = 0x000C;
83 pub const LE_CREATE_CONNECTION = 0x000D;
84 pub const LE_CREATE_CONNECTION_CANCEL = 0x000E;
85 pub const LE_READ_WHITE_LIST_SIZE = 0x000F;
86 pub const LE_CLEAR_WHITE_LIST = 0x0010;
87 pub const LE_ADD_DEVICE_TO_WHITE_LIST = 0x0011;
88 pub const LE_REMOVE_DEVICE_FROM_WHITE_LIST = 0x0012;
89 pub const LE_CONNECTION_UPDATE = 0x0013;
90 pub const LE_SET_HOST_CHANNEL_CLASSIFICATION = 0x0014;
91 pub const LE_READ_CHANNEL_MAP = 0x0015;
92 pub const LE_READ_REMOTE_USED_FEATURES = 0x0016;
93 pub const LE_ENCRYPT = 0x0017;
94 pub const LE_RAND = 0x0018;
95 pub const LE_START_ENCRYPTION = 0x0019;
96 pub const LE_LTK_REQUEST_REPLY = 0x001A;
97 pub const LE_LTK_REQUEST_NEGATIVE_REPLY = 0x001B;
98 pub const LE_READ_STATES = 0x001C;
99 pub const LE_RECEIVER_TEST = 0x001D;
100 pub const LE_TRANSMITTER_TEST = 0x001E;
101 pub const LE_TEST_END = 0x001F;
102 }
103}