Skip to content

Commit 6ba4558

Browse files
committed
enabled -scan 'batch mode' for updating notecard firmware
1 parent 80ec9d3 commit 6ba4558

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

notecard/dfu.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,21 +281,28 @@ func loadBin(filetype string, filename string, bin []byte, binaryMax int) (err e
281281

282282
}
283283

284+
// Display summary
285+
elapsedSecs := (time.Now().UTC().Unix() - beganSecs) + 1
286+
fmt.Printf("%d seconds (%.0f Bps)\n", elapsedSecs, float64(totalLen)/float64(elapsedSecs))
287+
284288
// Wait until the DFU has completed. This is particularly important for notecard
285289
// sideloads where we must restart the module.
286290
if filetype == notehub.HubFileTypeCardFirmware {
291+
first := true
287292
for i := 0; i < 90; i++ {
288293
rsp, err = card.TransactionRequest(notecard.Request{Req: "dfu.status", Name: "card"})
289294
if err == nil && !rsp.Pending {
290295
break
291296
}
297+
if first {
298+
first = false
299+
fmt.Printf("waiting for firmware update to complete\n")
300+
}
292301
time.Sleep(1000 * time.Millisecond)
293302
}
294303
}
295304

296305
// Done
297-
elapsedSecs := (time.Now().UTC().Unix() - beganSecs) + 1
298-
fmt.Printf("%d seconds (%.0f Bps)\n", elapsedSecs, float64(totalLen)/float64(elapsedSecs))
299306
return
300307

301308
}

notecard/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ func main() {
556556
lib.ConfigSetHub(actionHub)
557557
}
558558

559-
if err == nil && actionSideload != "" {
559+
if err == nil && actionSideload != "" && actionScan == "" {
560560
err = dfuSideload(actionSideload, actionVerbose)
561561
}
562562

@@ -669,7 +669,7 @@ func main() {
669669
}
670670

671671
if err == nil && actionScan != "" {
672-
err = scan(actionVerbose, actionFactory, actionSetup, actionSetupSKU, actionProvision, actionFactory, actionScan)
672+
err = scan(actionVerbose, actionFactory, actionSetup, actionSetupSKU, actionProvision, actionFactory, actionSideload, actionScan)
673673
}
674674

675675
if err == nil && actionCommtest {

notecard/scan.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ type ScannedSIM struct {
4343
}
4444

4545
// Scan of a set of notecards, appending to JSON file. Press ^C when done.
46-
func scan(debugEnabled bool, init bool, fnSetup string, fnSetupSKU string, carrierProvision string, factoryReset bool, outfile string) (err error) {
46+
func scan(debugEnabled bool, init bool, fnSetup string, fnSetupSKU string, carrierProvision string, factoryReset bool, sideload string, outfile string) (err error) {
4747

4848
// Only allow one of the two
4949
if fnSetup != "" && fnSetupSKU != "" {
@@ -205,6 +205,14 @@ func scan(debugEnabled bool, init bool, fnSetup string, fnSetupSKU string, carri
205205
}
206206
}
207207

208+
// If a sideload, do it
209+
if sideload != "" {
210+
err = dfuSideload(sideload, debugEnabled)
211+
if err != nil {
212+
break
213+
}
214+
}
215+
208216
// If requests were specified, process them
209217
if len(requests) > 0 {
210218
// Process the requests

0 commit comments

Comments
 (0)