RFModel

package
v0.0.0-...-cdf6177 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PacketLength       uint = 32
	RequestHeaderSize  uint = 4
	ResponseHeaderSize uint = 3
	MaxDataLengthRq         = PacketLength - RequestHeaderSize
	MaxDataLengthRs         = PacketLength - ResponseHeaderSize
)

for RF packet parsing

View Source
const (
	EDNone        EDataType = 0
	EDBool                  = 1
	EDByte                  = 2
	EDInt32                 = 3
	EDString                = 4
	EDByteArray             = 5
	EDUnspecified           = 0xF
)

EDataType enum

View Source
const (
	// Unit 0, global device functions
	F0SetNewSessionKey    FuncNo = 10
	F0SetMACAddress              = 12
	F0SetRFChannel               = 16
	F0GetDeviceStatistics        = 13
	F0NOP                        = 15
	F0ResetTransactionID         = 14
	F0SetSlaveMode               = 17
	// per Unit functions
	FGetListOfUnitFunctions = 0
	FGetTextDescription     = 1
	FSetTextDescription     = 2
)

RF functions

View Source
const (
	ERCOk               EResponseCode = 0
	ERCAddressBadLength               = 1

	ERCChBadChannels      = 0x10
	ERCChBadPermissions   = 0x12
	ERCChValidationFailed = 0x13

	ERCNotImplemented              = 0x7F
	ERCBadVersion                  = 0x90
	ERCBadUnitId                   = 0xA0
	ERCNotConsecutiveTransactionId = 0xB0
	ERCBadFunctionId               = 0xC0
	ERCResponseTooBig              = 0xD0
	ERCBadRequestData              = 0xE0
)
View Source
const (
	EGeneral          ErrorType = "general error"
	EBadParameter               = "bad parameter"
	EBadResponse                = "bad response"
	EPacketValidation           = "packet validation"
	EDeviceTimeout              = "device did not respond 3 times in a row"
	EBadCode                    = "function return code is not 0"
)

Variables

View Source
var Devices = map[DeviceAddress]*Device{}

Devices all known devices

View Source
var UnitFunctions = map[UnitFunctionKey]UnitFunction{}

UnitFunctions all known functions of all known devices

Functions

func AddressToString

func AddressToString(a DeviceAddress) (ret string)

func Dump

func Dump(b []byte) string

func Init

func Init(rf *RFModel, transmitter TranscieverModel.Transmitter)

Init ...

Types

type Device

type Device struct {
	Address      DeviceAddress
	LastUpdate   time.Time
	UnitCount    uint
	BuildNumber  uint32
	AllFunctions []UnitFunctionKey
}

Device represents a device with one transceiver with multiple units in it

type DeviceAddress

type DeviceAddress TranscieverModel.Address

func ParseAddress

func ParseAddress(s string) (ret DeviceAddress)

type EDataType

type EDataType byte

EDataType ...

type EResponseCode

type EResponseCode byte

type Error

type Error struct {
	Error error
	Type  ErrorType
	Code  byte
}

type ErrorType

type ErrorType string

type FuncNo

type FuncNo byte

FuncNo unit function id

type RFModel

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

RFModel handler

func (*RFModel) CallFunction

func (rf *RFModel) CallFunction(uid UID, fno FuncNo, payload TranscieverModel.Payload) TranscieverModel.Payload

CallFunction is basic api for RFModel TODO shall catch and handle all the transceiver panics TODO retry 3 times on any error may panic by its own

func (*RFModel) Close

func (rf *RFModel) Close()

Close ...

func (*RFModel) ReadFunction

func (rf *RFModel) ReadFunction(uid UID, fno FuncNo) Variant

ReadFunction read from the unit call given function with empty payload and parse result according to the function output type (fn 0 of a given unit)

func (*RFModel) WriteFunction

func (rf *RFModel) WriteFunction(uid UID, fno FuncNo, value Variant)

WriteFunction write to the unit call given function with serialized value as a payload according to the function input type

type UID

type UID struct {
	Address DeviceAddress
	Unit    byte
}

UID unit ID

type UnitFunction

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

UnitFunction ...

type UnitFunctionKey

type UnitFunctionKey struct {
	UID UID
	FNo FuncNo
}

UnitFunctionKey ...

type Variant

type Variant interface{}

Variant ...

Jump to

Keyboard shortcuts

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