Add dynamic UART/BLE host connect for serve, dashboard, and WS.

Serve starts without a required port; REST/WS/UI can scan and switch transports, with BLE live ticks and UART-only OTA.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-23 22:40:28 +02:00
co-authored by Cursor
parent 92a13d7fd0
commit aa67edfe94
18 changed files with 1573 additions and 404 deletions
+27 -1
View File
@@ -1,6 +1,12 @@
package main
import "powerpod/gotool/pb"
import (
"fmt"
"powerpod/gotool/pb"
"google.golang.org/protobuf/proto"
)
// accelSamplesFromCacheStatus maps combined CACHE_STATUS entries to AccelSample
// (for dashboard / WebSocket accel push).
@@ -47,3 +53,23 @@ func tapEventsFromCacheStatus(r *pb.CacheStatusResponse) []*pb.TapEvent {
}
return out
}
// cacheStatusFromBLEStreamPayload parses a framed BLE_STREAM_TICK payload
// (type byte + protobuf UartMessage) into a CacheStatusResponse-shaped view.
func cacheStatusFromBLEStreamPayload(payload []byte) (*pb.CacheStatusResponse, error) {
if len(payload) < 2 {
return nil, fmt.Errorf("BLE stream tick too short")
}
if payload[0] != byte(pb.MessageType_BLE_STREAM_TICK) {
return nil, fmt.Errorf("unexpected BLE tick type 0x%02x", payload[0])
}
var msg pb.UartMessage
if err := proto.Unmarshal(payload[1:], &msg); err != nil {
return nil, err
}
tick := msg.GetBleStreamTick()
if tick == nil {
return nil, fmt.Errorf("missing ble_stream_tick")
}
return &pb.CacheStatusResponse{Clients: tick.GetClients()}, nil
}