@@ -174,11 +174,16 @@ pub enum WriteType {
174174 WithoutResponse ,
175175}
176176
177+ pub type PeripheralId = BDAddr ;
178+
177179/// Peripheral is the device that you would like to communicate with (the "server" of BLE). This
178180/// struct contains both the current state of the device (its properties, characteristics, etc.)
179181/// as well as functions for communication.
180182#[ async_trait]
181183pub trait Peripheral : Send + Sync + Clone + Debug {
184+ /// Returns the MAC address of the peripheral.
185+ fn id ( & self ) -> PeripheralId ;
186+
182187 /// Returns the MAC address of the peripheral.
183188 fn address ( & self ) -> BDAddr ;
184189
@@ -236,23 +241,23 @@ pub trait Peripheral: Send + Sync + Clone + Debug {
236241) ]
237242#[ derive( Debug , Clone ) ]
238243pub enum CentralEvent {
239- DeviceDiscovered ( BDAddr ) ,
240- DeviceUpdated ( BDAddr ) ,
241- DeviceConnected ( BDAddr ) ,
242- DeviceDisconnected ( BDAddr ) ,
244+ DeviceDiscovered ( PeripheralId ) ,
245+ DeviceUpdated ( PeripheralId ) ,
246+ DeviceConnected ( PeripheralId ) ,
247+ DeviceDisconnected ( PeripheralId ) ,
243248 /// Emitted when a Manufacturer Data advertisement has been received from a device
244249 ManufacturerDataAdvertisement {
245- address : BDAddr ,
250+ address : PeripheralId ,
246251 manufacturer_data : HashMap < u16 , Vec < u8 > > ,
247252 } ,
248253 /// Emitted when a Service Data advertisement has been received from a device
249254 ServiceDataAdvertisement {
250- address : BDAddr ,
255+ address : PeripheralId ,
251256 service_data : HashMap < Uuid , Vec < u8 > > ,
252257 } ,
253258 /// Emitted when the advertised services for a device has been updated
254259 ServicesAdvertisement {
255- address : BDAddr ,
260+ address : PeripheralId ,
256261 services : Vec < Uuid > ,
257262 } ,
258263}
@@ -280,7 +285,7 @@ pub trait Central: Send + Sync + Clone {
280285 async fn peripherals ( & self ) -> Result < Vec < Self :: Peripheral > > ;
281286
282287 /// Returns a particular [`Peripheral`] by its address if it has been discovered.
283- async fn peripheral ( & self , address : BDAddr ) -> Result < Self :: Peripheral > ;
288+ async fn peripheral ( & self , address : PeripheralId ) -> Result < Self :: Peripheral > ;
284289
285290 /// Add a [`Peripheral`] from a MAC address without a scan result. Not supported on all Bluetooth systems.
286291 async fn add_peripheral ( & self , address : BDAddr ) -> Result < Self :: Peripheral > ;
0 commit comments