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:
+27
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user