1pub mod stream_mapper;
2
3use num_enum::IntoPrimitive;
4use num_enum::TryFromPrimitive;
5
6use super::enums::*;
7
8#[repr(u8)]
9#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, IntoPrimitive, TryFromPrimitive)]
10pub enum OpCode {
11 AdvertisementPacket = 0,
12 CreateConnectionChannelResponse = 1,
13 ConnectionStatusChanged = 2,
14 ConnectionChannelRemoved = 3,
15 ButtonUpOrDown = 4,
16 ButtonClickOrHold = 5,
17 ButtonSingleOrDoubleClick = 6,
18 ButtonSingleOrDoubleClickOrHold = 7,
19 NewVerifiedButton = 8,
20 GetInfoResponse = 9,
21 NoSpaceForNewConnection = 10,
22 GotSpaceForNewConnection = 11,
23 BluetoothControllerStateChange = 12,
24 PingResponse = 13,
25 GetButtonInfoResponse = 14,
26 ScanWizardFoundPrivateButton = 15,
27 ScanWizardFoundPublicButton = 16,
28 ScanWizardButtonConnected = 17,
29 ScanWizardCompleted = 18,
30 ButtonDeleted = 19,
31 BatteryStatus = 20,
32}
33
34#[allow(dead_code)]
35#[derive(Debug, PartialEq, Eq, Clone)]
36pub enum Event {
37 NoOp,
38 CorruptEvent,
39
40 AdvertisementPacket {
41 scan_id: u32,
42 bd_addr: String,
43 name: String,
44 rssi: u8,
45 is_private: bool,
46 already_verified: bool,
47 already_connected_to_this_device: bool,
48 already_connected_to_other_device: bool,
49 },
50
51 CreateConnectionChannelResponse {
52 conn_id: u32,
53 error: CreateConnectionChannelError,
54 connection_status: ConnectionStatus,
55 },
56
57 ConnectionStatusChanged {
58 conn_id: u32,
59 connection_status: ConnectionStatus,
60 disconnect_reason: DisconnectReason,
61 },
62
63 ConnectionChannelRemoved {
64 conn_id: u32,
65 removed_reason: RemovedReason,
66 },
67
68 ButtonUpOrDown {
69 conn_id: u32,
70 click_type: ClickType,
71 was_queued: bool,
72 time_diff: i32,
73 },
74 ButtonClickOrHold {
75 conn_id: u32,
76 click_type: ClickType,
77 was_queued: bool,
78 time_diff: i32,
79 },
80 ButtonSingleOrDoubleClick {
81 conn_id: u32,
82 click_type: ClickType,
83 was_queued: bool,
84 time_diff: i32,
85 },
86 ButtonSingleOrDoubleClickOrHold {
87 conn_id: u32,
88 click_type: ClickType,
89 was_queued: bool,
90 time_diff: i32,
91 },
92
93 NewVerifiedButton {
94 bd_addr: String,
95 },
96
97 GetInfoResponse {
98 bluetooth_controller_state: BluetoothControllerState,
99 my_bd_addr: String,
100 my_bd_addr_type: BdAddrType,
101 max_pending_connections: u8,
102 max_concurrently_connected_buttons: i16,
103 current_pending_connections: u8,
104 currently_no_space_for_new_connection: bool,
105 bd_addr_of_verified_buttons: Vec<String>,
106 },
107
108 NoSpaceForNewConnection {
109 max_concurrently_connected_buttons: u8,
110 },
111
112 GotSpaceForNewConnection {
113 max_concurrently_connected_buttons: u8,
114 },
115
116 BluetoothControllerStateChange {
117 state: BluetoothControllerState,
118 },
119
120 PingResponse {
121 ping_id: u32,
122 },
123
124 GetButtonInfoResponse {
125 bd_addr: String,
126 uuid: String,
127 color: Option<String>,
128 serial_number: Option<String>,
129 },
130
131 ScanWizardFoundPrivateButton {
132 scan_wizard_id: u32,
133 },
134
135 ScanWizardFoundPublicButton {
136 scan_wizard_id: u32,
137 bd_addr: String,
138 name: String,
139 },
140
141 ScanWizardButtonConnected {
142 scan_wizard_id: u32,
143 },
144
145 ScanWizardCompleted {
146 scan_wizard_id: u32,
147 result: ScanWizardResult,
148 },
149
150 ButtonDeleted {
151 bd_addr: String,
152 deleted_by_this_client: bool,
153 },
154
155 BatteryStatus {
156 listener_id: u32,
157 battery_percentage: i8,
158 timestamp: u64,
159 },
160}