@@ -17,7 +17,7 @@ use super::{
17
17
future:: { BtlePlugFuture , BtlePlugFutureStateShared } ,
18
18
utils:: { core_bluetooth:: cbuuid_to_uuid, nsstring:: nsstring_to_string, nsuuid_to_uuid} ,
19
19
} ;
20
- use crate :: api:: { CharPropFlags , Characteristic , Service , WriteType } ;
20
+ use crate :: api:: { CharPropFlags , Characteristic , ScanFilter , Service , WriteType } ;
21
21
use crate :: Error ;
22
22
use futures:: channel:: mpsc:: { self , Receiver , Sender } ;
23
23
use futures:: select;
@@ -258,7 +258,9 @@ impl Debug for CoreBluetoothInternal {
258
258
259
259
#[ derive( Debug ) ]
260
260
pub enum CoreBluetoothMessage {
261
- StartScanning ,
261
+ StartScanning {
262
+ filter : ScanFilter ,
263
+ } ,
262
264
StopScanning ,
263
265
ConnectDevice {
264
266
peripheral_uuid : Uuid ,
@@ -762,7 +764,7 @@ impl CoreBluetoothInternal {
762
764
adapter_msg = self . message_receiver. select_next_some( ) => {
763
765
trace!( "Adapter message!" ) ;
764
766
match adapter_msg {
765
- CoreBluetoothMessage :: StartScanning => self . start_discovery( ) ,
767
+ CoreBluetoothMessage :: StartScanning { filter } => self . start_discovery( filter ) ,
766
768
CoreBluetoothMessage :: StopScanning => self . stop_discovery( ) ,
767
769
CoreBluetoothMessage :: ConnectDevice { peripheral_uuid, future} => {
768
770
trace!( "got connectdevice msg!" ) ;
@@ -793,14 +795,15 @@ impl CoreBluetoothInternal {
793
795
}
794
796
}
795
797
796
- fn start_discovery ( & mut self ) {
798
+ fn start_discovery ( & mut self , _filter : ScanFilter ) {
797
799
trace ! ( "BluetoothAdapter::start_discovery" ) ;
798
800
let options = ns:: mutabledictionary ( ) ;
799
801
// NOTE: If duplicates are not allowed then a peripheral will not show
800
802
// up again once connected and then disconnected.
801
803
ns:: mutabledictionary_setobject_forkey ( options, ns:: number_withbool ( YES ) , unsafe {
802
804
cb:: CENTRALMANAGERSCANOPTIONALLOWDUPLICATESKEY
803
805
} ) ;
806
+ // TODO: set cb::CBCENTRALMANAGERSCANOPTIONSOLICITEDSERVICEUUIDSKEY with filter.services
804
807
cb:: centralmanager_scanforperipherals_options ( * self . manager , options) ;
805
808
}
806
809
0 commit comments