File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed
Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -143,11 +143,15 @@ async fn central_event(
143143 Some ( CentralEvent :: DeviceDiscovered ( device. id . into ( ) ) )
144144 }
145145 DeviceEvent :: Connected { connected } => {
146- let device = session. get_device_info ( & id) . await . ok ( ) ?;
147- if connected {
148- Some ( CentralEvent :: DeviceConnected ( device. id . into ( ) ) )
146+ // device may be unknown if unpaired manually from the system
147+ let device = session. get_device_info ( & id) . await ;
148+ if device. is_ok ( ) && connected {
149+ Some ( CentralEvent :: DeviceConnected ( id. into ( ) ) )
150+ } else if !connected {
151+ Some ( CentralEvent :: DeviceDisconnected ( id. into ( ) ) )
149152 } else {
150- Some ( CentralEvent :: DeviceDisconnected ( device. id . into ( ) ) )
153+ // unexpected state. connected without device_info
154+ None
151155 }
152156 }
153157 DeviceEvent :: Rssi { rssi : _ } => {
You can’t perform that action at this time.
0 commit comments