core

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2023 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCoreEmptyEndpointClientName = errors.New("endpoint client name empty")
	ErrCoreLwm2mVersionNotSupport  = errors.New("lwm2m version not support")
	ErrIDNotFound                  = errors.New("id not found")
	ErrNotFound                    = errors.New("not found")
	ErrDeviceNotFound              = errors.New("device not found")
)
View Source
var (
	ErrUnexpectedResponseCode = errors.New("unexpected response code")
)

Functions

func CloseConn

func CloseConn(cc inactivity.Conn)

func GetLifetime

func GetLifetime(ctx context.Context) *time.Duration

func WithLifetime

func WithLifetime(ctx context.Context, lifetime time.Duration) context.Context

Types

type Binding

type Binding string
var (
	UdpBinding   Binding = "U"
	TcpBinding   Binding = "T"
	SmsBinding   Binding = "S"
	NonIpBinding Binding = "N"
)

func NewBinding

func NewBinding(b string) Binding

type Device

type Device struct {
	Id          string
	Endpoint    string
	Version     string
	BindingMode Binding

	Lifetime int
	Sms      *string
	Manager  Manager
	// contains filtered or unexported fields
}

func (*Device) CancelObserve

func (d *Device) CancelObserve(p node.Path) error

func (*Device) Close

func (d *Device) Close()

func (*Device) Create

func (d *Device) Create(ctx context.Context, p node.Path, val *node.ObjectInstance) error

func (*Device) Delete

func (d *Device) Delete(ctx context.Context, p node.Path) error

func (*Device) Discover

func (d *Device) Discover(ctx context.Context, p node.Path) ([]*encoding.CoreLink, error)

func (*Device) Execute

func (d *Device) Execute(ctx context.Context, p node.Path, arguments string) error

func (*Device) HasObject

func (d *Device) HasObject(id uint16) bool

func (*Device) HasObjectInstance

func (d *Device) HasObjectInstance(id, iid uint16) bool

func (*Device) HasObjectWithInstance

func (d *Device) HasObjectWithInstance(id uint16) bool

func (*Device) Observe

func (d *Device) Observe(p node.Path, onMsg ObserveFunc) error

func (*Device) ObserveObject

func (d *Device) ObserveObject(p node.Path, onMsg ObserveObjectFunc) error

func (*Device) ObserveResource

func (d *Device) ObserveResource(p node.Path, onMsg ObserveResourceFunc) error

func (*Device) ObserveSync

func (d *Device) ObserveSync(p node.Path, onMsg ObserveFunc) error
func (d *Device) ParseCoreLinks(links []*encoding.CoreLink)

func (*Device) Read

func (d *Device) Read(ctx context.Context, p node.Path) ([]node.Node, error)

func (*Device) ReadObject

func (d *Device) ReadObject(ctx context.Context, p node.Path) (*node.Object, error)

func (*Device) ReadResource

func (d *Device) ReadResource(ctx context.Context, p node.Path) (*node.Resource, error)

func (*Device) String

func (d *Device) String() string

func (*Device) Write

func (d *Device) Write(ctx context.Context, p node.Path, val ...node.Node) error

func (*Device) WriteObjectInstance

func (d *Device) WriteObjectInstance(ctx context.Context, p node.Path, val *node.ObjectInstance) error

func (*Device) WriteResource

func (d *Device) WriteResource(ctx context.Context, p node.Path, val *node.Resource) error

type DeviceEvent

type DeviceEvent struct {
	EventType DeviceEventType
	Device    *Device
}

type DeviceEventType

type DeviceEventType int
const (
	DeviceRegister DeviceEventType = iota
	DevicePostRegister
	DeviceUpdate
	DevicePostUpdate
	DeviceDeregister
)

func (DeviceEventType) String

func (e DeviceEventType) String() string

type DeviceManager

type DeviceManager interface {
	Read(ctx context.Context, p node.Path) ([]node.Node, error)
	ReadObject(ctx context.Context, p node.Path) (*node.Object, error)
	ReadResource(ctx context.Context, p node.Path) (*node.Resource, error)
	Write(ctx context.Context, p node.Path, val ...node.Node) error
	WriteResource(ctx context.Context, p node.Path, val *node.Resource) error
	WriteObjectInstance(ctx context.Context, p node.Path, val *node.ObjectInstance) error
	Discover(ctx context.Context, p node.Path) ([]*encoding.CoreLink, error)
}

type InactivityMonitor

type InactivityMonitor[C inactivity.Conn] struct {
	// contains filtered or unexported fields
}

func New

func New[C inactivity.Conn](onInactive inactivity.OnInactiveFunc[C]) *InactivityMonitor[C]

func NewInactivityMonitor

func NewInactivityMonitor[C inactivity.Conn](onInactive inactivity.OnInactiveFunc[C]) *InactivityMonitor[C]

func (*InactivityMonitor[C]) CheckInactivity

func (m *InactivityMonitor[C]) CheckInactivity(now time.Time, cc C)

func (*InactivityMonitor[C]) LastActivity

func (m *InactivityMonitor[C]) LastActivity() time.Time

func (*InactivityMonitor[C]) Notify

func (m *InactivityMonitor[C]) Notify()

type InactivityMonitorOpt

type InactivityMonitorOpt[C options.OnInactiveFunc] struct {
	// contains filtered or unexported fields
}

InactivityMonitorOpt notifies when a connection was inactive for a given duration.

func WithInactivityMonitor

func WithInactivityMonitor[C options.OnInactiveFunc](onInactive C) InactivityMonitorOpt[C]

WithInactivityMonitor set deadline's for read operations over client connection.

func (InactivityMonitorOpt[C]) DTLSServerApply

func (o InactivityMonitorOpt[C]) DTLSServerApply(cfg *dtlsServer.Config)

func (InactivityMonitorOpt[C]) TCPServerApply

func (o InactivityMonitorOpt[C]) TCPServerApply(cfg *tcpServer.Config)

func (InactivityMonitorOpt[C]) UDPServerApply

func (o InactivityMonitorOpt[C]) UDPServerApply(cfg *udpServer.Config)

type Manager

type Manager interface {
	Register(req *RegisterRequest, links []*encoding.CoreLink, conn mux.Conn) (*Device, error)
	// PostRegister call by transport when register response send
	PostRegister(id string)
	Update(id string, req *UpdateRequest, links []*encoding.CoreLink, conn mux.Conn) error
	PostUpdate(id string)
	Deregister(id string) error
	GetDevice(id string) (*Device, error)
	GetDeviceByEP(ep string) (*Device, error)
	OnDeviceStateChange(f OnDeviceStateChangeFunc)
}

func DefaultManager

func DefaultManager(opts ...ManagerOption) Manager

type ManagerConfig

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

type ManagerOption

type ManagerOption func(cfg *ManagerConfig)

func WithContext

func WithContext(ctx context.Context) ManagerOption

func WithLogger

func WithLogger(l logging.LeveledLogger) ManagerOption

type Observation

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

type ObserveFunc

type ObserveFunc func(d *Device, p node.Path, notify []node.Node)

type ObserveObjectFunc

type ObserveObjectFunc func(d *Device, p node.Path, notify *node.Object)

type ObserveResourceFunc

type ObserveResourceFunc func(d *Device, p node.Path, notify *node.Resource)

type Observer

type Observer interface {
	ObserveSync(p node.Path, onMsg ObserveFunc) error
	Observe(p node.Path, onMsg ObserveFunc) error
	ObserveObject(p node.Path, onMsg ObserveObjectFunc) error
	ObserveResource(p node.Path, onMsg ObserveResourceFunc) error
	CancelObserve(p node.Path) error
}

type OnDeviceStateChangeFunc

type OnDeviceStateChangeFunc func(e DeviceEvent, m Manager)

OnDeviceStateChangeFunc call when a device state change events are fire in order and please do not block in this callback

type RegisterRequest

type RegisterRequest struct {
	Ep          string
	Lifetime    int
	Version     string
	BindingMode Binding
	Queue       bool
	SmsNumber   *string
}

func NewRegisterRequest

func NewRegisterRequest(queries []string) (req *RegisterRequest, err error)

type UpdateRequest

type UpdateRequest struct {
	Lifetime    *int
	BindingMode *Binding
	SmsNumber   *string
}

func NewUpdateRequest

func NewUpdateRequest(queries []string) (req *UpdateRequest, err error)

Jump to

Keyboard shortcuts

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