Minimalist LwM2M Client
a minimal LwM2M client which performe the following operations:
Client registrationfromRegisterinterfaceDiscoverfromDev Mang & Serv EnabinterfaceReadfromDev Mang & Serv EnabinterfaceSendfromInformation Reportinginterface
Installation
npm install
Test
npm test
Execution
npx tsx src/index.ts
Usage
- Create a device in coiote using No-Sec security mode
- Update value of
deviceNamewith the name of the device just created in
Coiote.
deviceName - Runs execution command
Description
After the execution is initialized, the device send a register operation to the
LwM2M server and wait for the response. If the server accept the registratrion
request, the client open a socket connection to hear about Discover and Read
operation. After that, the device wait 10 seconds and onces the time is expired,
the device trigger a send operation to update the value of resource /3/0/0.
Client Registration from Register interface
This action is executed by the LwM2M client, in this case this device.
Details
- host:
eu.iot.avsystem.cloud - port:
5683 - method:
POST - pathname:
/rd - query:
ep=xxxx<=xxxx&lwm2m=xxxx&b=xxxx, where:epis the name of the deviceltis the lifetime of the opening conenctionlwm2mis the version of the protocol suported by the devicebstands for biding mode
- payload:
</>;ct=110,112,11543;hb,<1/0>, <3/0>, where:ctstands for content type110is the id of SenML JSON112is the id of SenML CBOR11543is the id of LwM2M JSON
If request is successful, it returns a port number.
Discover from Dev Mang & Serv Enab interface
This action is triggered by the server, in this case Coiote, and the client
should listen from the port returned in the Client Registration operation in
order to receive the request.
Discover from Dev Mang & Serv Enab interface
This action is triggered by the server, in this case Coiote, and the client
should listen from the port returned in the Client Registration operation in
order to receive the request.
Details
- port: the one returned in Client Registration operation from Register
interface - content-format: 'application/vnd.oma.lwm2m+json'
- payload:
{ bn: '/3/0/', e: [ { n: '0/0', sv: 'Nordic' }, { n: '0/1', sv: '00010' }, { n: '0/2', sv: '00000',}, // .... ] }
Send from Information Reporting interface
This action is executed by the LwM2M client, in this case this device.
Details
- host:
eu.iot.avsystem.cloud - port:
5683 - method:
POST - pathname:
/dp - content-format:
application/senml+cbor&application/senml+json - payload:
// for application/senml+cbor'
81 a2 00 66 2f 33 2f 30 2f 30 03 6f 6e 65 77 4d 61 6e 75 66 61 63 74 75 72 65 72
// { 0: '/3/0/0', 3: 'newManufacturer' }or
// for application/senml+json
[{ 'n': '/3/0/0', 'vs': newManufacturer }]Links
- Code: send.ts
- Documentation:
Information Reporting Interface
,
Send Operation, pag 61