Creating an LWM2M client

We begin by declaring a new field member of type Lwm2mClient (defined in the namespace Waher.Networking.Lwm2m):

private Lwm2mClient lwm2mClient = null; 

The Lwm2mClient class provides the basic LWM2M functionality described previously. When we instantiate it, we need to provide it with a client name, a reference to the CoAP endpoint that will be used for communication, and some basic LWM2M objects. We begin by providing it with the security object (0), the server object (1), the access control object (2), and the device object (3). We don't have to provide any details for the first three. We will let the bootstrap process take care of filling these with values. The device object, however, requires some parameters for us to fill in, including manufacturer, serial number, and version numbers. These values will be presented to the server and can be used to identify the type of device the client represents. Make sure to update these values so they correspond to what you're doing:

this.lwm2mClient = new Lwm2mClient("MIoT:Sensor:" + this.deviceId, 
  this.coapEndpoint, 
  new Lwm2mSecurityObject(), 
  new Lwm2mServerObject(), 
  new Lwm2mAccessControlObject(), 
  new Lwm2mDeviceObject("Waher Data AB", "SensorLwm2m", 
    this.deviceId, "1.0", "Sensor", "1.0", "1.0")); 
For the actuator, all mentions of Sensor should be replaced by Actuator.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset