scanner

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Filter

func Filter(peripherals map[string]string) func(ble.Advertisement) bool

func LogInvalidData

func LogInvalidData(ctx context.Context, logger *slog.Logger, data []byte, err error)

LogInvalidData logs invalid BLE advertisement data

func NewMockBLEScanner added in v1.2.0

func NewMockBLEScanner(advertisements ...ble.Advertisement) *mockBLEScanner

func Read

func Read(a ble.Advertisement) (sd commonsensor.Data, err error)

Read reads sensor data from advertisement

func Validate added in v1.2.0

func Validate(cfg Config) error

Types

type BLEScanner

type BLEScanner interface {
	Scan(ctx context.Context, allowDup bool, h ble.AdvHandler, f ble.AdvFilter) error
}

type Config added in v1.2.0

type Config struct {
	Exporters     []exporter.Exporter
	DeviceName    string
	BLEScanner    BLEScanner
	Peripherals   map[string]string
	DeviceCreator DeviceCreator
	Logger        *slog.Logger
}

func DefaultConfig added in v1.2.0

func DefaultConfig() Config

type DeviceCreator

type DeviceCreator interface {
	NewDevice(impl string) (ble.Device, error)
}

type Discover added in v1.4.0

type Discover struct {
	// contains filtered or unexported fields
}

func NewDiscover added in v1.4.0

func NewDiscover(device string, ble BLEScanner, dev DeviceCreator, logger *slog.Logger) (*Discover, error)

func (*Discover) Close added in v1.4.0

func (d *Discover) Close() error

func (*Discover) Discover added in v1.4.0

func (d *Discover) Discover(ctx context.Context) ([]string, error)

type GoBLEDeviceCreator added in v1.2.0

type GoBLEDeviceCreator struct {
}

func (*GoBLEDeviceCreator) NewDevice added in v1.2.0

func (c *GoBLEDeviceCreator) NewDevice(impl string) (ble.Device, error)

type GoBLEScanner added in v1.2.0

type GoBLEScanner struct {
}

func (*GoBLEScanner) Scan added in v1.2.0

func (s *GoBLEScanner) Scan(ctx context.Context, allowDup bool, h ble.AdvHandler, f ble.AdvFilter) error

type Measurements

type Measurements struct {
	BLE         BLEScanner
	Peripherals map[string]string
	Logger      *slog.Logger
}

func (*Measurements) Channel

func (s *Measurements) Channel(ctx context.Context) chan sensor.Data

Channel creates a channel that will receive measurements read from all registered peripherals. The cancel function should be called after the client is done with receiving measurements or wishes to abort the scan.

type Scanner

type Scanner interface {
	io.Closer
	Scan(ctx context.Context, interval time.Duration) error
}

func NewContinuous

func NewContinuous(cfg Config) (Scanner, error)

func NewInterval

func NewInterval(cfg Config) (Scanner, error)

func NewOnce

func NewOnce(cfg Config) (Scanner, error)

Jump to

Keyboard shortcuts

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