@@ -2,7 +2,7 @@ use async_trait::async_trait;
22
33use crate :: attributes:: app_attributes:: AppAttributes ;
44use crate :: board_settings:: BoardSettings ;
5- use crate :: command_impl:: reshuffle_apps:: { create_pkt, reshuffle_apps} ;
5+ use crate :: command_impl:: reshuffle_apps:: { create_pkt, reshuffle_apps, TockApp } ;
66use crate :: connection:: TockloaderConnection ;
77use crate :: errors:: TockloaderError ;
88use crate :: tabs:: tab:: Tab ;
@@ -15,37 +15,36 @@ impl CommandInstall for TockloaderConnection {
1515 settings : & BoardSettings ,
1616 tab : Tab ,
1717 ) -> Result < ( ) , TockloaderError > {
18- let mut installed_apps: Vec < AppAttributes > = self . list ( settings) . await . unwrap ( ) ;
19-
20- if let Some ( mut app) = reconstruct_app ( Some ( & tab) , settings) {
21- app. index = installed_apps. len ( ) as u8 ;
22- installed_apps. push ( app. clone ( ) ) ;
23- }
18+ let app_attributes_list: Vec < AppAttributes > = self . list ( settings) . await . unwrap ( ) ;
19+ let mut tock_app_list = app_attributes_list
20+ . iter ( )
21+ . map ( |app| TockApp :: from_app_attributes ( app, settings) )
22+ . collect :: < Vec < TockApp > > ( ) ;
2423
2524 // obtain the binaries in a vector
2625 let mut app_binaries: Vec < Vec < u8 > > = Vec :: new ( ) ;
2726
28- for app in installed_apps. iter ( ) {
29- match app. installed {
30- true => {
31- app_binaries. push ( app. clone ( ) . read_binary ( self ) . await . unwrap ( ) ) ;
32- }
33- false => {
34- // TODO(adi): change this when TBF Filtering will get merged
35- app_binaries. push (
36- tab. extract_binary ( settings. arch . as_ref ( ) . unwrap ( ) . as_str ( ) )
37- . unwrap ( ) ,
38- ) ;
39- }
40- }
27+ for app in tock_app_list. iter ( ) {
28+ app_binaries. push ( app. clone ( ) . read_binary ( self ) . await . unwrap ( ) )
4129 }
42- let configuration = reshuffle_apps ( settings, installed_apps) . unwrap ( ) ;
30+
31+ let mut app = TockApp :: from_tab ( & tab, settings) . unwrap ( ) ;
32+
33+ app. replace_idx ( tock_app_list. len ( ) ) ;
34+ tock_app_list. push ( app. clone ( ) ) ;
35+
36+ app_binaries. push (
37+ tab. extract_binary ( settings. arch . as_ref ( ) . unwrap ( ) . as_str ( ) )
38+ . unwrap ( ) ,
39+ ) ;
40+
41+ let configuration = reshuffle_apps ( settings, tock_app_list) . unwrap ( ) ;
4342
4443 // create the pkt, this contains all the binaries in a vec
4544 let pkt = create_pkt ( configuration, app_binaries) ;
4645
4746 // write the pkt
48- let _ = self . write ( settings. start_address , pkt) . await ;
47+ let _ = self . write ( settings. start_address , pkt, settings ) . await ;
4948 Ok ( ( ) )
5049 }
5150}
0 commit comments