Skip to content

Commit

Permalink
enabled -scan 'batch mode' for updating notecard firmware
Browse files Browse the repository at this point in the history
  • Loading branch information
rayozzie committed May 15, 2024
1 parent 80ec9d3 commit 6ba4558
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
11 changes: 9 additions & 2 deletions notecard/dfu.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,21 +281,28 @@ func loadBin(filetype string, filename string, bin []byte, binaryMax int) (err e

}

// Display summary
elapsedSecs := (time.Now().UTC().Unix() - beganSecs) + 1
fmt.Printf("%d seconds (%.0f Bps)\n", elapsedSecs, float64(totalLen)/float64(elapsedSecs))

// Wait until the DFU has completed. This is particularly important for notecard
// sideloads where we must restart the module.
if filetype == notehub.HubFileTypeCardFirmware {
first := true
for i := 0; i < 90; i++ {
rsp, err = card.TransactionRequest(notecard.Request{Req: "dfu.status", Name: "card"})
if err == nil && !rsp.Pending {
break
}
if first {
first = false
fmt.Printf("waiting for firmware update to complete\n")
}
time.Sleep(1000 * time.Millisecond)
}
}

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

}
4 changes: 2 additions & 2 deletions notecard/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ func main() {
lib.ConfigSetHub(actionHub)
}

if err == nil && actionSideload != "" {
if err == nil && actionSideload != "" && actionScan == "" {
err = dfuSideload(actionSideload, actionVerbose)
}

Expand Down Expand Up @@ -669,7 +669,7 @@ func main() {
}

if err == nil && actionScan != "" {
err = scan(actionVerbose, actionFactory, actionSetup, actionSetupSKU, actionProvision, actionFactory, actionScan)
err = scan(actionVerbose, actionFactory, actionSetup, actionSetupSKU, actionProvision, actionFactory, actionSideload, actionScan)
}

if err == nil && actionCommtest {
Expand Down
10 changes: 9 additions & 1 deletion notecard/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type ScannedSIM struct {
}

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

// Only allow one of the two
if fnSetup != "" && fnSetupSKU != "" {
Expand Down Expand Up @@ -205,6 +205,14 @@ func scan(debugEnabled bool, init bool, fnSetup string, fnSetupSKU string, carri
}
}

// If a sideload, do it
if sideload != "" {
err = dfuSideload(sideload, debugEnabled)
if err != nil {
break
}
}

// If requests were specified, process them
if len(requests) > 0 {
// Process the requests
Expand Down

0 comments on commit 6ba4558

Please sign in to comment.