echonetlite

package
v0.0.0-...-e568d61 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BroadcastAddress = "224.0.23.0:3610"
)

Variables

View Source
var (
	ErrAlreadyStarted     = errors.New("a controller is already started")
	ErrNotQueryMessage    = errors.New("not a query message")
	ErrUnsupportedMessage = errors.New("unsupported message")
)
View Source
var (
	ErrUnsupportedFrame  = errors.New("unsupported frame")
	ErrElementsMismatch  = errors.New("the number of elements is mismatched")
	ErrTooManyProperties = errors.New("too many properties")
	ErrWrongLength       = errors.New("wrong length")
)
View Source
var (
	ErrUnexpectedEpc           = errors.New("unexpected epc")
	ErrPropertyCountMismatched = errors.New("the number of properties is mismatched")
)
View Source
var (
	ServiceTypeNames = map[ServiceType]string{
		ServiceTypeSetI:   "SetI",
		ServiceTypeSetC:   "SetC",
		ServiceTypeGet:    "Get",
		ServiceTypeInfReq: "InfReq",
		ServiceTypeSetGet: "SetGet",

		ServiceTypeSetReq:    "SetReq",
		ServiceTypeGetRes:    "GetRes",
		ServiceTypeInf:       "Inf",
		ServiceTypeInfC:      "InfC",
		ServiceTypeInfCRes:   "InfCRes",
		ServiceTypeSetGetRes: "SetGetRes",

		ServiceTypeSetISna:   "SetISna",
		ServiceTypeSetCSna:   "SetCSna",
		ServiceTypeGetSna:    "GetSna",
		ServiceTypeInfSna:    "InfSna",
		ServiceTypeSetGetSna: "SetGetSna",
	}
)

Functions

func GetPropertyMap

func GetPropertyMap(p Property) ([]byte, error)

Types

type Controller

type Controller struct {
	Logger *slog.Logger
	// contains filtered or unexported fields
}

func NewController

func NewController() Controller

func (*Controller) Close

func (c *Controller) Close() error

func (*Controller) CreateFrame

func (c *Controller) CreateFrame() Frame

func (*Controller) Execute

func (c *Controller) Execute(addr net.UDPAddr, f Frame) error

func (*Controller) QueryBuilder

func (c *Controller) QueryBuilder() *QueryBuilder

func (*Controller) Start

func (c *Controller) Start() error

func (*Controller) Stop

func (c *Controller) Stop() error

type Frame

type Frame struct {
	Ehd1  byte
	Ehd2  byte
	Tid   uint16
	Edata SpecifiedMessage
}

func DeserializeFrame

func DeserializeFrame(data []byte) (Frame, error)

func (Frame) Serialize

func (f Frame) Serialize() ([]byte, error)

type Property

type Property struct {
	Epc byte
	Edt []byte
}

func DeserializeProperties

func DeserializeProperties(data []byte) ([]Property, error)

func DeserializeProperty

func DeserializeProperty(data []byte) (Property, error)

func (Property) Serialize

func (p Property) Serialize() ([]byte, error)

type QueryBuilder

type QueryBuilder struct {
	Timeout time.Duration
	// contains filtered or unexported fields
}

func (QueryBuilder) Query

func (q QueryBuilder) Query(f Frame) ([]QueryResponse, error)

func (*QueryBuilder) SetTimeout

func (q *QueryBuilder) SetTimeout(duration time.Duration) *QueryBuilder

type QueryResponse

type QueryResponse struct {
	Addr  net.UDPAddr
	Frame Frame
}

type Serializable

type Serializable interface {
	Serialize() []byte
}

type ServiceType

type ServiceType byte
const (
	ServiceTypeSetI   ServiceType = 0x60
	ServiceTypeSetC   ServiceType = 0x61
	ServiceTypeGet    ServiceType = 0x62
	ServiceTypeInfReq ServiceType = 0x63
	ServiceTypeSetGet ServiceType = 0x6e

	ServiceTypeSetReq    ServiceType = 0x71
	ServiceTypeGetRes    ServiceType = 0x72
	ServiceTypeInf       ServiceType = 0x73
	ServiceTypeInfC      ServiceType = 0x74
	ServiceTypeInfCRes   ServiceType = 0x7a
	ServiceTypeSetGetRes ServiceType = 0x7e

	ServiceTypeSetISna   ServiceType = 0x50
	ServiceTypeSetCSna   ServiceType = 0x51
	ServiceTypeGetSna    ServiceType = 0x52
	ServiceTypeInfSna    ServiceType = 0x53
	ServiceTypeSetGetSna ServiceType = 0x5e
)

func (ServiceType) String

func (t ServiceType) String() string

type SpecifiedMessage

type SpecifiedMessage struct {
	Seoj       uint32
	Deoj       uint32
	Esv        ServiceType
	Properties []Property
}

func DeserializeSpecifiedMessage

func DeserializeSpecifiedMessage(data []byte) (SpecifiedMessage, error)

func (SpecifiedMessage) Serialize

func (m SpecifiedMessage) Serialize() ([]byte, error)

Jump to

Keyboard shortcuts

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