ble

package
v0.19.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: GPL-3.0 Imports: 17 Imported by: 0

README

BLE Plugin

Documentation

Documentation

Index

Constants

View Source
const (
	// Name ...
	Name = "ble"
	// FuncEntityAction ...
	FuncEntityAction = "entityAction"

	Version = "0.0.1"

	AttrAddress              = "address"
	AttrCharacteristic       = "characteristic"
	AttrService              = "service"
	AttrTimeoutSec           = "timeout_sec"
	AttrConnectionTimeoutSec = "connection_timeout_sec"
	AttrDebug                = "debug"
	ActionScan               = "SCAN"
	AttrSystemInfo           = "SystemInfo"

	FunctionName = "automationTriggerBle"

	DefaultTimeout           int64 = 5
	DefaultConnectionTimeout int64 = 5
)

Variables

Functions

func GetReadBind

func GetReadBind(actor *Actor) func(char string) Response

func GetWriteBind

func GetWriteBind(actor *Actor) func(char string, payload []byte, withResponse bool) Response

func New

func New() supervisor.Pluggable

New ...

func NewActions

func NewActions() map[string]supervisor.ActorAction

func NewSettings

func NewSettings() map[string]*m.Attribute

NewSettings ...

func NewTriggerParams

func NewTriggerParams() m.TriggerParams

Types

type Actor

type Actor struct {
	*supervisor.BaseActor
	// contains filtered or unexported fields
}

Actor ...

func NewActor

func NewActor(entity *m.Entity,
	service supervisor.Service) (actor *Actor)

NewActor ...

func (*Actor) Destroy

func (e *Actor) Destroy()

func (*Actor) SetState

func (e *Actor) SetState(params supervisor.EntityStateParams) error

SetState ...

func (*Actor) Spawn

func (e *Actor) Spawn()

type Ble

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

func NewBle

func NewBle(address string, timeout, connectionTimeout int64, debug bool) *Ble

func (*Ble) Connect added in v0.19.1

func (b *Ble) Connect() error

func (*Ble) Disconnect

func (b *Ble) Disconnect() error

func (*Ble) GetCharacteristics

func (b *Ble) GetCharacteristics(chars []bluetooth.UUID) ([]bluetooth.DeviceCharacteristic, error)

func (*Ble) GetServices

func (b *Ble) GetServices() ([]bluetooth.DeviceService, error)

func (*Ble) IsConnected added in v0.19.1

func (b *Ble) IsConnected() bool

func (*Ble) Read added in v0.19.1

func (b *Ble) Read(c string) ([]byte, error)

func (*Ble) Scan added in v0.19.1

func (b *Ble) Scan(param *string)

func (*Ble) Subscribe added in v0.19.1

func (b *Ble) Subscribe(c string, handler func([]byte)) error

func (*Ble) Write added in v0.19.1

func (b *Ble) Write(c string, request []byte, withResponse bool) ([]byte, error)

type Bluetooth added in v0.19.1

type Bluetooth interface {
	Connect() error
	IsConnected() bool
	Disconnect() error
	Scan(address *string)
	Write(char string, request []byte, withResponse bool) ([]byte, error)
	Read(char string) ([]byte, error)
	Subscribe(char string, handler func([]byte)) error
}

type Response

type Response struct {
	Response []byte `json:"response"`
	Error    string `json:"error"`
}

type Trigger

type Trigger struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewTrigger

func NewTrigger(eventBus bus.Bus) *Trigger

func (*Trigger) AsyncAttach

func (t *Trigger) AsyncAttach(wg *sync.WaitGroup)

func (*Trigger) Connect

func (t *Trigger) Connect(params *TriggerParams, firstTime bool) error

func (*Trigger) FunctionName

func (t *Trigger) FunctionName() string

FunctionName ...

func (*Trigger) Name

func (t *Trigger) Name() string

func (*Trigger) Shutdown

func (t *Trigger) Shutdown()

func (*Trigger) Subscribe

func (t *Trigger) Subscribe(options triggers.Subscriber) error

Subscribe ...

func (*Trigger) Unsubscribe

func (t *Trigger) Unsubscribe(options triggers.Subscriber) error

Unsubscribe ...

type TriggerParams

type TriggerParams struct {
	Bluetooth
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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