Documentation
¶
Overview ¶
Package handyble implements firmware-4 Handy RPC over a byte-oriented BLE link. It knows the device protocol, not the motion engine or the native radio stack.
Index ¶
- Constants
- Variables
- func Encode(r Request) ([]byte, error)
- type HSPState
- type Message
- type Method
- type Point
- type Request
- type Session
- type SimulatedConnector
- type SimulatedLink
- func (l *SimulatedLink) Close() error
- func (l *SimulatedLink) Device() ble.DeviceInfo
- func (l *SimulatedLink) Emit(payload []byte)
- func (l *SimulatedLink) Events() <-chan ble.LinkEvent
- func (l *SimulatedLink) ReadBattery(context.Context) (int, error)
- func (l *SimulatedLink) SetLastWill([]byte) error
- func (l *SimulatedLink) Write(ctx context.Context, data []byte, _ bool) error
- func (l *SimulatedLink) Writes() [][]byte
- type Snapshot
Constants ¶
const MaxFrameBytes = 512
MaxFrameBytes is the firmware RPC frame ceiling, before negotiated MTU limits.
Variables ¶
var ErrInterrupted = errors.New("handy command interrupted by Stop")
ErrInterrupted marks queued work invalidated by Stop.
Functions ¶
Types ¶
type HSPState ¶
type HSPState struct {
PlayState string
StreamID uint32
Points uint32
CurrentTime int32
Tail int32
}
HSPState contains observed firmware state, not a commanded-position estimate.
type Message ¶
type Message struct {
Notification bool
ID uint32
Method Method
State *HSPState
DeviceTime *uint32
ErrorCode *uint64
}
Message is a decoded response or notification with optional firmware feedback.
type Method ¶
type Method uint32
Method is a firmware RPC field number from handy-public-rpc commit 2398008c.
const ( StopCurrentMode Method = 715 // firmware 4.0.13+: Stop regardless of the active mode ClockSet Method = 709 ClockGet Method = 712 Stroke Method = 841 Setup Method = 860 Add Method = 861 Play Method = 863 Stop Method = 864 State Method = 867 )
Supported RPC methods use the same wire contract as Browser Bluetooth.
type Request ¶
type Request struct {
Method Method
ID uint32
StreamID uint32
Min, Max float32 // normalized 0..1 stroke window, not point positions
Points []Point
Tail uint32
Flush bool
Start int32
ServerTime *uint64
ClockOffset int64
RoundTrip int32
}
Request is a device command, after shared transport validation and quantization. Looping is deliberately not exposed: loss of the controller must exhaust a finite buffer. Play always pauses on starvation.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session owns RPC ordering and correlation on one immutable BLE link. The operation gate covers a whole point batch; Interrupt fences the next chunk without canceling a healthy native write halfway through Stop.
func NewSession ¶
NewSession attaches RPC correlation to an already-open immutable BLE link.
func (*Session) Done ¶
func (s *Session) Done() <-chan struct{}
Done closes when the event reader stops; Close also waits for link teardown.
func (*Session) Execute ¶
Execute serializes one command, including all of an Add operation's chunks.
func (*Session) Initialize ¶
Initialize sends only Stop and optional clock commands. It never starts motion.
type SimulatedConnector ¶
type SimulatedConnector struct {
WriteOnly bool
WriteLimit int
// contains filtered or unexported fields
}
SimulatedConnector exercises the RPC path without a radio or a second motion engine. It acknowledges bytes and records requests; it does not move anything.
func NewSimulatedConnector ¶
func NewSimulatedConnector() *SimulatedConnector
NewSimulatedConnector creates an RPC-only simulator with no radio access.
func (*SimulatedConnector) Connect ¶
func (c *SimulatedConnector) Connect(ctx context.Context, _ ble.ConnectRequest) (ble.Link, error)
Connect opens a fresh in-memory link without starting motion.
func (*SimulatedConnector) LastLink ¶
func (c *SimulatedConnector) LastLink() *SimulatedLink
LastLink returns the most recently created link for test inspection.
func (*SimulatedConnector) Simulated ¶
func (*SimulatedConnector) Simulated() bool
Simulated always reports true.
type SimulatedLink ¶
type SimulatedLink struct {
// contains filtered or unexported fields
}
SimulatedLink records wire requests and emits optional RPC acknowledgments.
func (*SimulatedLink) Close ¶
func (l *SimulatedLink) Close() error
Close retires the simulated link and ends its event stream.
func (*SimulatedLink) Device ¶
func (l *SimulatedLink) Device() ble.DeviceInfo
Device reports a synthetic identity and write limit.
func (*SimulatedLink) Emit ¶
func (l *SimulatedLink) Emit(payload []byte)
Emit injects firmware feedback for isolated protocol tests.
func (*SimulatedLink) Events ¶
func (l *SimulatedLink) Events() <-chan ble.LinkEvent
Events supplies the simulated notification stream.
func (*SimulatedLink) ReadBattery ¶
func (l *SimulatedLink) ReadBattery(context.Context) (int, error)
ReadBattery reports that the Handy profile has no battery characteristic.
func (*SimulatedLink) SetLastWill ¶
func (l *SimulatedLink) SetLastWill([]byte) error
SetLastWill is inert because this simulator has no physical output.
func (*SimulatedLink) Writes ¶
func (l *SimulatedLink) Writes() [][]byte
Writes returns independent copies of recorded frames.