Documentation
¶
Overview ¶
Package bleworker is the radio side of the native Bluetooth worker. It speaks workerproto over stdin and stdout and drives an Adapter. The concrete Bluetooth adapter lives in cmd/bluetooth-worker, so the core binary never links a radio stack (AGENTS.md section 3).
Index ¶
- Variables
- func Serve(ctx context.Context, input io.Reader, output io.Writer, adapter Adapter, ...) error
- type Adapter
- type Handlers
- type Info
- type Peripheral
- type SimulatedAdapter
- func (a *SimulatedAdapter) ConnectAddress(ctx context.Context, address string, profile ble.Profile) (Peripheral, error)
- func (a *SimulatedAdapter) Discover(_ context.Context, profile ble.Profile) ([]ble.Candidate, error)
- func (a *SimulatedAdapter) Enable() error
- func (a *SimulatedAdapter) ScanName(ctx context.Context, profile ble.Profile) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("device not found") ErrUnsupported = errors.New("device does not offer the required GATT service") ErrAmbiguous = errors.New("more than one matching Bluetooth device was found; turn off the others and try again") )
Adapter failures that map to protocol error codes.
Functions ¶
Types ¶
type Adapter ¶
type Adapter interface {
Enable() error
ConnectAddress(ctx context.Context, address string, profile ble.Profile) (Peripheral, error)
ScanName(ctx context.Context, profile ble.Profile) (string, error)
}
Adapter finds and connects devices.
type Peripheral ¶
type Peripheral interface {
Open(handlers Handlers) error
Write(payload []byte, withResponse bool) error
ReadBattery() (int, error)
Address() string
Name() string
MaxWriteBytes() int
Close() error
}
Peripheral is one connected device. Open discovers the pulse service and subscribes to notifications; it returns ErrUnsupported when the service or either characteristic is missing.
type SimulatedAdapter ¶
SimulatedAdapter models named device profiles behind the worker protocol. It backs the worker's -simulate flag and the process-level tests; no radio is used.
func NewSimulatedAdapter ¶
func NewSimulatedAdapter(connectors map[string]ble.Connector) *SimulatedAdapter
NewSimulatedAdapter returns an adapter over a fresh simulated connector.
func (*SimulatedAdapter) ConnectAddress ¶
func (a *SimulatedAdapter) ConnectAddress(ctx context.Context, address string, profile ble.Profile) (Peripheral, error)
ConnectAddress connects to the simulated device.