Skip to main content

cdp_protocol/
bluetooth_emulation.rs

1// Auto-generated from Chrome at version 146.0.7680.165 domain: BluetoothEmulation
2#![allow(dead_code)]
3#[allow(unused_imports)]
4use super::types::*;
5#[allow(unused_imports)]
6use derive_builder::Builder;
7#[allow(unused_imports)]
8use serde::{Deserialize, Serialize};
9#[allow(unused_imports)]
10use serde_json::Value as Json;
11#[allow(deprecated)]
12#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
13pub enum CentralState {
14    #[serde(rename = "absent")]
15    Absent,
16    #[serde(rename = "powered-off")]
17    PoweredOff,
18    #[serde(rename = "powered-on")]
19    PoweredOn,
20}
21#[allow(deprecated)]
22#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
23pub enum GattOperationType {
24    #[serde(rename = "connection")]
25    Connection,
26    #[serde(rename = "discovery")]
27    Discovery,
28}
29#[allow(deprecated)]
30#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
31pub enum CharacteristicWriteType {
32    #[serde(rename = "write-default-deprecated")]
33    WriteDefaultDeprecated,
34    #[serde(rename = "write-with-response")]
35    WriteWithResponse,
36    #[serde(rename = "write-without-response")]
37    WriteWithoutResponse,
38}
39#[allow(deprecated)]
40#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
41pub enum CharacteristicOperationType {
42    #[serde(rename = "read")]
43    Read,
44    #[serde(rename = "write")]
45    Write,
46    #[serde(rename = "subscribe-to-notifications")]
47    SubscribeToNotifications,
48    #[serde(rename = "unsubscribe-from-notifications")]
49    UnsubscribeFromNotifications,
50}
51#[allow(deprecated)]
52#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
53pub enum DescriptorOperationType {
54    #[serde(rename = "read")]
55    Read,
56    #[serde(rename = "write")]
57    Write,
58}
59#[allow(deprecated)]
60#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
61#[builder(setter(into, strip_option))]
62#[serde(rename_all = "camelCase")]
63#[doc = "Stores the manufacturer data"]
64pub struct ManufacturerData {
65    #[serde(default)]
66    #[doc = "Company identifier\n <https://bitbucket.org/bluetooth-SIG/public/src/main/assigned_numbers/company_identifiers/company_identifiers.yaml>\n <https://usb.org/developers>"]
67    pub key: JsUInt,
68    #[doc = "Manufacturer-specific data"]
69    pub data: String,
70}
71#[allow(deprecated)]
72#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
73#[builder(setter(into, strip_option))]
74#[serde(rename_all = "camelCase")]
75#[doc = "Stores the byte data of the advertisement packet sent by a Bluetooth device."]
76pub struct ScanRecord {
77    #[builder(default)]
78    #[serde(skip_serializing_if = "Option::is_none")]
79    #[serde(default)]
80    pub name: Option<String>,
81    #[builder(default)]
82    #[serde(skip_serializing_if = "Option::is_none")]
83    #[serde(default)]
84    pub uuids: Option<Vec<String>>,
85    #[builder(default)]
86    #[serde(skip_serializing_if = "Option::is_none")]
87    #[serde(default)]
88    #[doc = "Stores the external appearance description of the device."]
89    pub appearance: Option<JsUInt>,
90    #[builder(default)]
91    #[serde(skip_serializing_if = "Option::is_none")]
92    #[serde(default)]
93    #[doc = "Stores the transmission power of a broadcasting device."]
94    pub tx_power: Option<JsUInt>,
95    #[builder(default)]
96    #[serde(skip_serializing_if = "Option::is_none")]
97    #[doc = "Key is the company identifier and the value is an array of bytes of\n manufacturer specific data."]
98    pub manufacturer_data: Option<Vec<ManufacturerData>>,
99}
100#[allow(deprecated)]
101#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
102#[builder(setter(into, strip_option))]
103#[serde(rename_all = "camelCase")]
104#[doc = "Stores the advertisement packet information that is sent by a Bluetooth device."]
105pub struct ScanEntry {
106    #[serde(default)]
107    pub device_address: String,
108    #[serde(default)]
109    pub rssi: JsUInt,
110    pub scan_record: ScanRecord,
111}
112#[allow(deprecated)]
113#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
114#[builder(setter(into, strip_option))]
115#[serde(rename_all = "camelCase")]
116#[doc = "Describes the properties of a characteristic. This follows Bluetooth Core\n Specification BT 4.2 Vol 3 Part G 3.3.1. Characteristic Properties."]
117pub struct CharacteristicProperties {
118    #[builder(default)]
119    #[serde(skip_serializing_if = "Option::is_none")]
120    #[serde(default)]
121    pub broadcast: Option<bool>,
122    #[builder(default)]
123    #[serde(skip_serializing_if = "Option::is_none")]
124    #[serde(default)]
125    pub read: Option<bool>,
126    #[builder(default)]
127    #[serde(skip_serializing_if = "Option::is_none")]
128    #[serde(default)]
129    pub write_without_response: Option<bool>,
130    #[builder(default)]
131    #[serde(skip_serializing_if = "Option::is_none")]
132    #[serde(default)]
133    pub write: Option<bool>,
134    #[builder(default)]
135    #[serde(skip_serializing_if = "Option::is_none")]
136    #[serde(default)]
137    pub notify: Option<bool>,
138    #[builder(default)]
139    #[serde(skip_serializing_if = "Option::is_none")]
140    #[serde(default)]
141    pub indicate: Option<bool>,
142    #[builder(default)]
143    #[serde(skip_serializing_if = "Option::is_none")]
144    #[serde(default)]
145    pub authenticated_signed_writes: Option<bool>,
146    #[builder(default)]
147    #[serde(skip_serializing_if = "Option::is_none")]
148    #[serde(default)]
149    pub extended_properties: Option<bool>,
150}
151#[allow(deprecated)]
152#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
153#[builder(setter(into, strip_option))]
154#[serde(rename_all = "camelCase")]
155#[doc = "Enable the BluetoothEmulation domain."]
156pub struct Enable {
157    #[doc = "State of the simulated central."]
158    pub state: CentralState,
159    #[serde(default)]
160    #[doc = "If the simulated central supports low-energy."]
161    pub le_supported: bool,
162}
163#[allow(deprecated)]
164#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
165#[builder(setter(into, strip_option))]
166#[serde(rename_all = "camelCase")]
167#[doc = "Set the state of the simulated central."]
168pub struct SetSimulatedCentralState {
169    #[doc = "State of the simulated central."]
170    pub state: CentralState,
171}
172#[allow(deprecated)]
173#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
174pub struct Disable(pub Option<Json>);
175#[allow(deprecated)]
176#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
177#[builder(setter(into, strip_option))]
178#[serde(rename_all = "camelCase")]
179#[doc = "Simulates a peripheral with |address|, |name| and |knownServiceUuids|\n that has already been connected to the system."]
180pub struct SimulatePreconnectedPeripheral {
181    #[serde(default)]
182    pub address: String,
183    #[serde(default)]
184    pub name: String,
185    pub manufacturer_data: Vec<ManufacturerData>,
186    #[serde(default)]
187    pub known_service_uuids: Vec<String>,
188}
189#[allow(deprecated)]
190#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
191#[builder(setter(into, strip_option))]
192#[serde(rename_all = "camelCase")]
193#[doc = "Simulates an advertisement packet described in |entry| being received by\n the central."]
194pub struct SimulateAdvertisement {
195    pub entry: ScanEntry,
196}
197#[allow(deprecated)]
198#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
199#[builder(setter(into, strip_option))]
200#[serde(rename_all = "camelCase")]
201#[doc = "Simulates the response code from the peripheral with |address| for a\n GATT operation of |type|. The |code| value follows the HCI Error Codes from\n Bluetooth Core Specification Vol 2 Part D 1.3 List Of Error Codes."]
202pub struct SimulateGATTOperationResponse {
203    #[serde(default)]
204    pub address: String,
205    pub r#type: GattOperationType,
206    #[serde(default)]
207    pub code: JsUInt,
208}
209#[allow(deprecated)]
210#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
211#[builder(setter(into, strip_option))]
212#[serde(rename_all = "camelCase")]
213#[doc = "Simulates the response from the characteristic with |characteristicId| for a\n characteristic operation of |type|. The |code| value follows the Error\n Codes from Bluetooth Core Specification Vol 3 Part F 3.4.1.1 Error Response.\n The |data| is expected to exist when simulating a successful read operation\n response."]
214pub struct SimulateCharacteristicOperationResponse {
215    #[serde(default)]
216    pub characteristic_id: String,
217    pub r#type: CharacteristicOperationType,
218    #[serde(default)]
219    pub code: JsUInt,
220    #[builder(default)]
221    #[serde(skip_serializing_if = "Option::is_none")]
222    pub data: Option<Vec<u8>>,
223}
224#[allow(deprecated)]
225#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
226#[builder(setter(into, strip_option))]
227#[serde(rename_all = "camelCase")]
228#[doc = "Simulates the response from the descriptor with |descriptorId| for a\n descriptor operation of |type|. The |code| value follows the Error\n Codes from Bluetooth Core Specification Vol 3 Part F 3.4.1.1 Error Response.\n The |data| is expected to exist when simulating a successful read operation\n response."]
229pub struct SimulateDescriptorOperationResponse {
230    #[serde(default)]
231    pub descriptor_id: String,
232    pub r#type: DescriptorOperationType,
233    #[serde(default)]
234    pub code: JsUInt,
235    #[builder(default)]
236    #[serde(skip_serializing_if = "Option::is_none")]
237    pub data: Option<Vec<u8>>,
238}
239#[allow(deprecated)]
240#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
241#[builder(setter(into, strip_option))]
242#[serde(rename_all = "camelCase")]
243#[doc = "Adds a service with |serviceUuid| to the peripheral with |address|."]
244pub struct AddService {
245    #[serde(default)]
246    pub address: String,
247    #[serde(default)]
248    pub service_uuid: String,
249}
250#[allow(deprecated)]
251#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
252#[builder(setter(into, strip_option))]
253#[serde(rename_all = "camelCase")]
254#[doc = "Removes the service respresented by |serviceId| from the simulated central."]
255pub struct RemoveService {
256    #[serde(default)]
257    pub service_id: String,
258}
259#[allow(deprecated)]
260#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
261#[builder(setter(into, strip_option))]
262#[serde(rename_all = "camelCase")]
263#[doc = "Adds a characteristic with |characteristicUuid| and |properties| to the\n service represented by |serviceId|."]
264pub struct AddCharacteristic {
265    #[serde(default)]
266    pub service_id: String,
267    #[serde(default)]
268    pub characteristic_uuid: String,
269    pub properties: CharacteristicProperties,
270}
271#[allow(deprecated)]
272#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
273#[builder(setter(into, strip_option))]
274#[serde(rename_all = "camelCase")]
275#[doc = "Removes the characteristic respresented by |characteristicId| from the\n simulated central."]
276pub struct RemoveCharacteristic {
277    #[serde(default)]
278    pub characteristic_id: String,
279}
280#[allow(deprecated)]
281#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
282#[builder(setter(into, strip_option))]
283#[serde(rename_all = "camelCase")]
284#[doc = "Adds a descriptor with |descriptorUuid| to the characteristic respresented\n by |characteristicId|."]
285pub struct AddDescriptor {
286    #[serde(default)]
287    pub characteristic_id: String,
288    #[serde(default)]
289    pub descriptor_uuid: String,
290}
291#[allow(deprecated)]
292#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
293#[builder(setter(into, strip_option))]
294#[serde(rename_all = "camelCase")]
295#[doc = "Removes the descriptor with |descriptorId| from the simulated central."]
296pub struct RemoveDescriptor {
297    #[serde(default)]
298    pub descriptor_id: String,
299}
300#[allow(deprecated)]
301#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
302#[builder(setter(into, strip_option))]
303#[serde(rename_all = "camelCase")]
304#[doc = "Simulates a GATT disconnection from the peripheral with |address|."]
305pub struct SimulateGATTDisconnection {
306    #[serde(default)]
307    pub address: String,
308}
309#[allow(deprecated)]
310#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
311#[doc = "Enable the BluetoothEmulation domain."]
312pub struct EnableReturnObject(pub Option<Json>);
313#[allow(deprecated)]
314#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
315#[doc = "Set the state of the simulated central."]
316pub struct SetSimulatedCentralStateReturnObject(pub Option<Json>);
317#[allow(deprecated)]
318#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
319#[doc = "Disable the BluetoothEmulation domain."]
320pub struct DisableReturnObject(pub Option<Json>);
321#[allow(deprecated)]
322#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
323#[doc = "Simulates a peripheral with |address|, |name| and |knownServiceUuids|\n that has already been connected to the system."]
324pub struct SimulatePreconnectedPeripheralReturnObject(pub Option<Json>);
325#[allow(deprecated)]
326#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
327#[doc = "Simulates an advertisement packet described in |entry| being received by\n the central."]
328pub struct SimulateAdvertisementReturnObject(pub Option<Json>);
329#[allow(deprecated)]
330#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
331#[doc = "Simulates the response code from the peripheral with |address| for a\n GATT operation of |type|. The |code| value follows the HCI Error Codes from\n Bluetooth Core Specification Vol 2 Part D 1.3 List Of Error Codes."]
332pub struct SimulateGATTOperationResponseReturnObject(pub Option<Json>);
333#[allow(deprecated)]
334#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
335#[doc = "Simulates the response from the characteristic with |characteristicId| for a\n characteristic operation of |type|. The |code| value follows the Error\n Codes from Bluetooth Core Specification Vol 3 Part F 3.4.1.1 Error Response.\n The |data| is expected to exist when simulating a successful read operation\n response."]
336pub struct SimulateCharacteristicOperationResponseReturnObject(pub Option<Json>);
337#[allow(deprecated)]
338#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
339#[doc = "Simulates the response from the descriptor with |descriptorId| for a\n descriptor operation of |type|. The |code| value follows the Error\n Codes from Bluetooth Core Specification Vol 3 Part F 3.4.1.1 Error Response.\n The |data| is expected to exist when simulating a successful read operation\n response."]
340pub struct SimulateDescriptorOperationResponseReturnObject(pub Option<Json>);
341#[allow(deprecated)]
342#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
343#[serde(rename_all = "camelCase")]
344#[doc = "Adds a service with |serviceUuid| to the peripheral with |address|."]
345pub struct AddServiceReturnObject {
346    #[serde(default)]
347    #[doc = "An identifier that uniquely represents this service."]
348    pub service_id: String,
349}
350#[allow(deprecated)]
351#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
352#[doc = "Removes the service respresented by |serviceId| from the simulated central."]
353pub struct RemoveServiceReturnObject(pub Option<Json>);
354#[allow(deprecated)]
355#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
356#[serde(rename_all = "camelCase")]
357#[doc = "Adds a characteristic with |characteristicUuid| and |properties| to the\n service represented by |serviceId|."]
358pub struct AddCharacteristicReturnObject {
359    #[serde(default)]
360    #[doc = "An identifier that uniquely represents this characteristic."]
361    pub characteristic_id: String,
362}
363#[allow(deprecated)]
364#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
365#[doc = "Removes the characteristic respresented by |characteristicId| from the\n simulated central."]
366pub struct RemoveCharacteristicReturnObject(pub Option<Json>);
367#[allow(deprecated)]
368#[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
369#[serde(rename_all = "camelCase")]
370#[doc = "Adds a descriptor with |descriptorUuid| to the characteristic respresented\n by |characteristicId|."]
371pub struct AddDescriptorReturnObject {
372    #[serde(default)]
373    #[doc = "An identifier that uniquely represents this descriptor."]
374    pub descriptor_id: String,
375}
376#[allow(deprecated)]
377#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
378#[doc = "Removes the descriptor with |descriptorId| from the simulated central."]
379pub struct RemoveDescriptorReturnObject(pub Option<Json>);
380#[allow(deprecated)]
381#[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
382#[doc = "Simulates a GATT disconnection from the peripheral with |address|."]
383pub struct SimulateGATTDisconnectionReturnObject(pub Option<Json>);
384#[allow(deprecated)]
385impl Method for Enable {
386    const NAME: &'static str = "BluetoothEmulation.enable";
387    type ReturnObject = EnableReturnObject;
388}
389#[allow(deprecated)]
390impl Method for SetSimulatedCentralState {
391    const NAME: &'static str = "BluetoothEmulation.setSimulatedCentralState";
392    type ReturnObject = SetSimulatedCentralStateReturnObject;
393}
394#[allow(deprecated)]
395impl Method for Disable {
396    const NAME: &'static str = "BluetoothEmulation.disable";
397    type ReturnObject = DisableReturnObject;
398}
399#[allow(deprecated)]
400impl Method for SimulatePreconnectedPeripheral {
401    const NAME: &'static str = "BluetoothEmulation.simulatePreconnectedPeripheral";
402    type ReturnObject = SimulatePreconnectedPeripheralReturnObject;
403}
404#[allow(deprecated)]
405impl Method for SimulateAdvertisement {
406    const NAME: &'static str = "BluetoothEmulation.simulateAdvertisement";
407    type ReturnObject = SimulateAdvertisementReturnObject;
408}
409#[allow(deprecated)]
410impl Method for SimulateGATTOperationResponse {
411    const NAME: &'static str = "BluetoothEmulation.simulateGATTOperationResponse";
412    type ReturnObject = SimulateGATTOperationResponseReturnObject;
413}
414#[allow(deprecated)]
415impl Method for SimulateCharacteristicOperationResponse {
416    const NAME: &'static str = "BluetoothEmulation.simulateCharacteristicOperationResponse";
417    type ReturnObject = SimulateCharacteristicOperationResponseReturnObject;
418}
419#[allow(deprecated)]
420impl Method for SimulateDescriptorOperationResponse {
421    const NAME: &'static str = "BluetoothEmulation.simulateDescriptorOperationResponse";
422    type ReturnObject = SimulateDescriptorOperationResponseReturnObject;
423}
424#[allow(deprecated)]
425impl Method for AddService {
426    const NAME: &'static str = "BluetoothEmulation.addService";
427    type ReturnObject = AddServiceReturnObject;
428}
429#[allow(deprecated)]
430impl Method for RemoveService {
431    const NAME: &'static str = "BluetoothEmulation.removeService";
432    type ReturnObject = RemoveServiceReturnObject;
433}
434#[allow(deprecated)]
435impl Method for AddCharacteristic {
436    const NAME: &'static str = "BluetoothEmulation.addCharacteristic";
437    type ReturnObject = AddCharacteristicReturnObject;
438}
439#[allow(deprecated)]
440impl Method for RemoveCharacteristic {
441    const NAME: &'static str = "BluetoothEmulation.removeCharacteristic";
442    type ReturnObject = RemoveCharacteristicReturnObject;
443}
444#[allow(deprecated)]
445impl Method for AddDescriptor {
446    const NAME: &'static str = "BluetoothEmulation.addDescriptor";
447    type ReturnObject = AddDescriptorReturnObject;
448}
449#[allow(deprecated)]
450impl Method for RemoveDescriptor {
451    const NAME: &'static str = "BluetoothEmulation.removeDescriptor";
452    type ReturnObject = RemoveDescriptorReturnObject;
453}
454#[allow(deprecated)]
455impl Method for SimulateGATTDisconnection {
456    const NAME: &'static str = "BluetoothEmulation.simulateGATTDisconnection";
457    type ReturnObject = SimulateGATTDisconnectionReturnObject;
458}
459#[allow(dead_code)]
460pub mod events {
461    #[allow(unused_imports)]
462    use super::super::types::*;
463    #[allow(unused_imports)]
464    use derive_builder::Builder;
465    #[allow(unused_imports)]
466    use serde::{Deserialize, Serialize};
467    #[allow(unused_imports)]
468    use serde_json::Value as Json;
469    #[allow(deprecated)]
470    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
471    pub struct GattOperationReceivedEvent {
472        pub params: GattOperationReceivedEventParams,
473    }
474    #[allow(deprecated)]
475    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
476    #[serde(rename_all = "camelCase")]
477    pub struct GattOperationReceivedEventParams {
478        #[serde(default)]
479        pub address: String,
480        pub r#type: super::GattOperationType,
481    }
482    #[allow(deprecated)]
483    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
484    pub struct CharacteristicOperationReceivedEvent {
485        pub params: CharacteristicOperationReceivedEventParams,
486    }
487    #[allow(deprecated)]
488    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
489    #[serde(rename_all = "camelCase")]
490    pub struct CharacteristicOperationReceivedEventParams {
491        #[serde(default)]
492        pub characteristic_id: String,
493        pub r#type: super::CharacteristicOperationType,
494        #[builder(default)]
495        #[serde(skip_serializing_if = "Option::is_none")]
496        #[serde(default)]
497        pub data: Option<String>,
498        #[builder(default)]
499        #[serde(skip_serializing_if = "Option::is_none")]
500        pub write_type: Option<super::CharacteristicWriteType>,
501    }
502    #[allow(deprecated)]
503    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq)]
504    pub struct DescriptorOperationReceivedEvent {
505        pub params: DescriptorOperationReceivedEventParams,
506    }
507    #[allow(deprecated)]
508    #[derive(Deserialize, Serialize, Debug, Clone, PartialEq, Builder)]
509    #[serde(rename_all = "camelCase")]
510    pub struct DescriptorOperationReceivedEventParams {
511        #[serde(default)]
512        pub descriptor_id: String,
513        pub r#type: super::DescriptorOperationType,
514        #[builder(default)]
515        #[serde(skip_serializing_if = "Option::is_none")]
516        #[serde(default)]
517        pub data: Option<String>,
518    }
519}