MLopezJ / LwM2M-device-simulator

A LwM2M Client to perform operations on a LwM2M Server
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link
lwm2m-client

LwM2M Device Simulator

Test and Release semantic-release Renovate Mergify Status Commitizen friendly code style: prettier ESLint: TypeScript

This is a LwM2M device simulator who emulate 4 actions from a Thingy:91 running with nRF Asset Tracker v2 firmware; bootstrapping, connection, sequential updates and heartbeat.

Action Description LwM2M Interface LwM2M Operation Triggered By
Bootstrapping Used to provision essential information into the LwM2M Client to enable it to perform the "Register" operation. The Factory Bootstrap is the default mode used Bootstrap Factory Bootstrap LwM2M Client
Connection Register the device with a LwM2M server and send the value of the object registered. This action mix 3 operation from 2 different interfaces
-- Client Registration Register LwM2M Client
-- Dev Mang & Serv Enab Discover LwM2M Server
-- Dev Mang & Serv Enab Read LwM2M Server
Sequential Updates Update the value of an object, instance or resource without explicit request of the LwM2M Server Information Reporting Send LwM2M Client
Heartbeat Extend the lifetime of a registration Client Registration Update LwM2M Client

The main propose of this project is to facilitate the testing process of LwM2M Asset Tracker.

Specifications

This device uses LwM2M as a protocol and provides a command line interface for its interaction. This interface offer 7 different commands and here is one table with the operations from the LwM2M protocol implemented by each command.

Command Action Emulated LwM2M Operation LwM2M Interface Content Format
clear
register Connection
-- Client registration Register Link Format
-- Discover Dev Mang & Serv Enab LwM2M JSON
-- Read Dev Mang & Serv Enab LwM2M JSON
list
set Sequential Update Send Information Reporting SenML JSON
quit
help
heartbeat Heartbeat Update Client Registration Link Format

CLI reference

command required-param [optional param]

Options:

    List

        List values

    Format: list /[object-id]/[instance-id]/[resource-id]
    Example:
           list
           list /3
           list /3/0
           list /3/0/0
-------------------------------------------------

    Set

        Set resource value

    Format: set object-id/instance-id/resource-id  value
    Example: set /3/0/0 Nordic
-------------------------------------------------

    Register

        Execute LwM2M Client Registration interface

    Format: register
    Example: register
-------------------------------------------------

    Clear

        Clear console

    Format: clear
    Example: clear
-------------------------------------------------

    Quit

        Exit the client

    Format: quit
    Example: quit
-------------------------------------------------

    Help

        List all possible commands

    Format: help
    Example: help
-------------------------------------------------

Installation

npm install

Enviroment variables

Create a .env file in the root of the proyect with the following keys

deviceName=
port=
host=
lifetime=
lwm2mV=
biding=

Where

Test

npm test

Execution

npx tsx src/index.ts

Usage

see example to see the usage of the CLI and the expected behavior in each command.

Also you can type help in the CLI in order to get more info about commands.

Limitations

Security Mode

The device simulator does not support credentials or pre-shared keys, and the only security mode option implemented is the No-Sec, which uses the port 5683 for the comunication with the server. The implemented security mode is not recommended for production enviroments.