@@ -89,11 +89,8 @@ async fn async_main(
8989 HashMap :: new ( )
9090 } ) ;
9191 for ( mac, device_data) in devices_list. iter ( ) {
92- match device_data. type_ {
93- devices:: enums:: DeviceType :: Nothing => {
94- managed_devices_mac. push ( mac. clone ( ) ) ;
95- }
96- _ => { }
92+ if device_data. type_ == devices:: enums:: DeviceType :: Nothing {
93+ managed_devices_mac. push ( mac. clone ( ) ) ;
9794 }
9895 }
9996
@@ -166,17 +163,14 @@ async fn async_main(
166163 let device_managers = device_managers. clone ( ) ;
167164 tokio:: spawn ( async move {
168165 let mut managers = device_managers. write ( ) . await ;
169- match type_ {
170- devices:: enums:: DeviceType :: Nothing => {
171- let dev = devices:: nothing:: NothingDevice :: new ( device. address ( ) , ui_tx_clone. clone ( ) ) . await ;
172- let dev_managers = DeviceManagers :: with_att ( dev. att_manager . clone ( ) ) ;
173- managers
174- . entry ( addr_str. clone ( ) )
175- . or_insert ( dev_managers)
176- . set_att ( dev. att_manager ) ;
177- ui_tx_clone. send ( BluetoothUIMessage :: DeviceConnected ( addr_str) ) . unwrap ( ) ;
178- }
179- _ => { }
166+ if type_ == devices:: enums:: DeviceType :: Nothing {
167+ let dev = devices:: nothing:: NothingDevice :: new ( device. address ( ) , ui_tx_clone. clone ( ) ) . await ;
168+ let dev_managers = DeviceManagers :: with_att ( dev. att_manager . clone ( ) ) ;
169+ managers
170+ . entry ( addr_str. clone ( ) )
171+ . or_insert ( dev_managers)
172+ . set_att ( dev. att_manager ) ;
173+ ui_tx_clone. send ( BluetoothUIMessage :: DeviceConnected ( addr_str) ) . unwrap ( ) ;
180174 }
181175 drop ( managers)
182176 } ) ;
@@ -221,23 +215,20 @@ async fn async_main(
221215 if managed_devices_mac. contains ( & addr_str) {
222216 info ! ( "Managed device connected: {}, initializing" , addr_str) ;
223217 let type_ = devices_list. get ( & addr_str) . unwrap ( ) . type_ . clone ( ) ;
224- match type_ {
225- devices:: enums:: DeviceType :: Nothing => {
226- let ui_tx_clone = ui_tx. clone ( ) ;
227- let device_managers = device_managers. clone ( ) ;
228- tokio:: spawn ( async move {
229- let mut managers = device_managers. write ( ) . await ;
230- let dev = devices:: nothing:: NothingDevice :: new ( addr, ui_tx_clone. clone ( ) ) . await ;
231- let dev_managers = DeviceManagers :: with_att ( dev. att_manager . clone ( ) ) ;
232- managers
233- . entry ( addr_str. clone ( ) )
234- . or_insert ( dev_managers)
235- . set_att ( dev. att_manager ) ;
236- drop ( managers) ;
237- ui_tx_clone. send ( BluetoothUIMessage :: DeviceConnected ( addr_str. clone ( ) ) ) . unwrap ( ) ;
238- } ) ;
239- }
240- _ => { }
218+ if type_ == devices:: enums:: DeviceType :: Nothing {
219+ let ui_tx_clone = ui_tx. clone ( ) ;
220+ let device_managers = device_managers. clone ( ) ;
221+ tokio:: spawn ( async move {
222+ let mut managers = device_managers. write ( ) . await ;
223+ let dev = devices:: nothing:: NothingDevice :: new ( addr, ui_tx_clone. clone ( ) ) . await ;
224+ let dev_managers = DeviceManagers :: with_att ( dev. att_manager . clone ( ) ) ;
225+ managers
226+ . entry ( addr_str. clone ( ) )
227+ . or_insert ( dev_managers)
228+ . set_att ( dev. att_manager ) ;
229+ drop ( managers) ;
230+ ui_tx_clone. send ( BluetoothUIMessage :: DeviceConnected ( addr_str. clone ( ) ) ) . unwrap ( ) ;
231+ } ) ;
241232 }
242233 return true ;
243234 }
0 commit comments