@@ -40,7 +40,7 @@ import (
40
40
var (
41
41
commonFlags arguments.Flags // contains fqbn and address
42
42
module string
43
- retries uint8
43
+ retries int
44
44
fwFile string
45
45
)
46
46
@@ -60,7 +60,7 @@ func NewFlashCommand() *cobra.Command {
60
60
}
61
61
commonFlags .AddToCommand (command )
62
62
command .Flags ().StringVarP (& module , "module" , "m" , "" , "Firmware module ID, e.g.: WINC1500, NINA" )
63
- command .Flags ().Uint8Var (& retries , "retries" , 9 , "Number of retries in case of upload failure (default 9)" )
63
+ command .Flags ().IntVar (& retries , "retries" , 9 , "Number of retries in case of upload failure (default 9)" )
64
64
command .Flags ().StringVarP (& fwFile , "input-file" , "i" , "" , "Path of the firmware to upload" )
65
65
return command
66
66
}
@@ -114,22 +114,31 @@ func runFlash(cmd *cobra.Command, args []string) {
114
114
logrus .Debugf ("firmware file downloaded in %s" , firmwareFilePath .String ())
115
115
}
116
116
117
- loaderSketchPath , err := download .DownloadSketch (board .LoaderSketch )
118
- if err != nil {
119
- feedback .Fatal (fmt .Sprintf ("Error downloading loader sketch from %s: %s" , board .LoaderSketch .URL , err ), feedback .ErrGeneric )
117
+ loaderSketch := ""
118
+ if ! board .IsPlugin () {
119
+ loaderSketchPath , err := download .DownloadSketch (board .LoaderSketch )
120
+ if err != nil {
121
+ feedback .Fatal (fmt .Sprintf ("Error downloading loader sketch from %s: %s" , board .LoaderSketch .URL , err ), feedback .ErrGeneric )
122
+ }
123
+ logrus .Debugf ("loader sketch downloaded in %s" , loaderSketchPath .String ())
124
+ loaderSketch = strings .ReplaceAll (loaderSketchPath .String (), loaderSketchPath .Ext (), "" )
125
+ } else {
126
+ // TODO...
120
127
}
121
- logrus .Debugf ("loader sketch downloaded in %s" , loaderSketchPath .String ())
122
128
123
- loaderSketch := strings .ReplaceAll (loaderSketchPath .String (), loaderSketchPath .Ext (), "" )
124
-
125
- for retry := 1 ; retry <= int (retries ); retry ++ {
126
- err = updateFirmware (board , loaderSketch , moduleName , uploadToolDir , firmwareFilePath )
129
+ for retry := 1 ; retry <= retries ; retry ++ {
130
+ var err error
131
+ if ! board .IsPlugin () {
132
+ err = updateFirmware (board , loaderSketch , moduleName , uploadToolDir , firmwareFilePath )
133
+ } else {
134
+ err = nil // TODO...
135
+ }
127
136
if err == nil {
128
137
logrus .Info ("Operation completed: success! :-)" )
129
138
break
130
139
}
131
140
logrus .Error (err )
132
- if retry == int ( retries ) {
141
+ if retry == retries {
133
142
logrus .Fatal ("Operation failed. :-(" )
134
143
}
135
144
logrus .Info ("Waiting 1 second before retrying..." )
0 commit comments