scanner

package
v0.0.0-...-df94072 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const BufferSize = 128

Variables

This section is empty.

Functions

func ContainsKeys

func ContainsKeys(a map[string]string, b map[string]bool) bool

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 Read

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

Read reads sensor data from advertisement

Types

type BLEScanner

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

type ContinuousScanner

type ContinuousScanner struct {
	Exporters []exporter.Exporter
	Quit      chan int
	// contains filtered or unexported fields
}

func NewContinuous

func NewContinuous(logger *slog.Logger, peripherals map[string]string) *ContinuousScanner

func (*ContinuousScanner) Close

func (s *ContinuousScanner) Close()

Close closes the scanner and frees allocated resources

func (*ContinuousScanner) Init

func (s *ContinuousScanner) Init(device string) error

Init initializes scanner using the given device

func (*ContinuousScanner) Scan

func (s *ContinuousScanner) Scan(ctx context.Context)

Scan scans and reports measurements immediately as they are received

func (*ContinuousScanner) Stop

func (s *ContinuousScanner) Stop()

Stop stops all running scans

type DeviceCreator

type DeviceCreator interface {
	NewDevice(impl string) (ble.Device, 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 OnceScanner

type OnceScanner struct {
	Exporters []exporter.Exporter
	// contains filtered or unexported fields
}

func NewOnce

func NewOnce(logger *slog.Logger, peripherals map[string]string) *OnceScanner

func (*OnceScanner) Close

func (s *OnceScanner) Close()

func (*OnceScanner) Init

func (s *OnceScanner) Init(device string) error

func (*OnceScanner) Scan

func (s *OnceScanner) Scan(ctx context.Context) error

Scan scans all registered peripherals once and quits

type Scanner

type Scanner struct {
	Exporters []exporter.Exporter
	Quit      chan int
	// contains filtered or unexported fields
}

func NewInterval

func NewInterval(logger *slog.Logger, peripherals map[string]string) *Scanner

func (*Scanner) Close

func (s *Scanner) Close()

Close closes the scanner and frees allocated resources

func (*Scanner) Init

func (s *Scanner) Init(device string) error

Init initializes scanner using the given device

func (*Scanner) Scan

func (s *Scanner) Scan(ctx context.Context, scanInterval time.Duration)

Scan scans and reports measurements at specified intervals

func (*Scanner) Stop

func (s *Scanner) Stop()

Stop stops all running scans

Jump to

Keyboard shortcuts

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