• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 use btstack::bluetooth_gatt::{
2     IBluetoothGatt, IScannerCallback, RSSISettings, ScanFilter, ScanSettings, ScanType,
3 };
4 use btstack::RPCProxy;
5 
6 use dbus::arg::RefArg;
7 
8 use dbus::nonblock::SyncConnection;
9 use dbus::strings::{BusName, Path};
10 
11 use dbus_macros::{dbus_method, dbus_propmap, dbus_proxy_obj, generate_dbus_exporter};
12 
13 use dbus_projection::impl_dbus_arg_enum;
14 use dbus_projection::DisconnectWatcher;
15 
16 use num_traits::cast::{FromPrimitive, ToPrimitive};
17 
18 use std::collections::HashMap;
19 use std::error::Error;
20 use std::sync::{Arc, Mutex};
21 
22 use crate::dbus_arg::{DBusArg, DBusArgError};
23 
24 #[allow(dead_code)]
25 struct ScannerCallbackDBus {}
26 
27 #[dbus_proxy_obj(ScannerCallback, "org.chromium.bluetooth.ScannerCallback")]
28 impl IScannerCallback for ScannerCallbackDBus {
29     #[dbus_method("OnScannerRegistered")]
on_scanner_registered(&self, _status: i32, _scanner_id: i32)30     fn on_scanner_registered(&self, _status: i32, _scanner_id: i32) {}
31 }
32 
33 #[dbus_propmap(RSSISettings)]
34 pub struct RSSISettingsDBus {
35     low_threshold: i32,
36     high_threshold: i32,
37 }
38 
39 #[dbus_propmap(ScanSettings)]
40 struct ScanSettingsDBus {
41     interval: i32,
42 
43     window: i32,
44 
45     #[dbus_propmap_field_enum]
46     scan_type: ScanType,
47 
48     #[dbus_propmap_field_propmap]
49     rssi_settings: RSSISettings,
50 }
51 
52 impl_dbus_arg_enum!(ScanType);
53 
54 #[dbus_propmap(ScanFilter)]
55 struct ScanFilterDBus {}
56 
57 #[allow(dead_code)]
58 struct IBluetoothGattDBus {}
59 
60 #[generate_dbus_exporter(export_bluetooth_gatt_dbus_obj, "org.chromium.bluetooth.BluetoothGatt")]
61 impl IBluetoothGatt for IBluetoothGattDBus {
62     #[dbus_method("RegisterScanner")]
register_scanner(&self, callback: Box<dyn IScannerCallback + Send>)63     fn register_scanner(&self, callback: Box<dyn IScannerCallback + Send>) {}
64 
65     #[dbus_method("UnregisterScanner")]
unregister_scanner(&self, scanner_id: i32)66     fn unregister_scanner(&self, scanner_id: i32) {}
67 
68     #[dbus_method("StartScan")]
start_scan(&self, scanner_id: i32, settings: ScanSettings, filters: Vec<ScanFilter>)69     fn start_scan(&self, scanner_id: i32, settings: ScanSettings, filters: Vec<ScanFilter>) {}
70 
71     #[dbus_method("StopScan")]
stop_scan(&self, scanner_id: i32)72     fn stop_scan(&self, scanner_id: i32) {}
73 }
74