@@ -2,8 +2,8 @@ use anyhow::Result;
22use btleplug:: api:: { Central , Manager as _, Peripheral , ScanFilter } ;
33use btleplug:: platform:: Manager ;
44
5- const FKM_UUID : uuid:: Uuid = uuid:: Uuid :: from_u128 ( 0xf254a578_ef88_4372_b5f5_5ecf87e65884 ) ;
6- const SET_WIFI_UUID : uuid:: Uuid = uuid:: Uuid :: from_u128 ( 0xbcd7e573_b0b2_4775_83c0_acbf3aaf210c ) ;
5+ // const FKM_UUID: uuid::Uuid = uuid::uuid!("f254a578-ef88-4372-b5f5-5ecf87e65884" );
6+ const SET_WIFI_UUID : uuid:: Uuid = uuid:: uuid! ( "bcd7e573-b0b2-4775-83c0-acbf3aaf210c" ) ;
77
88pub async fn start_bluetooth_task ( ) -> Result < ( ) > {
99 let manager = Manager :: new ( ) . await ?;
@@ -39,9 +39,7 @@ async fn bluetooth_task() -> Result<()> {
3939 loop {
4040 tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 5 ) ) . await ;
4141
42- let filter = ScanFilter {
43- services : vec ! [ FKM_UUID ] ,
44- } ;
42+ let filter = ScanFilter { services : vec ! [ ] } ;
4543 adapter. start_scan ( filter) . await ?;
4644
4745 tokio:: time:: sleep ( std:: time:: Duration :: from_secs ( 5 ) ) . await ;
@@ -51,7 +49,12 @@ async fn bluetooth_task() -> Result<()> {
5149 . await ?
5250 . ok_or_else ( || anyhow:: anyhow!( "No device properties found!" ) ) ?;
5351
54- let is_fkm = properties. services . contains ( & FKM_UUID ) ;
52+ //let is_fkm = properties.services.contains(&FKM_UUID);
53+ let is_fkm = properties
54+ . local_name
55+ . as_ref ( )
56+ . unwrap_or ( & String :: new ( ) )
57+ . starts_with ( "FKM-" ) ;
5558 if !is_fkm {
5659 continue ;
5760 }
@@ -72,8 +75,11 @@ async fn bluetooth_task() -> Result<()> {
7275}
7376
7477async fn setup_bt_device ( device : btleplug:: platform:: Peripheral ) -> Result < ( ) > {
75- tracing:: trace!( "Connecting to device" ) ;
76- device. connect ( ) . await ?;
78+ if !device. is_connected ( ) . await ? {
79+ tracing:: trace!( "Connecting to device" ) ;
80+ device. connect ( ) . await ?;
81+ }
82+
7783 tracing:: trace!( "Connected to device" ) ;
7884 device. discover_services ( ) . await ?;
7985 tracing:: trace!( "Discovered services" ) ;
0 commit comments