Files
powerpods/goTool/cmd_ota.go
T
skrueckenandCursor ae8ef40820 Enable host OTA over BLE and harden ESP-NOW slave distribution.
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>
2026-11-01 20:42:14 +01:00

40 lines
684 B
Go

package main
import (
"fmt"
"os"
)
func runOTA(t otaTransport, args []string) error {
if len(args) < 1 {
return fmt.Errorf("usage: ota <firmware.bin>")
}
data, err := os.ReadFile(args[0])
if err != nil {
return err
}
switch x := t.(type) {
case *serialPort:
x.mu.Lock()
defer x.mu.Unlock()
case *bleLink:
if err := x.ensureOTAMTU(); err != nil {
return err
}
}
return runOTAUnlocked(t, data, func(p OTAProgress) {
switch p.Phase {
case "preparing", "ready":
fmt.Println(p.Message)
case "uploading":
if p.Percent%10 == 0 {
fmt.Printf(" %s (%d%%)\n", p.Message, p.Percent)
}
case "done", "error":
fmt.Println(p.Message)
}
})
}