Documentation
¶
Index ¶
- func NewClientBootstrappedEvent(args ...string) Event
- func NewClientRegUpdatedEvent(args ...string) Event
- func NewClientRegisteredEvent(args ...string) Event
- func NewClientUnregisteredEvent(args ...string) Event
- func NewRegisteredClient(server *LwM2MServer, info *RegistrationInfo, registry ObjectRegistry) RegisteredClient
- func NewServerStartedEvent(args ...string) Event
- func NewServerStoppedEvent(args ...string) Event
- type BootstrapContext
- type BootstrapServerDelegator
- type BootstrapService
- type ClientBootstrappedEvent
- type ClientRegUpdatedEvent
- type ClientRegisteredEvent
- type ClientUnregisteredEvent
- type DefaultEventObserver
- func (d *DefaultEventObserver) Bootstrapped(epName string)
- func (d *DefaultEventObserver) DeviceOperated(c core.RegisteredClient, objs []core.ObjectInstance)
- func (d *DefaultEventObserver) Registered(c core.RegisteredClient)
- func (d *DefaultEventObserver) Unregistered(c core.RegisteredClient)
- func (d *DefaultEventObserver) Updated(c core.RegisteredClient)
- type DeviceControlDelegator
- type DeviceControlService
- type GuidProvider
- type InMemoryRegInfoStore
- func (db *InMemoryRegInfoStore) Close()
- func (db *InMemoryRegInfoStore) Delete(name string)
- func (db *InMemoryRegInfoStore) Get(name string) *RegistrationInfo
- func (db *InMemoryRegInfoStore) Init()
- func (db *InMemoryRegInfoStore) Save(c *RegistrationInfo) error
- func (db *InMemoryRegInfoStore) Update(info *RegistrationInfo) error
- type LwM2MServer
- func (s *LwM2MServer) EnableBootstrapService(bootstrapService BootstrapService)
- func (s *LwM2MServer) EnableRegistrationService(registerService RegistrationService)
- func (s *LwM2MServer) EnableReportingService(reportService ReportingService)
- func (s *LwM2MServer) GetClient(name string) RegisteredClient
- func (s *LwM2MServer) Listen(et EventType, h EventHandler)
- func (s *LwM2MServer) Serve()
- func (s *LwM2MServer) Shutdown()
- type MessagerServer
- func (m *MessagerServer) BootstrapDelete(peer string, oid ObjectID, oiId InstanceID) error
- func (m *MessagerServer) BootstrapDiscover(peer string, oid ObjectID) ([]*coap.CoREResource, error)
- func (m *MessagerServer) BootstrapFinish(peer string) error
- func (m *MessagerServer) BootstrapWrite(peer string, oid ObjectID, oiId InstanceID, rid ResourceID, value Value) error
- func (m *MessagerServer) CancelObservation(peer string, oid ObjectID, oiId InstanceID, rid ResourceID, riId InstanceID) error
- func (m *MessagerServer) CancelObservationComposite(peer string, t coap.MediaType, body []byte) error
- func (m *MessagerServer) Create(peer string, oid ObjectID, value Value) error
- func (m *MessagerServer) Delete(peer string, oid ObjectID, oiId InstanceID, rid ResourceID, riId InstanceID) error
- func (m *MessagerServer) Discover(peer string, oid ObjectID, oiId InstanceID, rid ResourceID, depth int) ([]*coap.CoREResource, error)
- func (m *MessagerServer) Execute(peer string, oid ObjectID, id InstanceID, rid ResourceID, args string) error
- func (m *MessagerServer) Observe(peer string, oid ObjectID, oiId InstanceID, rid ResourceID, riId InstanceID, ...) error
- func (m *MessagerServer) ObserveComposite(peer string, t coap.MediaType, body []byte, h ObserveHandler) ([]byte, error)
- func (m *MessagerServer) Read(peer string, oid ObjectID, oiId InstanceID, rid ResourceID, riId InstanceID) ([]byte, error)
- func (m *MessagerServer) Start()
- func (m *MessagerServer) Stop()
- func (m *MessagerServer) Write(peer string, oid ObjectID, oiId InstanceID, rid ResourceID, riId InstanceID, ...) ([]byte, error)
- type Option
- func WithBindingAddress(network, addr string) Option
- func WithClientEventObserver(observer RegisteredClientObserver) Option
- func WithDTLSConfig(conf *piondtls.Config) Option
- func WithGuidProvider(provider GuidProvider) Option
- func WithObjectClassRegistry(registry core.ObjectRegistry) Option
- func WithRegistrationInfoStore(store RegInfoStore) Option
- type RedisRegInfoStore
- func (db *RedisRegInfoStore) Close()
- func (db *RedisRegInfoStore) Delete(name string)
- func (db *RedisRegInfoStore) Get(name string) *RegistrationInfo
- func (db *RedisRegInfoStore) Init()
- func (db *RedisRegInfoStore) Save(c *RegistrationInfo) error
- func (db *RedisRegInfoStore) Update(info *RegistrationInfo) error
- type RegInfoStore
- type RegisterServiceDelegator
- type RegisteredClientManager
- type RegisteredClientObserver
- type RegistrationService
- type ReportingServerDelegator
- type ReportingService
- type Server
- type StartedEvent
- type Statistics
- type StoppedEvent
- type UrnUuidProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewClientBootstrappedEvent ¶
func NewClientBootstrappedEvent(args ...string) Event
func NewClientRegUpdatedEvent ¶
func NewClientRegUpdatedEvent(args ...string) Event
func NewClientRegisteredEvent ¶
func NewClientRegisteredEvent(args ...string) Event
func NewClientUnregisteredEvent ¶
func NewClientUnregisteredEvent(args ...string) Event
func NewRegisteredClient ¶
func NewRegisteredClient(server *LwM2MServer, info *RegistrationInfo, registry ObjectRegistry) RegisteredClient
NewRegisteredClient creates a new session, using the given registration information, representing the registered client.
func NewServerStartedEvent ¶
func NewServerStartedEvent(args ...string) Event
func NewServerStoppedEvent ¶
func NewServerStoppedEvent(args ...string) Event
Types ¶
type BootstrapContext ¶
type BootstrapContext interface { Name() string Address() string Stale() bool // Read implements BootstrapRead operation // method: GET // format: TLV, LwM2M CBOR, SenML CBOR or SenML JSON // path: /{Object ID} in LwM2M 1.1 and thereafter, Object ID MUST be '1' // (Server Object) or '2' (Access Control Object) // code may be responded: // 2.05 Content // 4.00 Bad Request // 4.01 Unauthorized // 4.04 Not Found // 4.05 Method Not Allowed // 4.06 Not Acceptable Read(oid ObjectID) ([]byte, error) // Discover implements BootstrapDiscover operation // method: GET // path: /{Object ID} // code may be responded: // 2.05 Content // 4.00 Bad Request // 4.04 Not Found Discover(oid ObjectID) ([]*coap.CoREResource, error) // Write implements BootstrapWrite operation // method: PUT // path: /{Object ID} // /{Object ID}/{optional Object Instance ID} // /{Object ID}/{optional Object Instance ID}/{optional Resource ID} // code may be responded: // 2.04 Changed // 4.00 Bad Request // 4.15 Unsupported content format Write(oid ObjectID, oiId InstanceID, rid ResourceID, value Value) error // Delete implements BootstrapDelete operation // method: DELETE // path: /{Object ID}/{Object Instance ID} // code may be responded: // 2.02 Deleted // 4.00 Bad Request Delete(oid ObjectID, oiId InstanceID) error // Finish implements BootstrapFinish operation // method: POST // path: /bs // code may be responded: // 2.04 Changed // 4.00 Bad Request // 4.06 Not Acceptable Finish() error }
BootstrapContext defines context that is used for a client to do bootstrap.
The server will start a separate goroutine to run bootstrap sub procedure.
As the bootstrap process is comprised multi-stage message exchanging passes, the context provides method to respond to client when BootstrapRequest is done, and provides methods to access client resources in case needed.
type BootstrapServerDelegator ¶
type BootstrapServerDelegator struct {
// contains filtered or unexported fields
}
BootstrapServerDelegator delegates application layer logic for client bootstrap procedure at server side.
func NewBootstrapServerDelegator ¶
func NewBootstrapServerDelegator(server *LwM2MServer) *BootstrapServerDelegator
func (*BootstrapServerDelegator) OnPackRequest ¶
func (b *BootstrapServerDelegator) OnPackRequest(name string) ([]byte, error)
func (*BootstrapServerDelegator) OnRequest ¶
func (b *BootstrapServerDelegator) OnRequest(name, addr string) error
type BootstrapService ¶
type BootstrapService interface { Bootstrap(ctx BootstrapContext) error Bootstrapping(ctx BootstrapContext) error BootstrapPack(ctx BootstrapContext) ([]byte, error) }
type ClientBootstrappedEvent ¶
type ClientBootstrappedEvent struct {
*BaseEvent
}
type ClientRegUpdatedEvent ¶
type ClientRegUpdatedEvent struct {
*BaseEvent
}
type ClientRegisteredEvent ¶
type ClientRegisteredEvent struct {
*BaseEvent
}
type ClientUnregisteredEvent ¶
type ClientUnregisteredEvent struct {
*BaseEvent
}
type DefaultEventObserver ¶
type DefaultEventObserver struct { }
DefaultEventObserver implements RegisteredClientObserver and provides a dummy operation for each event.
func NewDefaultEventObserver ¶
func NewDefaultEventObserver() *DefaultEventObserver
func (*DefaultEventObserver) Bootstrapped ¶
func (d *DefaultEventObserver) Bootstrapped(epName string)
func (*DefaultEventObserver) DeviceOperated ¶
func (d *DefaultEventObserver) DeviceOperated(c core.RegisteredClient, objs []core.ObjectInstance)
func (*DefaultEventObserver) Registered ¶
func (d *DefaultEventObserver) Registered(c core.RegisteredClient)
func (*DefaultEventObserver) Unregistered ¶
func (d *DefaultEventObserver) Unregistered(c core.RegisteredClient)
func (*DefaultEventObserver) Updated ¶
func (d *DefaultEventObserver) Updated(c core.RegisteredClient)
type DeviceControlDelegator ¶
type DeviceControlDelegator struct {
// contains filtered or unexported fields
}
DeviceControlDelegator implements the server-side operations for Device Management and Service Enablement Interface.
func NewDeviceControlServerDelegator ¶
func NewDeviceControlServerDelegator(server *LwM2MServer) *DeviceControlDelegator
type DeviceControlService ¶
type DeviceControlService interface { }
type GuidProvider ¶
GuidProvider provides global uuid generation service.
func NewUrnUuidProvider ¶
func NewUrnUuidProvider() GuidProvider
type InMemoryRegInfoStore ¶
type InMemoryRegInfoStore struct {
// contains filtered or unexported fields
}
func NewInMemorySessionStore ¶
func NewInMemorySessionStore() *InMemoryRegInfoStore
func (*InMemoryRegInfoStore) Close ¶
func (db *InMemoryRegInfoStore) Close()
func (*InMemoryRegInfoStore) Delete ¶
func (db *InMemoryRegInfoStore) Delete(name string)
func (*InMemoryRegInfoStore) Get ¶
func (db *InMemoryRegInfoStore) Get(name string) *RegistrationInfo
func (*InMemoryRegInfoStore) Init ¶
func (db *InMemoryRegInfoStore) Init()
func (*InMemoryRegInfoStore) Save ¶
func (db *InMemoryRegInfoStore) Save(c *RegistrationInfo) error
func (*InMemoryRegInfoStore) Update ¶
func (db *InMemoryRegInfoStore) Update(info *RegistrationInfo) error
type LwM2MServer ¶
type LwM2MServer struct {
// contains filtered or unexported fields
}
func New ¶
func New(opts ...Option) *LwM2MServer
func (*LwM2MServer) EnableBootstrapService ¶
func (s *LwM2MServer) EnableBootstrapService(bootstrapService BootstrapService)
func (*LwM2MServer) EnableRegistrationService ¶
func (s *LwM2MServer) EnableRegistrationService(registerService RegistrationService)
func (*LwM2MServer) EnableReportingService ¶
func (s *LwM2MServer) EnableReportingService(reportService ReportingService)
func (*LwM2MServer) GetClient ¶
func (s *LwM2MServer) GetClient(name string) RegisteredClient
func (*LwM2MServer) Listen ¶
func (s *LwM2MServer) Listen(et EventType, h EventHandler)
func (*LwM2MServer) Serve ¶
func (s *LwM2MServer) Serve()
func (*LwM2MServer) Shutdown ¶
func (s *LwM2MServer) Shutdown()
Shutdown shuts down the server gracefully.
type MessagerServer ¶
MessagerServer encapsulates and hide transport layer details.
Put them together here to make it easier when replacing COAP layer later.
func NewMessager ¶
func NewMessager(s *LwM2MServer) *MessagerServer
func (*MessagerServer) BootstrapDelete ¶
func (m *MessagerServer) BootstrapDelete(peer string, oid ObjectID, oiId InstanceID) error
func (*MessagerServer) BootstrapDiscover ¶
func (m *MessagerServer) BootstrapDiscover(peer string, oid ObjectID) ([]*coap.CoREResource, error)
func (*MessagerServer) BootstrapFinish ¶
func (m *MessagerServer) BootstrapFinish(peer string) error
func (*MessagerServer) BootstrapWrite ¶
func (m *MessagerServer) BootstrapWrite(peer string, oid ObjectID, oiId InstanceID, rid ResourceID, value Value) error
func (*MessagerServer) CancelObservation ¶
func (m *MessagerServer) CancelObservation(peer string, oid ObjectID, oiId InstanceID, rid ResourceID, riId InstanceID) error
func (*MessagerServer) CancelObservationComposite ¶
func (*MessagerServer) Create ¶
func (m *MessagerServer) Create(peer string, oid ObjectID, value Value) error
func (*MessagerServer) Delete ¶
func (m *MessagerServer) Delete(peer string, oid ObjectID, oiId InstanceID, rid ResourceID, riId InstanceID) error
func (*MessagerServer) Discover ¶
func (m *MessagerServer) Discover(peer string, oid ObjectID, oiId InstanceID, rid ResourceID, depth int) ([]*coap.CoREResource, error)
func (*MessagerServer) Execute ¶
func (m *MessagerServer) Execute(peer string, oid ObjectID, id InstanceID, rid ResourceID, args string) error
func (*MessagerServer) Observe ¶
func (m *MessagerServer) Observe(peer string, oid ObjectID, oiId InstanceID, rid ResourceID, riId InstanceID, attrs NotificationAttrs, h ObserveHandler) error
func (*MessagerServer) ObserveComposite ¶
func (*MessagerServer) Read ¶
func (m *MessagerServer) Read(peer string, oid ObjectID, oiId InstanceID, rid ResourceID, riId InstanceID) ([]byte, error)
func (*MessagerServer) Start ¶
func (m *MessagerServer) Start()
func (*MessagerServer) Stop ¶
func (m *MessagerServer) Stop()
type Option ¶
type Option func(s *LwM2MServer)
func WithBindingAddress ¶
func WithClientEventObserver ¶
func WithClientEventObserver(observer RegisteredClientObserver) Option
func WithDTLSConfig ¶
func WithGuidProvider ¶
func WithGuidProvider(provider GuidProvider) Option
func WithObjectClassRegistry ¶
func WithObjectClassRegistry(registry core.ObjectRegistry) Option
func WithRegistrationInfoStore ¶
func WithRegistrationInfoStore(store RegInfoStore) Option
type RedisRegInfoStore ¶
type RedisRegInfoStore struct {
// contains filtered or unexported fields
}
func NewRedisStore ¶
func NewRedisStore(addr, pwd string) *RedisRegInfoStore
func (*RedisRegInfoStore) Close ¶
func (db *RedisRegInfoStore) Close()
func (*RedisRegInfoStore) Delete ¶
func (db *RedisRegInfoStore) Delete(name string)
func (*RedisRegInfoStore) Get ¶
func (db *RedisRegInfoStore) Get(name string) *RegistrationInfo
func (*RedisRegInfoStore) Init ¶
func (db *RedisRegInfoStore) Init()
func (*RedisRegInfoStore) Save ¶
func (db *RedisRegInfoStore) Save(c *RegistrationInfo) error
func (*RedisRegInfoStore) Update ¶
func (db *RedisRegInfoStore) Update(info *RegistrationInfo) error
type RegInfoStore ¶
type RegInfoStore interface { Init() Close() //Get returns the registration info of the client //identified by global unique name. Get(name string) *RegistrationInfo //Save saves the registration info of a client to the store. Save(info *RegistrationInfo) error //Delete deletes the registration info of a client. Delete(name string) //Update updates the registration info of a client. Update(info *RegistrationInfo) error }
RegInfoStore defines storage operations for client registration info.
type RegisterServiceDelegator ¶
type RegisterServiceDelegator struct {
// contains filtered or unexported fields
}
RegisterServiceDelegator delegates application layer logic for client registration procedure at server side.
func NewRegistrationServerDelegator ¶
func NewRegistrationServerDelegator(server *LwM2MServer) *RegisterServiceDelegator
func (*RegisterServiceDelegator) OnDeregister ¶
func (s *RegisterServiceDelegator) OnDeregister(location string)
func (*RegisterServiceDelegator) OnRegister ¶
func (s *RegisterServiceDelegator) OnRegister(info *RegistrationInfo) (string, error)
OnRegister registers a client and returns the assigned location mapping to the unique endpoint client name.
func (*RegisterServiceDelegator) OnUpdate ¶
func (s *RegisterServiceDelegator) OnUpdate(info *RegistrationInfo) error
type RegisteredClientManager ¶
type RegisteredClientManager interface { Add(info *core.RegistrationInfo) core.RegisteredClient Get(name string) core.RegisteredClient GetByAddr(addr string) core.RegisteredClient GetByLocation(location string) core.RegisteredClient Update(info *core.RegistrationInfo) error Delete(name string) DeleteByLocation(location string) Start() Stop() // Enable enables management of the registered // client identified by location. Enable(location string) // Disable disables management of the registered // client identified by location. Disable(location string) }
RegisteredClientManager manages sessions of clients, based on RegisteredClient, that are registered to this server.
func NewRegisteredClientManager ¶
func NewRegisteredClientManager(server *LwM2MServer) RegisteredClientManager
type RegisteredClientObserver ¶
type RegisteredClientObserver interface { // Bootstrapped invoked after client is bootstrapped Bootstrapped(epName string) // Registered invoked after client is registered Registered(c core.RegisteredClient) // Updated invoked after client registration info is updated Updated(c core.RegisteredClient) // Unregistered invoked after client unregistered Unregistered(c core.RegisteredClient) }
RegisteredClientObserver defines lifecycle event observers/callbacks for a LwM2M client.
type RegistrationService ¶
type RegistrationService interface { Register(info *core.RegistrationInfo) error Update(info *core.RegistrationInfo) error Unregister(info *core.RegistrationInfo) }
type ReportingServerDelegator ¶
type ReportingServerDelegator struct {
// contains filtered or unexported fields
}
func NewReportingServerDelegator ¶
func NewReportingServerDelegator(server *LwM2MServer) *ReportingServerDelegator
func (*ReportingServerDelegator) OnNotify ¶
func (r *ReportingServerDelegator) OnNotify(c core.RegisteredClient, value []byte) error
func (*ReportingServerDelegator) OnSend ¶
func (r *ReportingServerDelegator) OnSend(c core.RegisteredClient, value []byte) ([]byte, error)
type ReportingService ¶
type ReportingService interface { // Send invoked when info is received from send operation of reporting interface. Send(c core.RegisteredClient, data []byte) ([]byte, error) // Notify invoked when info is received from notify operation of reporting interface. Notify(c core.RegisteredClient, data []byte) ([]byte, error) }
type Server ¶
type Server interface { Serve() Shutdown() GetClient(name string) core.RegisteredClient Listen(et core.EventType, h core.EventHandler) }
Server defines api for application layer to use.
Procedures, initiated by the client but not terminated within the LwM2M protocol layer, will be exposed to server side applications by methods defined here, including:
Send or Notify of Information Reporting
Procedures, initiated by the server but not terminated within the LwM2M protocol layer, will be exposed to client side applications by methods defined here too:
Create/Read/Write/Execute of DeviceManagement & Service Enablement Observe of Information Reporting
EventType listeners are also supported to acquire client states including bootstrapping results, registration results etc.
type StartedEvent ¶
type StartedEvent struct {
*BaseEvent
}
type Statistics ¶
type Statistics struct {
// contains filtered or unexported fields
}
func NewStatistics ¶
func NewStatistics() *Statistics
func (*Statistics) GetRequestCount ¶
func (s *Statistics) GetRequestCount() uint64
func (*Statistics) IncrementRequestCount ¶
func (s *Statistics) IncrementRequestCount()
type StoppedEvent ¶
type StoppedEvent struct {
*BaseEvent
}
type UrnUuidProvider ¶
type UrnUuidProvider struct { }
func (*UrnUuidProvider) GetGuid ¶
func (p *UrnUuidProvider) GetGuid() string
GetGuid returns an id of format:
urn:uuid:########-####-####-####-############
func (*UrnUuidProvider) GetGuidWithHint ¶
func (p *UrnUuidProvider) GetGuidWithHint(hint string) string