@@ -154,7 +154,8 @@ func StartApp(
154154 if ! yield (StreamMessage {progress : & Progress {Name : "preparing" , Progress : 0.0 }}) {
155155 return
156156 }
157- if appToStart .MainSketchPath != nil {
157+
158+ if _ , ok := appToStart .GetSketchPath (); ok {
158159 if ! yield (StreamMessage {progress : & Progress {Name : "sketch compiling and uploading" , Progress : 0.0 }}) {
159160 return
160161 }
@@ -175,7 +176,7 @@ func StartApp(
175176 return
176177 }
177178 provisionStartProgress := float32 (0.0 )
178- if appToStart . MainSketchPath != nil {
179+ if _ , ok := appToStart . GetSketchPath (); ok {
179180 provisionStartProgress = 10.0
180181 }
181182
@@ -402,7 +403,7 @@ func stopAppWithCmd(ctx context.Context, docker command.Cli, app app.ArduinoApp,
402403 }
403404 })
404405
405- if app . MainSketchPath != nil {
406+ if _ , ok := app . GetSketchPath (); ok {
406407 // Before stopping the microcontroller we want to make sure that the app was running.
407408 appStatus , err := getAppStatus (ctx , docker , app )
408409 if err != nil {
@@ -1162,9 +1163,12 @@ func compileUploadSketch(
11621163 defer func () {
11631164 _ , _ = srv .Destroy (ctx , & rpc.DestroyRequest {Instance : inst })
11641165 }()
1165- sketchPath := arduinoApp .MainSketchPath .String ()
1166+ sketchPath , ok := arduinoApp .GetSketchPath ()
1167+ if ! ok {
1168+ return fmt .Errorf ("no sketch path found in the Arduino app" )
1169+ }
11661170 buildPath := arduinoApp .SketchBuildPath ().String ()
1167- sketchResp , err := srv .LoadSketch (ctx , & rpc.LoadSketchRequest {SketchPath : sketchPath })
1171+ sketchResp , err := srv .LoadSketch (ctx , & rpc.LoadSketchRequest {SketchPath : sketchPath . String () })
11681172 if err != nil {
11691173 return err
11701174 }
@@ -1175,7 +1179,7 @@ func compileUploadSketch(
11751179 }
11761180 initReq := & rpc.InitRequest {
11771181 Instance : inst ,
1178- SketchPath : sketchPath ,
1182+ SketchPath : sketchPath . String () ,
11791183 Profile : profile ,
11801184 }
11811185
@@ -1215,7 +1219,7 @@ func compileUploadSketch(
12151219 compileReq := rpc.CompileRequest {
12161220 Instance : inst ,
12171221 Fqbn : "arduino:zephyr:unoq" ,
1218- SketchPath : sketchPath ,
1222+ SketchPath : sketchPath . String () ,
12191223 BuildPath : buildPath ,
12201224 Jobs : 2 ,
12211225 }
@@ -1241,12 +1245,12 @@ func compileUploadSketch(
12411245 slog .Info ("Used library " + lib .GetName () + " (" + lib .GetVersion () + ") in " + lib .GetInstallDir ())
12421246 }
12431247
1244- if err := uploadSketchInRam (ctx , w , srv , inst , sketchPath , buildPath ); err != nil {
1248+ if err := uploadSketchInRam (ctx , w , srv , inst , sketchPath . String () , buildPath ); err != nil {
12451249 slog .Warn ("failed to upload in ram mode, trying to configure the board in ram mode, and retry" , slog .String ("error" , err .Error ()))
12461250 if err := configureMicroInRamMode (ctx , w , srv , inst ); err != nil {
12471251 return err
12481252 }
1249- return uploadSketchInRam (ctx , w , srv , inst , sketchPath , buildPath )
1253+ return uploadSketchInRam (ctx , w , srv , inst , sketchPath . String () , buildPath )
12501254 }
12511255 return nil
12521256}
0 commit comments