dbusconn

package
Version: v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2021 License: LGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// OperabilityOk state 'ok' for OperabilityState
	OperabilityOk OperabilityState = 0
	// OperabilityPartial state 'partial' for OperabilityState
	OperabilityPartial OperabilityState = 1
	// OperabilityKo state 'Ko' for OperabilityState
	OperabilityKo OperabilityState = 2
	// OperabilityUnknown state 'unknown' for OperabilityState
	OperabilityUnknown OperabilityState = 3

	// PairingOk state 'ok' for PairingState
	PairingOk PairingState = 0
	// PairingInProgres state 'in progres' for PairingState
	PairingInProgres PairingState = 1
	// PairingKo state 'ko' for PairingState
	PairingKo PairingState = 2
	// PairingUnknown state 'unknown' for PairingState
	PairingUnknown PairingState = 3
	// PairingNotNeeded state 'not needed' for PairingState
	PairingNotNeeded PairingState = 4

	// ReachabilityOk state 'ok' for ReachabilityState
	ReachabilityOk ReachabilityState = 0
	// ReachabilityKo state 'ko' for ReachabilityState
	ReachabilityKo ReachabilityState = 1
	// ReachabilityRescue state 'rescue' for ReachabilityState
	ReachabilityRescue ReachabilityState = 2
	// ReachabilityUnknown state 'unknown' for ReachabilityState
	ReachabilityUnknown ReachabilityState = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Dbus

type Dbus struct {
	Callbacks DbusInterface
	Protocol  string
	// contains filtered or unexported fields
}

Dbus exported structure

func (*Dbus) EmitDeviceAdded

func (dc *Dbus) EmitDeviceAdded(devID string, alreadyAdded bool)

EmitDeviceAdded to call when a device is added

func (*Dbus) EmitItemChanged

func (dc *Dbus) EmitItemChanged(devID string, itemID string, data *Payload)

EmitItemChanged to call when the value of an item has changed

func (*Dbus) ExportDeviceOnDbus

func (dc *Dbus) ExportDeviceOnDbus(device *Device)

ExportDeviceOnDbus export a device on dbus

func (*Dbus) ExportItemOnDbus

func (dc *Dbus) ExportItemOnDbus(devID string, item *Item)

ExportItemOnDbus export an item on dbus

func (*Dbus) ExportModuleObject

func (dc *Dbus) ExportModuleObject(protocol string) (*Module, bool)

ExportModuleObject Initializes and exports the Module object on DBus

func (*Dbus) InitDbus

func (dc *Dbus) InitDbus() bool

InitDbus dbus initialization

func (*Dbus) Ready

func (dc *Dbus) Ready()

Ready set the Module object parameter "ready" to true

type DbusInterface

type DbusInterface interface {
	AddDevice(string, string, string, string, map[string]string) bool
	RemoveDevice(string) bool
}

DbusInterface callback called from dbus events

type Device

type Device struct {
	sync.Mutex

	DevID           string
	Address         string
	TypeID          string
	TypeVersion     string
	Options         map[string]string
	FirmwareVersion string

	Items map[string]*Item

	Frequency *int // in ms
	// contains filtered or unexported fields
}

Device sent over dbus

func InitDevice

func InitDevice(devID string, address string, typeID string, typeVersion string, options map[string]string, deviceInterface DeviceInterface) *Device

InitDevice to init a Device struct

func (*Device) AddItem

func (device *Device) AddItem(itemID string, typeID string, typeVersion string, options map[string]string) (bool, *dbus.Error)

AddItem called to add a new item to this device

func (*Device) HeartBeat

func (device *Device) HeartBeat() bool

HeartBeat return true if the hearbeat of the device is ok

func (*Device) RemoveItem

func (device *Device) RemoveItem(itemID string) (bool, *dbus.Error)

RemoveItem called to remove an item to this device

func (*Device) SetOperabilityState

func (device *Device) SetOperabilityState(state OperabilityState)

SetOperabilityState set the value of the property OperabilityState

func (*Device) SetOptions

func (device *Device) SetOptions(options map[string]string) (bool, *dbus.Error)

SetOptions called when a new options come from Hemis

func (*Device) SetPairingState

func (device *Device) SetPairingState(state PairingState)

SetPairingState set the value of the property PairingState

func (*Device) SetReachabilityState

func (device *Device) SetReachabilityState(state ReachabilityState)

SetReachabilityState set the value of the property ReachabilityState

func (*Device) SetVersion

func (device *Device) SetVersion(newVersion string)

SetVersion set the value of the property Version

func (*Device) UpdateFirmware

func (device *Device) UpdateFirmware(param string) (string, *dbus.Error)

UpdateFirmware call firmware update

type DeviceInterface

type DeviceInterface interface {
	SetItem(*Item, []byte) bool
	SetOptionsItem(*Item) bool
	SetOptionsDevice(*Device) bool
	AddItem(*Device, *Item) bool
	RemoveItem(*Device, *Item)
	UpdateFirmware(*Device, string) string
}

DeviceInterface callback called from device dbus events

type Item

type Item struct {
	ItemID      string
	Mac         string
	TypeID      string
	TypeVersion string
	Options     map[string]string
	// contains filtered or unexported fields
}

Item struct

func InitItem

func InitItem(itemID string, typeID string, typeVersion string, address string, options map[string]string, callbacks ItemInterface) *Item

InitItem to init an Item struct

func (*Item) SetItem

func (item *Item) SetItem(order []byte) (bool, *dbus.Error)

SetItem called when a new order come from Hemis

func (*Item) SetOptions

func (item *Item) SetOptions(options map[string]string) (bool, *dbus.Error)

SetOptions called when a new options come from Hemis

type ItemInterface

type ItemInterface interface {
	SetItem(*Item, []byte) bool
	SetOptionsItem(*Item) bool
}

ItemInterface callback called from item events

type Module

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

Module is a dbus object which represents the states of the module

func (*Module) IsReady

func (m *Module) IsReady() (bool, *dbus.Error)

IsReady dbus method to known is the module is ready or not

type OperabilityState

type OperabilityState int32

OperabilityState informs if the device work

type PairingState

type PairingState int32

PairingState informs if the state of the pairing

type Payload

type Payload struct {
	Value interface{} `json:"value"`
}

Payload is a struct of data

type ReachabilityState

type ReachabilityState int32

ReachabilityState informs if the device is reachable

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL