use serde::{Serialize, Deserialize};
use serde_json::Value as JsonValue;
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum CentralState {
#[default]
Absent,
PoweredOff,
PoweredOn,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum GATTOperationType {
#[default]
Connection,
Discovery,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum CharacteristicWriteType {
#[default]
WriteDefaultDeprecated,
WriteWithResponse,
WriteWithoutResponse,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum CharacteristicOperationType {
#[default]
Read,
Write,
SubscribeToNotifications,
UnsubscribeFromNotifications,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
pub enum DescriptorOperationType {
#[default]
Read,
Write,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ManufacturerData {
pub key: i64,
pub data: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ScanRecord {
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub uuids: Option<Vec<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub appearance: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub txPower: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub manufacturerData: Option<Vec<ManufacturerData>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct ScanEntry {
pub deviceAddress: String,
pub rssi: i64,
pub scanRecord: ScanRecord,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct CharacteristicProperties {
#[serde(skip_serializing_if = "Option::is_none")]
pub broadcast: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub read: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub writeWithoutResponse: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub write: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub notify: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub indicate: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub authenticatedSignedWrites: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub extendedProperties: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct EnableParams {
pub state: CentralState,
pub leSupported: bool,
}
impl EnableParams { pub const METHOD: &'static str = "BluetoothEmulation.enable"; }
impl crate::CdpCommand for EnableParams {
const METHOD: &'static str = "BluetoothEmulation.enable";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SetSimulatedCentralStateParams {
pub state: CentralState,
}
impl SetSimulatedCentralStateParams { pub const METHOD: &'static str = "BluetoothEmulation.setSimulatedCentralState"; }
impl crate::CdpCommand for SetSimulatedCentralStateParams {
const METHOD: &'static str = "BluetoothEmulation.setSimulatedCentralState";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub struct DisableParams {}
impl DisableParams { pub const METHOD: &'static str = "BluetoothEmulation.disable"; }
impl crate::CdpCommand for DisableParams {
const METHOD: &'static str = "BluetoothEmulation.disable";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SimulatePreconnectedPeripheralParams {
pub address: String,
pub name: String,
pub manufacturerData: Vec<ManufacturerData>,
pub knownServiceUuids: Vec<String>,
}
impl SimulatePreconnectedPeripheralParams { pub const METHOD: &'static str = "BluetoothEmulation.simulatePreconnectedPeripheral"; }
impl crate::CdpCommand for SimulatePreconnectedPeripheralParams {
const METHOD: &'static str = "BluetoothEmulation.simulatePreconnectedPeripheral";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SimulateAdvertisementParams {
pub entry: ScanEntry,
}
impl SimulateAdvertisementParams { pub const METHOD: &'static str = "BluetoothEmulation.simulateAdvertisement"; }
impl crate::CdpCommand for SimulateAdvertisementParams {
const METHOD: &'static str = "BluetoothEmulation.simulateAdvertisement";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SimulateGATTOperationResponseParams {
pub address: String,
#[serde(rename = "type")]
pub type_: GATTOperationType,
pub code: i64,
}
impl SimulateGATTOperationResponseParams { pub const METHOD: &'static str = "BluetoothEmulation.simulateGATTOperationResponse"; }
impl crate::CdpCommand for SimulateGATTOperationResponseParams {
const METHOD: &'static str = "BluetoothEmulation.simulateGATTOperationResponse";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SimulateCharacteristicOperationResponseParams {
pub characteristicId: String,
#[serde(rename = "type")]
pub type_: CharacteristicOperationType,
pub code: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<String>,
}
impl SimulateCharacteristicOperationResponseParams { pub const METHOD: &'static str = "BluetoothEmulation.simulateCharacteristicOperationResponse"; }
impl crate::CdpCommand for SimulateCharacteristicOperationResponseParams {
const METHOD: &'static str = "BluetoothEmulation.simulateCharacteristicOperationResponse";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SimulateDescriptorOperationResponseParams {
pub descriptorId: String,
#[serde(rename = "type")]
pub type_: DescriptorOperationType,
pub code: i64,
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<String>,
}
impl SimulateDescriptorOperationResponseParams { pub const METHOD: &'static str = "BluetoothEmulation.simulateDescriptorOperationResponse"; }
impl crate::CdpCommand for SimulateDescriptorOperationResponseParams {
const METHOD: &'static str = "BluetoothEmulation.simulateDescriptorOperationResponse";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AddServiceParams {
pub address: String,
pub serviceUuid: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AddServiceReturns {
pub serviceId: String,
}
impl AddServiceParams { pub const METHOD: &'static str = "BluetoothEmulation.addService"; }
impl crate::CdpCommand for AddServiceParams {
const METHOD: &'static str = "BluetoothEmulation.addService";
type Response = AddServiceReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RemoveServiceParams {
pub serviceId: String,
}
impl RemoveServiceParams { pub const METHOD: &'static str = "BluetoothEmulation.removeService"; }
impl crate::CdpCommand for RemoveServiceParams {
const METHOD: &'static str = "BluetoothEmulation.removeService";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AddCharacteristicParams {
pub serviceId: String,
pub characteristicUuid: String,
pub properties: CharacteristicProperties,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AddCharacteristicReturns {
pub characteristicId: String,
}
impl AddCharacteristicParams { pub const METHOD: &'static str = "BluetoothEmulation.addCharacteristic"; }
impl crate::CdpCommand for AddCharacteristicParams {
const METHOD: &'static str = "BluetoothEmulation.addCharacteristic";
type Response = AddCharacteristicReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RemoveCharacteristicParams {
pub characteristicId: String,
}
impl RemoveCharacteristicParams { pub const METHOD: &'static str = "BluetoothEmulation.removeCharacteristic"; }
impl crate::CdpCommand for RemoveCharacteristicParams {
const METHOD: &'static str = "BluetoothEmulation.removeCharacteristic";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AddDescriptorParams {
pub characteristicId: String,
pub descriptorUuid: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct AddDescriptorReturns {
pub descriptorId: String,
}
impl AddDescriptorParams { pub const METHOD: &'static str = "BluetoothEmulation.addDescriptor"; }
impl crate::CdpCommand for AddDescriptorParams {
const METHOD: &'static str = "BluetoothEmulation.addDescriptor";
type Response = AddDescriptorReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct RemoveDescriptorParams {
pub descriptorId: String,
}
impl RemoveDescriptorParams { pub const METHOD: &'static str = "BluetoothEmulation.removeDescriptor"; }
impl crate::CdpCommand for RemoveDescriptorParams {
const METHOD: &'static str = "BluetoothEmulation.removeDescriptor";
type Response = crate::EmptyReturns;
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
#[serde(rename_all = "camelCase")]
pub struct SimulateGATTDisconnectionParams {
pub address: String,
}
impl SimulateGATTDisconnectionParams { pub const METHOD: &'static str = "BluetoothEmulation.simulateGATTDisconnection"; }
impl crate::CdpCommand for SimulateGATTDisconnectionParams {
const METHOD: &'static str = "BluetoothEmulation.simulateGATTDisconnection";
type Response = crate::EmptyReturns;
}