client

package
v0.64.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Reference to https://datatracker.ietf.org/doc/html/rfc6690 unused for now

Index

Constants

View Source
const (
	EnableObserveAction  uint32 = 0
	DisableObserveAction uint32 = 1
)
View Source
const (
	ObjectPathDelimiter = "/"
	ObjectRoot          = "/"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	Config
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, config Config) (*Client, error)

func (*Client) AddObject

func (c *Client) AddObject(object Object)

func (*Client) CleanUp

func (c *Client) CleanUp()

func (*Client) Object

func (c *Client) Object() Object

func (*Client) Ping

func (c *Client) Ping() error

func (*Client) Start

func (c *Client) Start() error

type Config

type Config struct {
	EndpointName    string
	EndpointUrl     string
	DeviceShifuHost string
	Settings        v1alpha1.LwM2MSetting
}
type Link struct {
	ResourcePath string            // ResourcePath is the path to the resource.
	Attributes   map[string]string // Attributes are the attributes of the resource link.
}

Link represents a single resource link with its attributes in CoRE Link Format.

func NewLink(resourcePath string, attributes map[string]string) *Link

NewLink creates a new Link with the given resource path and attributes.

func (*Link) String

func (l *Link) String() string

String formats the Link into a CoRE Link Format string. example: </>;rt="oma.lwm2m",</1/0>;rt="oma.lwm2m",</1/1>;rt="oma.lwm2m"

type Object

type Object struct {
	Id    string
	Child map[string]Object
	ObjectAPI
}

func NewObject

func NewObject(Id string, data ObjectAPI) *Object

func (*Object) AddGroup

func (o *Object) AddGroup(group Object)

func (*Object) AddObject

func (o *Object) AddObject(path string, childObject ObjectAPI)

AddObject adds a child Object to target path input: path is the path of the child object. example: /1/0 input: childObject is the child object to be added

func (*Object) GetAllChildPaths

func (o *Object) GetAllChildPaths() []string

GetAllChildPaths returns all the child paths of the object. example: [/1/0, /1/1]

func (Object) GetChildObject

func (o Object) GetChildObject(path string) *Object

GetChildObject returns the child object at the given path if it exists.

func (*Object) GetCoRELinkString

func (o *Object) GetCoRELinkString() string

GetCoRELinkString returns the CoRE Link Format string for the object and its children. Reference to https://datatracker.ietf.org/doc/html/rfc6690 example: </>;rt="oma.lwm2m";ct="11543",</1/0>,</1/1>

func (Object) ReadAll

func (o Object) ReadAll(baseName string) (Resource, error)

ReadAll reads all the data from the object and its children.

type ObjectAPI

type ObjectAPI interface {
	Read() (interface{}, error)
	Write(interface{}) error
	Execute() error
}

type ObjectData

type ObjectData struct {
	ParameterName *string  `json:"n,omitempty"`
	FloatValue    *float64 `json:"v,omitempty"`
	StringValue   *string  `json:"sv,omitempty"`
	// Pointer to avoid marshal false value
	BoolValue *bool `json:"bv,omitempty"`
}

type QueryParams

type QueryParams string
const (
	QueryParamsEndpointName QueryParams = "ep"
	QueryParamslifeTime     QueryParams = "lt"
	QueryParamsLwM2MVersion QueryParams = "lwm2m"
	QueryParamsBindingMode  QueryParams = "b"
)

type Resource

type Resource struct {
	BaseName      string       `json:"bn"`
	ResourceArray []ObjectData `json:"e"`
}

func (*Resource) ReadAsJSON

func (r *Resource) ReadAsJSON() string

type Task

type Task struct {
	Ticker     *time.Ticker
	CancelFunc context.CancelFunc
	// contains filtered or unexported fields
}

type TaskManager

type TaskManager struct {
	Tasks map[string]*Task
	Lock  sync.Mutex
	// contains filtered or unexported fields
}

func NewTaskManager

func NewTaskManager(ctx context.Context) *TaskManager

func (*TaskManager) AddTask

func (m *TaskManager) AddTask(id string, interval time.Duration, fn func())

AddTask adds a new task to the task manager. The task will be executed every interval and run the given function and assign the task to the given id.

func (*TaskManager) CancelAllTasks

func (m *TaskManager) CancelAllTasks()

CancelAllTasks cancels all the tasks in the task manager.

func (*TaskManager) CancelTask

func (m *TaskManager) CancelTask(id string)

CancelTask cancels the task with the given id.

func (*TaskManager) ResetTask

func (m *TaskManager) ResetTask(id string)

reset the task ticker for the given id

Jump to

Keyboard shortcuts

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