zmk_studio_api/transport/
mod.rs1#[cfg(feature = "ble")]
2use std::time::Duration;
3
4#[derive(Debug, Clone, PartialEq, Eq)]
6pub struct BleDeviceInfo {
7 pub device_id: String,
8 pub local_name: Option<String>,
9}
10
11impl BleDeviceInfo {
12 pub fn display_name(&self) -> String {
13 match &self.local_name {
14 Some(name) if !name.is_empty() => format!("{} [{}]", name, self.device_id),
15 _ => self.device_id.clone(),
16 }
17 }
18}
19
20#[derive(Debug, Clone, Copy, PartialEq, Eq)]
25pub enum BleDiscoveryMode {
26 Advertising,
28 Connected,
30 Any,
32}
33
34#[cfg(feature = "ble")]
35pub(crate) const ZMK_SERVICE_UUID_STR: &str = "00000000-0196-6107-c967-c5cfb1c2482a";
36#[cfg(feature = "ble")]
37pub(crate) const ZMK_RPC_CHAR_UUID_STR: &str = "00000001-0196-6107-c967-c5cfb1c2482a";
38#[cfg(feature = "ble")]
39pub(crate) const DEFAULT_BLE_READ_TIMEOUT: Duration = Duration::from_secs(5);
40#[cfg(feature = "ble")]
41pub(crate) const DEFAULT_BLE_SETUP_TIMEOUT: Duration = Duration::from_secs(15);
42#[cfg(feature = "ble")]
43pub(crate) const DEFAULT_BLE_WRITE_QUEUE_CAPACITY: usize = 32;
44
45#[cfg(feature = "ble")]
46pub mod ble;
47#[cfg(feature = "ble")]
48mod blocking_ble;
49#[cfg(feature = "serial")]
50pub mod serial;
51
52#[cfg(feature = "ble")]
53pub type PlatformBleTransport = ble::BluestTransport;
54
55#[cfg(feature = "ble")]
56pub type PlatformBleError = ble::BluestTransportError;
57
58#[cfg(feature = "ble")]
59pub fn discover_platform_ble_devices(
60 mode: BleDiscoveryMode,
61) -> Result<Vec<BleDeviceInfo>, PlatformBleError> {
62 ble::discover_devices_with_mode(mode)
63}