Allow the same staged firmware upload path on BLE as UART, fix distribute stack/event-group crashes, and recover sticky slave OTA sessions instead of failing with err=4. Co-authored-by: Cursor <cursoragent@cursor.com>
34 lines
799 B
Go
34 lines
799 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
)
|
|
|
|
func runOtaProgress(t otaTransport, args []string) error {
|
|
fs := flag.NewFlagSet("ota-progress", flag.ExitOnError)
|
|
clientID := fs.Uint("client", 0, "slave client id (0 = all in session)")
|
|
if err := fs.Parse(args); err != nil {
|
|
return err
|
|
}
|
|
|
|
if sp, ok := t.(*serialPort); ok {
|
|
sp.mu.Lock()
|
|
defer sp.mu.Unlock()
|
|
}
|
|
|
|
r, err := QueryOtaSlaveProgress(t, uint32(*clientID))
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Printf("active=%v total=%d aggregate=%d slaves=%d\n",
|
|
r.GetActive(), r.GetTotalBytes(), r.GetAggregateBytes(), r.GetSlaveCount())
|
|
for _, s := range r.GetSlaves() {
|
|
fmt.Printf(" slave %d: %d / %d bytes status=%d error=%d\n",
|
|
s.GetClientId(), s.GetBytesWritten(), s.GetTotalBytes(),
|
|
s.GetStatus(), s.GetError())
|
|
}
|
|
return nil
|
|
}
|