1use serde::{Serialize, Deserialize};
4use serde_json::Value as JsonValue;
5
6#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
9pub enum CentralState {
10 #[default]
11 Absent,
12 PoweredOff,
13 PoweredOn,
14}
15
16#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
19pub enum GATTOperationType {
20 #[default]
21 Connection,
22 Discovery,
23}
24
25#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
28pub enum CharacteristicWriteType {
29 #[default]
30 WriteDefaultDeprecated,
31 WriteWithResponse,
32 WriteWithoutResponse,
33}
34
35#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
38pub enum CharacteristicOperationType {
39 #[default]
40 Read,
41 Write,
42 SubscribeToNotifications,
43 UnsubscribeFromNotifications,
44}
45
46#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
49pub enum DescriptorOperationType {
50 #[default]
51 Read,
52 Write,
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize, Default)]
58#[serde(rename_all = "camelCase")]
59pub struct ManufacturerData {
60 pub key: i64,
65 pub data: String,
68}
69
70#[derive(Debug, Clone, Serialize, Deserialize, Default)]
73#[serde(rename_all = "camelCase")]
74pub struct ScanRecord {
75
76 #[serde(skip_serializing_if = "Option::is_none")]
77 pub name: Option<String>,
78
79 #[serde(skip_serializing_if = "Option::is_none")]
80 pub uuids: Option<Vec<String>>,
81 #[serde(skip_serializing_if = "Option::is_none")]
84 pub appearance: Option<i64>,
85 #[serde(skip_serializing_if = "Option::is_none")]
88 pub txPower: Option<i64>,
89 #[serde(skip_serializing_if = "Option::is_none")]
93 pub manufacturerData: Option<Vec<ManufacturerData>>,
94}
95
96#[derive(Debug, Clone, Serialize, Deserialize, Default)]
99#[serde(rename_all = "camelCase")]
100pub struct ScanEntry {
101
102 pub deviceAddress: String,
103
104 pub rssi: i64,
105
106 pub scanRecord: ScanRecord,
107}
108
109#[derive(Debug, Clone, Serialize, Deserialize, Default)]
113#[serde(rename_all = "camelCase")]
114pub struct CharacteristicProperties {
115
116 #[serde(skip_serializing_if = "Option::is_none")]
117 pub broadcast: Option<bool>,
118
119 #[serde(skip_serializing_if = "Option::is_none")]
120 pub read: Option<bool>,
121
122 #[serde(skip_serializing_if = "Option::is_none")]
123 pub writeWithoutResponse: Option<bool>,
124
125 #[serde(skip_serializing_if = "Option::is_none")]
126 pub write: Option<bool>,
127
128 #[serde(skip_serializing_if = "Option::is_none")]
129 pub notify: Option<bool>,
130
131 #[serde(skip_serializing_if = "Option::is_none")]
132 pub indicate: Option<bool>,
133
134 #[serde(skip_serializing_if = "Option::is_none")]
135 pub authenticatedSignedWrites: Option<bool>,
136
137 #[serde(skip_serializing_if = "Option::is_none")]
138 pub extendedProperties: Option<bool>,
139}
140
141#[derive(Debug, Clone, Serialize, Deserialize, Default)]
144#[serde(rename_all = "camelCase")]
145pub struct EnableParams {
146 pub state: CentralState,
149 pub leSupported: bool,
152}
153
154impl EnableParams { pub const METHOD: &'static str = "BluetoothEmulation.enable"; }
155
156impl crate::CdpCommand for EnableParams {
157 const METHOD: &'static str = "BluetoothEmulation.enable";
158 type Response = crate::EmptyReturns;
159}
160
161#[derive(Debug, Clone, Serialize, Deserialize, Default)]
164#[serde(rename_all = "camelCase")]
165pub struct SetSimulatedCentralStateParams {
166 pub state: CentralState,
169}
170
171impl SetSimulatedCentralStateParams { pub const METHOD: &'static str = "BluetoothEmulation.setSimulatedCentralState"; }
172
173impl crate::CdpCommand for SetSimulatedCentralStateParams {
174 const METHOD: &'static str = "BluetoothEmulation.setSimulatedCentralState";
175 type Response = crate::EmptyReturns;
176}
177
178#[derive(Debug, Clone, Serialize, Deserialize, Default)]
179pub struct DisableParams {}
180
181impl DisableParams { pub const METHOD: &'static str = "BluetoothEmulation.disable"; }
182
183impl crate::CdpCommand for DisableParams {
184 const METHOD: &'static str = "BluetoothEmulation.disable";
185 type Response = crate::EmptyReturns;
186}
187
188#[derive(Debug, Clone, Serialize, Deserialize, Default)]
192#[serde(rename_all = "camelCase")]
193pub struct SimulatePreconnectedPeripheralParams {
194
195 pub address: String,
196
197 pub name: String,
198
199 pub manufacturerData: Vec<ManufacturerData>,
200
201 pub knownServiceUuids: Vec<String>,
202}
203
204impl SimulatePreconnectedPeripheralParams { pub const METHOD: &'static str = "BluetoothEmulation.simulatePreconnectedPeripheral"; }
205
206impl crate::CdpCommand for SimulatePreconnectedPeripheralParams {
207 const METHOD: &'static str = "BluetoothEmulation.simulatePreconnectedPeripheral";
208 type Response = crate::EmptyReturns;
209}
210
211#[derive(Debug, Clone, Serialize, Deserialize, Default)]
215#[serde(rename_all = "camelCase")]
216pub struct SimulateAdvertisementParams {
217
218 pub entry: ScanEntry,
219}
220
221impl SimulateAdvertisementParams { pub const METHOD: &'static str = "BluetoothEmulation.simulateAdvertisement"; }
222
223impl crate::CdpCommand for SimulateAdvertisementParams {
224 const METHOD: &'static str = "BluetoothEmulation.simulateAdvertisement";
225 type Response = crate::EmptyReturns;
226}
227
228#[derive(Debug, Clone, Serialize, Deserialize, Default)]
233#[serde(rename_all = "camelCase")]
234pub struct SimulateGATTOperationResponseParams {
235
236 pub address: String,
237
238 #[serde(rename = "type")]
239 pub type_: GATTOperationType,
240
241 pub code: i64,
242}
243
244impl SimulateGATTOperationResponseParams { pub const METHOD: &'static str = "BluetoothEmulation.simulateGATTOperationResponse"; }
245
246impl crate::CdpCommand for SimulateGATTOperationResponseParams {
247 const METHOD: &'static str = "BluetoothEmulation.simulateGATTOperationResponse";
248 type Response = crate::EmptyReturns;
249}
250
251#[derive(Debug, Clone, Serialize, Deserialize, Default)]
258#[serde(rename_all = "camelCase")]
259pub struct SimulateCharacteristicOperationResponseParams {
260
261 pub characteristicId: String,
262
263 #[serde(rename = "type")]
264 pub type_: CharacteristicOperationType,
265
266 pub code: i64,
267
268 #[serde(skip_serializing_if = "Option::is_none")]
269 pub data: Option<String>,
270}
271
272impl SimulateCharacteristicOperationResponseParams { pub const METHOD: &'static str = "BluetoothEmulation.simulateCharacteristicOperationResponse"; }
273
274impl crate::CdpCommand for SimulateCharacteristicOperationResponseParams {
275 const METHOD: &'static str = "BluetoothEmulation.simulateCharacteristicOperationResponse";
276 type Response = crate::EmptyReturns;
277}
278
279#[derive(Debug, Clone, Serialize, Deserialize, Default)]
286#[serde(rename_all = "camelCase")]
287pub struct SimulateDescriptorOperationResponseParams {
288
289 pub descriptorId: String,
290
291 #[serde(rename = "type")]
292 pub type_: DescriptorOperationType,
293
294 pub code: i64,
295
296 #[serde(skip_serializing_if = "Option::is_none")]
297 pub data: Option<String>,
298}
299
300impl SimulateDescriptorOperationResponseParams { pub const METHOD: &'static str = "BluetoothEmulation.simulateDescriptorOperationResponse"; }
301
302impl crate::CdpCommand for SimulateDescriptorOperationResponseParams {
303 const METHOD: &'static str = "BluetoothEmulation.simulateDescriptorOperationResponse";
304 type Response = crate::EmptyReturns;
305}
306
307#[derive(Debug, Clone, Serialize, Deserialize, Default)]
310#[serde(rename_all = "camelCase")]
311pub struct AddServiceParams {
312
313 pub address: String,
314
315 pub serviceUuid: String,
316}
317
318#[derive(Debug, Clone, Serialize, Deserialize, Default)]
321#[serde(rename_all = "camelCase")]
322pub struct AddServiceReturns {
323 pub serviceId: String,
326}
327
328impl AddServiceParams { pub const METHOD: &'static str = "BluetoothEmulation.addService"; }
329
330impl crate::CdpCommand for AddServiceParams {
331 const METHOD: &'static str = "BluetoothEmulation.addService";
332 type Response = AddServiceReturns;
333}
334
335#[derive(Debug, Clone, Serialize, Deserialize, Default)]
338#[serde(rename_all = "camelCase")]
339pub struct RemoveServiceParams {
340
341 pub serviceId: String,
342}
343
344impl RemoveServiceParams { pub const METHOD: &'static str = "BluetoothEmulation.removeService"; }
345
346impl crate::CdpCommand for RemoveServiceParams {
347 const METHOD: &'static str = "BluetoothEmulation.removeService";
348 type Response = crate::EmptyReturns;
349}
350
351#[derive(Debug, Clone, Serialize, Deserialize, Default)]
355#[serde(rename_all = "camelCase")]
356pub struct AddCharacteristicParams {
357
358 pub serviceId: String,
359
360 pub characteristicUuid: String,
361
362 pub properties: CharacteristicProperties,
363}
364
365#[derive(Debug, Clone, Serialize, Deserialize, Default)]
369#[serde(rename_all = "camelCase")]
370pub struct AddCharacteristicReturns {
371 pub characteristicId: String,
374}
375
376impl AddCharacteristicParams { pub const METHOD: &'static str = "BluetoothEmulation.addCharacteristic"; }
377
378impl crate::CdpCommand for AddCharacteristicParams {
379 const METHOD: &'static str = "BluetoothEmulation.addCharacteristic";
380 type Response = AddCharacteristicReturns;
381}
382
383#[derive(Debug, Clone, Serialize, Deserialize, Default)]
387#[serde(rename_all = "camelCase")]
388pub struct RemoveCharacteristicParams {
389
390 pub characteristicId: String,
391}
392
393impl RemoveCharacteristicParams { pub const METHOD: &'static str = "BluetoothEmulation.removeCharacteristic"; }
394
395impl crate::CdpCommand for RemoveCharacteristicParams {
396 const METHOD: &'static str = "BluetoothEmulation.removeCharacteristic";
397 type Response = crate::EmptyReturns;
398}
399
400#[derive(Debug, Clone, Serialize, Deserialize, Default)]
404#[serde(rename_all = "camelCase")]
405pub struct AddDescriptorParams {
406
407 pub characteristicId: String,
408
409 pub descriptorUuid: String,
410}
411
412#[derive(Debug, Clone, Serialize, Deserialize, Default)]
416#[serde(rename_all = "camelCase")]
417pub struct AddDescriptorReturns {
418 pub descriptorId: String,
421}
422
423impl AddDescriptorParams { pub const METHOD: &'static str = "BluetoothEmulation.addDescriptor"; }
424
425impl crate::CdpCommand for AddDescriptorParams {
426 const METHOD: &'static str = "BluetoothEmulation.addDescriptor";
427 type Response = AddDescriptorReturns;
428}
429
430#[derive(Debug, Clone, Serialize, Deserialize, Default)]
433#[serde(rename_all = "camelCase")]
434pub struct RemoveDescriptorParams {
435
436 pub descriptorId: String,
437}
438
439impl RemoveDescriptorParams { pub const METHOD: &'static str = "BluetoothEmulation.removeDescriptor"; }
440
441impl crate::CdpCommand for RemoveDescriptorParams {
442 const METHOD: &'static str = "BluetoothEmulation.removeDescriptor";
443 type Response = crate::EmptyReturns;
444}
445
446#[derive(Debug, Clone, Serialize, Deserialize, Default)]
449#[serde(rename_all = "camelCase")]
450pub struct SimulateGATTDisconnectionParams {
451
452 pub address: String,
453}
454
455impl SimulateGATTDisconnectionParams { pub const METHOD: &'static str = "BluetoothEmulation.simulateGATTDisconnection"; }
456
457impl crate::CdpCommand for SimulateGATTDisconnectionParams {
458 const METHOD: &'static str = "BluetoothEmulation.simulateGATTDisconnection";
459 type Response = crate::EmptyReturns;
460}