These example protocol translators show the calls and parameters to pass to
Edge Core protocol translator API. The simple-pt-example.js
demonstrates the
basic protocol translator functionality, ie. registering, unregistering and
device operations. The pt-crypto-api-example.js
demonstrates specifically
the usage of the crypto API's, ie. certificate and public key usage, certificate renewal, asymmetric
operations and ECDH key agreement operation. The websocket connection and
JSONRPC 2.0 specification and communication is left out of the scope to
keep the examples simple.
Libraries are used to handle the websocket and JSONRPC 2.0 communication.
Please study the example code to see how to use the protocol translator JSONRPC 2.0 API and read the relevant documentation for Edge APIs from Device Management Docs.
This example management application demostrates the calls and parameters to pass to Edge core management API. The websocket connection and JSONRPC 2.0 specification and communciation is left out of the scope to keep the example simple.
This application is interactive and supports few command that can be given
to control the API. See the usage on the example application startup or
by using help()
function.
Libraries are used to handle the websocket and JSONRPC 2.0 communication.
Please study the example code to see how to use the management JSONRPC 2.0 API and read the relevant documentation for Edge APIs from Device Management Docs.
This example uses node.js v8
or higher.
Install the dependencies:
$ npm install
Dependencies are:
simple-edge-api-examples
├── es6-promisify@6.0.0
├─┬ json-rpc-ws@5.0.0
│ ├─┬ debug@3.1.0
│ │ └── ms@2.0.0
│ ├── uuid@3.2.1
│ └─┬ ws@4.1.0
│ ├── async-limiter@1.0.0
│ └── safe-buffer@5.1.2
└── repl.history@0.1.4
The list with version can be listed with:
$ npm ls
Fixed values for the example:
- Protocol translator name is
simple-pt-example
- The device name is
example-device-1
- The example device has two LwM2M objects:
3303
which is a temperature sensor and has one readable resource5700
3308
which is a set point sensor and has one writable resource5900
- Both resource values are floating point values.
- Run the Edge Core See the pre-requisites to build and run from the root README.md
- Verify that Edge device is connected to Device Management and visible from Device Management Portal
- Run this example and connect to Edge.
$ nodejs simple-pt-example.js
- Monitor the registered Edge and endpoint device from Device Management Portal.
Fixed values for the example:
- Run the Edge Core See the pre-requisites to build and run from the root README.md
- Verify that Edge device is connected to Device Management and visible from Device Management Portal
- Connect a protocol translator and some devices to Edge. For example one of the protocol translator examples provided from Edge examples.
- Run this example and connect to Edge.
$ nodejs simple-mgmt-example.js
- Use the
connect()
function provided by the interactive example to connect to the Edge Core. - After successful connection you can query devices from Edge Core with
devices()
function. - See the example application help for other functions.