File tree Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Expand file tree Collapse file tree 2 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -100,15 +100,27 @@ impl BLEDevice {
100100 let async_result = service
101101 . GetCharacteristicsWithCacheModeAsync ( BluetoothCacheMode :: Uncached ) ?
102102 . await ?;
103- let status = async_result. Status ( ) ;
104- if status == Ok ( GattCommunicationStatus :: Success ) {
105- let results = async_result. Characteristics ( ) ?;
106- debug ! ( "characteristics {:?}" , results. Size ( ) ) ;
107- Ok ( results. into_iter ( ) . collect ( ) )
108- } else {
109- Err ( Error :: Other (
110- format ! ( "get_characteristics for {:?} failed: {:?}" , service, status) . into ( ) ,
111- ) )
103+
104+ match async_result. Status ( ) {
105+ Ok ( GattCommunicationStatus :: Success ) => {
106+ let results = async_result. Characteristics ( ) ?;
107+ debug ! ( "characteristics {:?}" , results. Size ( ) ) ;
108+ Ok ( results. into_iter ( ) . collect ( ) )
109+ }
110+ Ok ( GattCommunicationStatus :: ProtocolError ) => Err ( Error :: Other (
111+ format ! (
112+ "get_characteristics for {:?} encountered a protocol error" ,
113+ service
114+ )
115+ . into ( ) ,
116+ ) ) ,
117+ Ok ( status) => {
118+ debug ! ( "characteristic read failed due to {:?}" , status) ;
119+ Ok ( vec ! [ ] )
120+ }
121+ Err ( e) => Err ( Error :: Other (
122+ format ! ( "get_characteristics for {:?} failed: {:?}" , service, e) . into ( ) ,
123+ ) ) ,
112124 }
113125 }
114126
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ use crate::{
2727use async_trait:: async_trait;
2828use dashmap:: DashMap ;
2929use futures:: stream:: Stream ;
30- use log:: { error , trace } ;
30+ use log:: { trace , warn } ;
3131#[ cfg( feature = "serde" ) ]
3232use serde:: { Deserialize , Serialize } ;
3333#[ cfg( feature = "serde" ) ]
@@ -449,8 +449,7 @@ impl ApiPeripheral for Peripheral {
449449 ) ;
450450 }
451451 Err ( e) => {
452- error ! ( "get_characteristics_async {:?}" , e) ;
453- return Err ( e) ;
452+ warn ! ( "get_characteristics_async {:?}" , e) ;
454453 }
455454 }
456455 }
You can’t perform that action at this time.
0 commit comments