Documentation
¶
Index ¶
- Variables
- func CloseConn(cc inactivity.Conn)
- func GetLifetime(ctx context.Context) *time.Duration
- func WithLifetime(ctx context.Context, lifetime time.Duration) context.Context
- type Binding
- type Device
- func (d *Device) CancelObserve(p node.Path) error
- func (d *Device) Close()
- func (d *Device) Create(ctx context.Context, p node.Path, val *node.ObjectInstance) error
- func (d *Device) Delete(ctx context.Context, p node.Path) error
- func (d *Device) Discover(ctx context.Context, p node.Path) ([]*encoding.CoreLink, error)
- func (d *Device) Execute(ctx context.Context, p node.Path, arguments string) error
- func (d *Device) HasObject(id uint16) bool
- func (d *Device) HasObjectInstance(id, iid uint16) bool
- func (d *Device) HasObjectWithInstance(id uint16) bool
- func (d *Device) Observe(p node.Path, onMsg ObserveFunc) error
- func (d *Device) ObserveObject(p node.Path, onMsg ObserveObjectFunc) error
- func (d *Device) ObserveResource(p node.Path, onMsg ObserveResourceFunc) error
- func (d *Device) ObserveSync(p node.Path, onMsg ObserveFunc) error
- func (d *Device) ParseCoreLinks(links []*encoding.CoreLink)
- func (d *Device) Read(ctx context.Context, p node.Path) ([]node.Node, error)
- func (d *Device) ReadObject(ctx context.Context, p node.Path) (*node.Object, error)
- func (d *Device) ReadResource(ctx context.Context, p node.Path) (*node.Resource, error)
- func (d *Device) String() string
- func (d *Device) Write(ctx context.Context, p node.Path, val ...node.Node) error
- func (d *Device) WriteObjectInstance(ctx context.Context, p node.Path, val *node.ObjectInstance) error
- func (d *Device) WriteResource(ctx context.Context, p node.Path, val *node.Resource) error
- type DeviceEvent
- type DeviceEventType
- type DeviceManager
- type InactivityMonitor
- type InactivityMonitorOpt
- type Manager
- type ManagerConfig
- type ManagerOption
- type Observation
- type ObserveFunc
- type ObserveObjectFunc
- type ObserveResourceFunc
- type Observer
- type OnDeviceStateChangeFunc
- type RegisterRequest
- type UpdateRequest
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)
Types ¶
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) HasObjectInstance ¶
func (*Device) HasObjectWithInstance ¶
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 (*Device) ParseCoreLinks ¶
func (*Device) ReadObject ¶
func (*Device) ReadResource ¶
func (*Device) WriteObjectInstance ¶
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 ObserveResourceFunc ¶
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 ¶
func NewUpdateRequest ¶
func NewUpdateRequest(queries []string) (req *UpdateRequest, err error)
Click to show internal directories.
Click to hide internal directories.