Run the Example
Project Content
The Demo example can be found in examples/serial-lte-modem/gurux-dlms
folder inside the project on Acklio's GitLab repository.
It contains two sub-folders.
Folder | Description |
---|---|
cloud | The Python source files for the DLMS application, including the Gurux component to simulate the Head End System (HES) |
device | The Python source files for the device, i.e. the code to deploy on the PC connected to the AT Modem board, which includes the Tun controller and the Gurux component to simulate the DLMS server. |
Dependencies
SLM Firmware & nRF Connect SDK
The UDP client depends on the Serial LTE Modem (SLM) that integrates Acklio FullSDK.
The Demo example has a dependency with Nordic Semiconductor nRF Connect SDK.
The resources on Acklio GitLab Repository are available here https://gitlab.acklio.cloud/acklio-opensource/sdk-nrf.
This includes:
- A link to nRF Connect SDK repository on GitHub
- Information to build and flash the AT Modem "Serial LTE Modem"
- The list of SCHC AT Commands that come in addition to the SLM AT Commands
Gurux
The UDP Client also depends on the Gurux DLMS/COSEM protocol component. This component has its own requirements (Java and Maven).
Resource | Link |
---|---|
Gurux Official Website | https://www.gurux.fi/Gurux.DLMS |
Gurux Respository on GitHub | https://github.com/gurux |
Python
The Demo requires Python 3 to run.
Run the Demo Example
Cloud Side
The Cloud application must run on the same machine as the VPN agent.
Run the following command in cloud/dlms-python-client
in order to install the dependencies of the DLMS client.
./setup.sh
The Cloud application requires an IPv6 address to start. To assign it to one of the network interfaces on your machine, run the following sudo
command:
sudo ip -6 address add <app_ipv6_addr> dev <network_interface>
where <network_interface>
is the name of your network interface.
Do not use the loopback interface for binding the application.
Then, when all the device side configuration is done, run the Cloud application with the following command:
env DLMS_SERVER_ADDRESS=<dev_ipv6_addr> DLMS_SERVER_PORT=4063 DLMS_CLIENT_ADDRESS=<app_ipv6_addr> DLMS_CLIENT_PORT=<app_port> DLMS_READ_TIMEOUT=<timeout> DLMS_SESSION_INTERVAL=<interval> python3 main.py
Where:
DLMS_SERVER_ADDRESS
is the IPv6 address of the device.DLMS_SERVER_PORT
is the port that the device listens (it should always be4063
).DLMS_CLIENT_ADDRESS
is the IPv6 address of the Cloud application.DLMS_CLIENT_PORT
is the port that the Cloud application listens.DLMS_READ_TIMEOUT
is the delay (in milliseconds) during which the application will wait for a response before sending the next request.DLMS_SESSION_INTERVAL
is the delay (in seconds) between two DLMS sessions.
Device Side
The process starts with the TUN controller. Go to the "device" folder on the Demo repository and run the tun_script.sh
script by using the following command:
sudo ./tun_script.sh <tun_name> <dev_ipv6> <app_ipv6_prefix>/64
Where:
<tun_name>
is the name of the TUN interface to create.<dev_ipv6>
is the IPv6 address of the device, as configured in IPCore.<app_ipv6_prefix>
is the prefix of the IPv6 address of the Cloud application, as configured in Acklio IPCore.
The process continues with the build of the DTLS server. Go to "gurux" subfolder and run the following command:
mvn package
Now start the DLMS server. Connect the board, then run the following command:
java -jar target/gurux.dlms.server-1.jar
Finally, bind the TUN interface with the AT Modem by running the following command in the "device" directory.
python3 -m tun_app --tun-name <tun_name> --apn <apn> --l2-ip <remote_ip> --l2-port <remote_port> --template <template_file> --template-params <template_param_file> --psk-id <psk_id> --psk <psk_value>
where:
<tun_name>
is the name of the TUN interface that the device will listen<apn>
is the Access Point Name to use (m2m.public.nl
with iotcreators SIM cards)<remote_ip>
is the IP of Acklio IPCore connector<remote_port>
is the listening port of Acklio IPCore connector<template_file>
is the file containing the CBOR compression template (usually namedcompression_rules.bin
)<template_param_file
is the file containing the list of template parameters defined in the device profile. There are the following recommendations:- The parameters must comply with the format
<index2>,<value2>
... - The UDP port must be set in hexadecimal
- The values must all be written as ASCII HEX
<psk_id>
is the ID of the PSK used to establish the DTLS connection<psk_value>
is the value of the PSK used to establish the DTLS connection
- The parameters must comply with the format
See the Template Parameters in the Create a Device Profile page for more information.
Due to the NB-IoT operator NAT constraints, an uplink must be be sent in order to be able to send a downlink and start the DLMS session.
There is currently a 3-seconds window after the reception of the uplink on server side to initiate the DLMS session.
Here is the recommended command to run from the device side in order to be able to open a downlink window:
echo "+++" | nc -6u -s <template_device_ipv6> -p <dummy_port> <template_app_ip> <dummy_port>
where:
<template_device_ipv6>
is the IPv6 address of the device, as configured in IPCore<template_app_ip>
is the IPv6 address of the Cloud application, as configured in Acklio IPCore<dummy_port>
only the IPs matter as they are what determines which interface will be the destination of the packets
As soon as the uplink is seen arriving on the server side, then the python command can be launched and the DLMS session will start.