Documentation
¶
Overview ¶
Package simpleserialble is the simple serial reader protocol carried over Bluetooth Low Energy. The reader is a peripheral exposing the Nordic UART Service; Core connects as a central, subscribes to its TX characteristic and reads the same newline-delimited SCAN lines a wired simple serial reader would send.
Readers are connected by explicit configuration only:
[[readers.connect]] driver = "simpleserial_ble" path = "AA:BB:CC:DD:EE:FF"
The service UUID is shared by thousands of unrelated devices, so scanning for it and connecting to whatever answers is not an option. Advertising a recognisable local name is the natural way to add detection later.
Unlike a serial port, the device may be out of range or switched off for long stretches, so the driver owns the link: Open attaches to the adapter and returns at once, and a background loop finds, connects to and reconnects the device. It never backs off: one scan stays open until the device is heard, so a reader that is switched on is picked up as soon as it advertises. Scanning shares the radio with the BLE API transport's advertising, so a reader that is missing makes the device a little harder to discover until it turns up.
Index ¶
- Constants
- type Reader
- func (*Reader) CancelWrite()
- func (r *Reader) Capabilities() []readers.Capability
- func (r *Reader) Close() error
- func (r *Reader) Connected() bool
- func (*Reader) Detect(_ []string) string
- func (*Reader) IDs() []string
- func (r *Reader) Info() string
- func (*Reader) Metadata() readers.DriverMetadata
- func (*Reader) OnMediaChange(*models.ActiveMedia) error
- func (r *Reader) Open(device config.ReadersConnect, iq chan<- readers.Scan, _ readers.OpenOpts) error
- func (r *Reader) Path() string
- func (r *Reader) ReaderID() string
- func (*Reader) Write(_ string) (*tokens.Token, error)
Constants ¶
const (
// DriverID is the reader driver identifier.
DriverID = "simpleserial_ble"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader is a simple serial reader reached over BLE.
func NewReader ¶
NewReader builds a reader over the system's Bluetooth stack. It never powers the adapter on: a reader that keeps retrying must not keep switching a radio back on that the user turned off.
func (*Reader) CancelWrite ¶
func (*Reader) CancelWrite()
func (*Reader) Capabilities ¶
func (r *Reader) Capabilities() []readers.Capability
func (*Reader) Connected ¶
Connected reports whether the reader is attached: opened and not closed. The device itself may be out of range meanwhile; Info says which.
func (*Reader) Metadata ¶
func (*Reader) Metadata() readers.DriverMetadata
func (*Reader) OnMediaChange ¶
func (*Reader) OnMediaChange(*models.ActiveMedia) error
func (*Reader) Open ¶
func (r *Reader) Open(device config.ReadersConnect, iq chan<- readers.Scan, _ readers.OpenOpts) error
Open attaches to the Bluetooth adapter and starts looking for the device. It fails only for what cannot be retried by waiting: a bad address, no adapter, an adapter that cannot act as a central. Whether the device is in range is the background loop's business, so the reader manager, which calls Open on its own tick, is never held up by a device that is off.