datamodel

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package datamodel supports CPE datamodel and state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DataModel

type DataModel struct {
	Values       map[string]Parameter
	Bootstrapped bool
	// contains filtered or unexported fields
}

DataModel describes a stateful CPE datamodel.

func Load

func Load(dmPath, statePath string) (*DataModel, error)

Load looks or given datamodel and state paths and loads them.

func (*DataModel) AddEvent

func (dm *DataModel) AddEvent(evt string)

AddEvent adds a new event to be advertised during the next inform message.

func (*DataModel) AddObject

func (dm *DataModel) AddObject(name string) (int, error)

AddObject create a new object and returns the index if successful.

func (*DataModel) CanSetValue

func (dm *DataModel) CanSetValue(param Parameter) *rpc.FaultCode

CanSetValue returns a non-nil fault code if a value can't be set.

func (*DataModel) ClearEvents

func (dm *DataModel) ClearEvents()

ClearEvents removes all pending inform events.

func (*DataModel) ClearNotifyParams

func (dm *DataModel) ClearNotifyParams()

ClearNotifyParams clears all previous parameter notifications.

func (*DataModel) CommandKey

func (dm *DataModel) CommandKey() string

CommandKey returns the current command key.

func (*DataModel) ConnectionRequestURL

func (dm *DataModel) ConnectionRequestURL() Parameter

ConnectionRequestURL returns the connection request URL.

func (*DataModel) DeleteObject

func (dm *DataModel) DeleteObject(name string)

DeleteObject deletes the given object.

func (*DataModel) DeviceID

func (dm *DataModel) DeviceID() DeviceID

DeviceID returns a DeviceID populated from the datamodel.

func (*DataModel) DownUntil

func (dm *DataModel) DownUntil() time.Time

DownUntil returns the time the CPE will stop pretending to be offline.

func (*DataModel) GetAll

func (dm *DataModel) GetAll(path string) []Parameter

GetAll returns one or more parameters prefixed with the given path.

func (*DataModel) GetValue

func (dm *DataModel) GetValue(path string) Parameter

GetValue returns a parameter value with the given path. If it does not exist a placeholder is returned.

func (*DataModel) IncrRetryAttempts

func (dm *DataModel) IncrRetryAttempts()

IncrRetryAttempts increments the number of infrom attempts by one.

func (*DataModel) IsBootstrapped

func (dm *DataModel) IsBootstrapped() bool

IsBootstrapped returns true if CPE is had a successful bootstrap message exchange.

func (*DataModel) IsPeriodicInformParameter

func (dm *DataModel) IsPeriodicInformParameter(name string) bool

IsPeriodicInformParameter returns true if periodic inform is configured.

func (*DataModel) NotifyParam

func (dm *DataModel) NotifyParam(path string)

NotifyParam subscribes the ACS for the given parameter value.

func (*DataModel) NotifyParams

func (dm *DataModel) NotifyParams() []string

NotifyParams returns a list of parameters that should be included in the next inform message.

func (*DataModel) ParameterNames

func (dm *DataModel) ParameterNames(path string, nextLevel bool) []Parameter

ParameterNames returns all subparameters in the given path. If nextLevel is set to true the list of parameters goes one level deeper. nolint:nestif

func (*DataModel) PendingEvents

func (dm *DataModel) PendingEvents() []string

PendingEvents returns all events to be advertised during the next inform message.

func (*DataModel) PeriodicInformEnabled

func (dm *DataModel) PeriodicInformEnabled() bool

PeriodicInformEnabled returns true if periodic inform is enabled.

func (*DataModel) PeriodicInformInterval

func (dm *DataModel) PeriodicInformInterval() time.Duration

PeriodicInformInterval returns the value of periodic inform interval.

func (*DataModel) PeriodicInformTime

func (dm *DataModel) PeriodicInformTime() time.Time

PeriodicInformTime returns the value of periodic inform time.

func (*DataModel) ResetRetryAttempts

func (dm *DataModel) ResetRetryAttempts()

ResetRetryAttempts resets the number of infrom attempts to zero.

func (*DataModel) RetryAttempts

func (dm *DataModel) RetryAttempts() uint32

RetryAttempts returns the number of currently take attepts to inform.

func (*DataModel) SaveState

func (dm *DataModel) SaveState(stateFile string) error

SaveState saves the state to the given file.

func (*DataModel) SetBootstrapped

func (dm *DataModel) SetBootstrapped(b bool)

SetBootstrapped assigns the bootstrap flag to the given value.

func (*DataModel) SetCommandKey

func (dm *DataModel) SetCommandKey(ck string)

SetCommandKey sets the command key value.

func (*DataModel) SetConnectionRequestURL

func (dm *DataModel) SetConnectionRequestURL(val string)

SetConnectionRequestURL sets connection request URL to the given value.

func (*DataModel) SetDownUntil

func (dm *DataModel) SetDownUntil(du time.Time)

SetDownUntil sets the time until the CPE should pretend to be offline.

func (*DataModel) SetFirmwareVersion

func (dm *DataModel) SetFirmwareVersion(ver string)

SetFirmwareVersion sets the new firmware version value.

func (*DataModel) SetParameterAttribute

func (dm *DataModel) SetParameterAttribute(name string, notif int, notifChange bool, acl []string, aclChange bool)

SetParameterAttribute changes parameter value attributes.

func (*DataModel) SetParameterKey

func (dm *DataModel) SetParameterKey(val string)

SetParameterKey sets parameter key to the given value.

func (*DataModel) SetPeriodicInformInterval

func (dm *DataModel) SetPeriodicInformInterval(sec int64)

SetPeriodicInformInterval sets periodic inform interval to the given value.

func (*DataModel) SetPeriodicInformTime

func (dm *DataModel) SetPeriodicInformTime(ts time.Time)

SetPeriodicInformTime sets periodic inform time to the given value.

func (*DataModel) SetSerialNumber

func (dm *DataModel) SetSerialNumber(val string)

SetSerialNumber sets serial number to the given value.

func (*DataModel) SetValue

func (dm *DataModel) SetValue(path, val string)

SetValue sets the value of a given parameter.

func (*DataModel) SetValues

func (dm *DataModel) SetValues(params []Parameter)

SetValues saves multiple parameter values.

type DeviceID

type DeviceID struct {
	Manufacturer string
	OUI          string
	ProductClass string
	SerialNumber string
}

DeviceID contains basic CPE info.

type Parameter

type Parameter struct {
	Path         string
	Object       bool
	Writable     bool
	Type         string
	Value        string
	Notification int
	ACL          []string
}

Parameter describes a datamodel paremeter.

func (Parameter) Encode

func (p Parameter) Encode() rpc.ParameterValueEncoder

Encode converts a parameter into RPC ParameterValue structure.

Jump to

Keyboard shortcuts

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