@@ -24,7 +24,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
2424 . start_scan ( )
2525 . await
2626 . expect ( "Can't scan BLE adapter for connected devices..." ) ;
27- time:: sleep ( Duration :: from_secs ( 2 ) ) . await ;
27+ time:: sleep ( Duration :: from_secs ( 10 ) ) . await ;
2828 let peripherals = adapter. peripherals ( ) . await ?;
2929 if peripherals. is_empty ( ) {
3030 eprintln ! ( "->>> BLE peripheral devices were not found, sorry. Exiting..." ) ;
@@ -53,12 +53,18 @@ async fn main() -> Result<(), Box<dyn Error>> {
5353 "Now connected ({:?}) to peripheral {:?}..." ,
5454 is_connected, & local_name
5555 ) ;
56- let chars = peripheral. discover_characteristics ( ) . await ?;
57- if is_connected {
58- println ! ( "Discover peripheral {:?} characteristics..." , & local_name) ;
59- for characteristic in chars. into_iter ( ) {
60- println ! ( "{:?}" , characteristic) ;
56+ peripheral. discover_characteristics ( ) . await ?;
57+ println ! ( "Discover peripheral {:?} characteristics..." , & local_name) ;
58+ for service in peripheral. services ( ) {
59+ println ! (
60+ "Service UUID {}, primary: {}" ,
61+ service. uuid, service. primary
62+ ) ;
63+ for characteristic in service. characteristics {
64+ println ! ( " {:?}" , characteristic) ;
6165 }
66+ }
67+ if is_connected {
6268 println ! ( "Disconnecting from peripheral {:?}..." , & local_name) ;
6369 peripheral
6470 . disconnect ( )
0 commit comments