simpleserialble

package
v2.23.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: GPL-3.0 Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func NewReader(cfg *config.Instance) *Reader

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) Close

func (r *Reader) Close() error

Close stops the background loop, drops the link and releases the adapter.

func (*Reader) Connected

func (r *Reader) Connected() bool

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) Detect

func (*Reader) Detect(_ []string) string

func (*Reader) IDs

func (*Reader) IDs() []string

func (*Reader) Info

func (r *Reader) Info() string

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.

func (*Reader) Path

func (r *Reader) Path() string

func (*Reader) ReaderID

func (r *Reader) ReaderID() string

func (*Reader) Write

func (*Reader) Write(_ string) (*tokens.Token, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL