Skip to main content
Version: 4.0

Run the Example

Project Content

The Demo example can be found in examples/at-modem/udp-client folder inside the project on Acklio's GitLab repository.

It contains two sub-folders:

FolderDescription
cloudThe Python source files for the server side, including the UDP server.
deviceThe Python source files for the client side, i.e. the code to deploy on the PC connected to the AT Modem board. This project folder contains the UDP client.

Run the Demo Example

Start the UDP Server

info

The UDP server must run on the same machine as the VPN agent.

The server 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 abcd::1 dev <network_interface>

where <network_interface> is the name of your network interface. You can use the VPN agent interface called tun-agent.

In examples/at-modem/udp-client folder, run the following command to start the UDP server:

python3 -m cloud -ip abcd::1 -port 22222

The UDP server is now running.

Start the UDP Client

Note: The board must be connected before starting the client application

Run the following command:

python3 -m device -template device/template.bin -dev-eui <dev_eui> -app-eui <app_eui> -app-key <app_key> -ipv6-dev-prefix 5454:0000:0000:0000

where:

  • <dev_eui> is the device DevEUI (in hexadecimal format xx:xx:xx:xx:xx:xx:xx:xx)
  • <app_eui> is the device AppEUI (in hexadecimal format xx:xx:xx:xx:xx:xx:xx:xx)
  • <app_key> is the device AppKey (in hexadecimal format xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx)
  • 5454:0000:0000:0000 is the IPv6 prefix of the device, as configured in Acklio IPCore.

View the Logs

Example Log on UDP Server-Side

This is an example log file on the server side.

$> python3 -m cloud -ip abcd::1 -port 22222
2021-10-21 15:15:41,871 INFO starting udp server on [abcd::1]:22222
2021-10-21 15:16:13,505 INFO receive uplink packet from the device [5454::2]:33333 b'ZRQXKRGGYUUMOXSSEYEOMHJNQOSARIWFKWVUTYYAMGTYLMVHAZLIAADCIDRNONIE'
2021-10-21 15:16:18,509 INFO send downlink packet to the device [5454::2]:33333 b'ZRQXKRGGYUUMOXSSEYEOMHJNQOSARIWFKWVUTYYAMGTYLMVHAZLIAADCIDRNONIE'

Example Log on UDP Client-side

This is an example log file of packet exchange on the client side.

Comments are inserted between the lines for documentation purpose.

$> $ python3 -m device -template device/template.bin -dev-eui ff:ff:00:00:00:00:11:ee -app-eui ff:ff:00:00:00:00:11:ee -app-key ff:ff:00:00:00:00:11:ee:ff:ff:00:00:00:00:11:ee -ipv6-dev-prefix 5454:0000:0000:0000
// Check the serial connection:
2021-10-21 15:15:57,836 DEBUG request : AT+SCHC=VERSION
2021-10-21 15:15:58,337 DEBUG response : 4.0.0
// L2 AT Commands:
2021-10-21 15:15:58,337 DEBUG request : AT+DEUI=ff:ff:00:00:00:00:11:ee
2021-10-21 15:15:58,838 DEBUG response : OK
2021-10-21 15:15:58,838 DEBUG request : AT+APPEUI=ff:ff:00:00:00:00:11:ee
2021-10-21 15:15:59,339 DEBUG response : OK
2021-10-21 15:15:59,339 DEBUG request : AT+APPKEY=ff:ff:00:00:00:00:11:ee:ff:ff:00:00:00:00:11:ee
2021-10-21 15:15:59,840 DEBUG response : OK
2021-10-21 15:15:59,840 DEBUG request : AT+JOIN=C
2021-10-21 15:16:00,341 DEBUG response : OK
2021-10-21 15:16:05,941 DEBUG response : +JOINED
2021-10-21 15:16:05,941 DEBUG request : AT+DR=5
2021-10-21 15:16:06,442 DEBUG response : OK
// Uplink
// SCHC Management:
2021-10-21 15:16:06,442 DEBUG request : AT+SCHC=TPL,SET,b1008418960186010101010101818302181c8e880c040102000081410602880d080101000081410002880e140101000081440001234502880f100101000081420000028810080101000081411102881108010100008141400288121840010200008100028813184001020000810102881418400102000081020288151840010200008103028816100102000081040288171001020000810502881818100101000081420000028818191001010000814200000224b2
2021-10-21 15:16:07,267 DEBUG response : OK
2021-10-21 15:16:07,267 DEBUG request : AT+SCHC=SYNC,5000,3
2021-10-21 15:16:07,768 DEBUG response : OK
2021-10-21 15:16:08,722 DEBUG response : +SYNCOK
2021-10-21 15:16:08,722 DEBUG request : AT+SCHC=TPLPARAMS,GET,0
2021-10-21 15:16:09,223 DEBUG response : 0,5454000000000000
2021-10-21 15:16:09,223 DEBUG response : OK
2021-10-21 15:16:09,223 DEBUG request : AT+SCHC=TPLPARAMS,GET,1
2021-10-21 15:16:09,724 DEBUG response : 1,0000000000000007
2021-10-21 15:16:09,724 DEBUG response : OK
2021-10-21 15:16:09,724 DEBUG request : AT+SCHC=TPLPARAMS,GET,2
2021-10-21 15:16:10,225 DEBUG response : 2,ABCD000000000000
2021-10-21 15:16:10,225 DEBUG response : OK
2021-10-21 15:16:10,225 DEBUG request : AT+SCHC=TPLPARAMS,GET,3
2021-10-21 15:16:10,726 DEBUG response : 3,0000000000000001
2021-10-21 15:16:10,726 DEBUG response : OK
2021-10-21 15:16:10,726 DEBUG request : AT+SCHC=TPLPARAMS,GET,4
2021-10-21 15:16:11,227 DEBUG response : 4,8235
2021-10-21 15:16:11,227 DEBUG response : OK
2021-10-21 15:16:11,227 DEBUG request : AT+SCHC=TPLPARAMS,GET,5
2021-10-21 15:16:11,728 DEBUG response : 5,56CE
2021-10-21 15:16:11,728 DEBUG response : OK
// SCHC Datagram
2021-10-21 15:16:11,728 DEBUG request : AT+SCHC=SOCKET
2021-10-21 15:16:12,229 DEBUG response : 0
2021-10-21 15:16:12,229 DEBUG response : OK
2021-10-21 15:16:12,229 DEBUG request : AT+SCHC=BIND,0,5454:0000:0000:0000:0000:0000:0000:0007,33333
2021-10-21 15:16:12,729 DEBUG response : OK
2021-10-21 15:16:12,730 DEBUG request : AT+SCHC=SEND,0,ABCD:0000:0000:0000:0000:0000:0000:0001,22222,ZRQXKRGGYUUMOXSSEYEOMHJNQOSARIWFKWVUTYYAMGTYLMVHAZLIAADCIDRNONIE
2021-10-21 15:16:13,230 DEBUG response : OK
// Downlink
2021-10-21 15:16:15,480 DEBUG response : +SENDOK,0
2021-10-21 15:16:15,480 INFO waiting 60 seconds to receive a downlink
2021-10-21 15:16:47,876 DEBUG response : +RECVOK,0:5A5251584B5247475955554D4F5853534559454F4D484A4E514F5341524957464B575655545959414D4754594C4D5648415A4C49414144434944524E4F4E4945
2021-10-21 15:16:47,876 INFO receive downlink packet, payload +RECVOK,0:5A5251584B5247475955554D4F5853534559454F4D484A4E514F5341524957464B575655545959414D4754594C4D5648415A4C49414144434944524E4F4E4945