Module Twin
Module Twin - Reported Properties
Thingspro Agent exposes device's up to date configurations by reported properties when it connected. The reported properties be categorize by below.
Sections of Reported Properties
No | Section | Description |
---|---|---|
1 | applications | List all installed applications on ThingsPro Edge. |
2 | httpserver | Display HTTP Server setting, and status. |
3 | sshserver | Display SSH Server setting, and status. |
4 | discovery | Show discovery service status: enable / disable. |
5 | serialconsole | Show serial console status: enable / disable. |
6 | wan | Display network interface which connect to WAN. |
7 | route | List routing priority for each network interface. |
8 | dhcpservers | List DHCP Server status and configuration. |
9 | serials | List serial port configuration. |
10 | time | Display system time zone and NTP setting. |
11 | ethernets | List Ethernet interface status and configuration. |
12 | general | List device general properties, such as CPU type, Firmware version, ThingsPro Edge version and etc. |
13 | gps | Display GPS setting. |
14 | installations | Display OTA upgrade progress and result. |
15 | wifi | Display wifi setting. |
16 | cellulars | List cellular interface status and configuration. |
Sample of Reported Properties
{
"applications": {
"list": {
"0": {
"description": "MOXA Modbus TCP Client (Master)",
"desiredState": "ready",
"displayName": "Modbus TCP Client (Master)",
"hardwares": {
"arraySize": 0
},
"health": "good",
"icon": "/app-icons/modbusmaster-tcp.png",
"id": "modbusmaster-tcp",
"name": "modbusmaster-tcp",
"state": "ready",
"version": "3.14.0-278"
},
"arraySize": 1
}
},
"httpserver": {
"certFileName": "default.crt",
"httpEnable": true,
"httpPort": 80,
"httpsEnable": true,
"httpsPort": 8443,
"keyFileName": "default.key"
},
"sshserver": {
"enable": true,
"port": 22
},
"discovery": {
"enable": true
},
"serialconsole": {
"enable": true
},
"wan": {
"displayName": "LAN1",
"dns": {
"0": "10.128.8.5",
"arraySize": 1
},
"gateway": "10.144.51.254",
"ip": "10.144.48.128",
"name": "eth0",
"netmask": "255.255.252.0",
"type": "wan"
},
"route": {
"priorityList": {
"0": "Cellular1",
"1": "LAN1",
"arraySize": 2
},
"type": "route"
},
"dhcpservers": {
"0": {
"available": false,
"displayName": "LAN1",
"domainName": "",
"domainNameServers": {
"0": "8.8.8.8",
"1": "8.8.4.4",
"arraySize": 2
},
"enable": false,
"endIp": "192.168.3.250",
"id": 1,
"leaseTime": 3600,
"name": "eth0",
"netmask": "255.255.255.0",
"startIp": "192.168.3.200",
"status": false,
"type": "dhcpservers"
},
"arraySize": 1
},
"serials": {
"0": {
"baudRate": 9600,
"dataBits": 8,
"device": "/dev/ttyM0",
"displayName": "PORT 1",
"flowControl": "none",
"id": 1,
"mode": "rs232",
"parity": "none",
"stopBits": 1,
"type": "serials"
},
"arraySize": 1
},
"time": {
"ntp": {
"enable": false,
"interval": 7200,
"server": "pool.ntp.org"
},
"timezone": "Asia/Taipei",
"type": "time"
},
"general": {
"cpu": "ARMv7 Processor rev 2 (v7l)",
"description": "",
"deviceType": "gateway",
"firmwareVersion": "3.0",
"hostName": "Moxa",
"lastBootTime": "2019-11-13T11:42:51Z",
"lastRebootTime": "",
"memorySize": 524333056,
"modelName": "UC-8112-LX",
"serialNumber": "TAIAB1021075",
"thingsproVersion": "1.1.0-348",
"type": "general"
},
"ethernets": {
"0": {
"broadcast": "10.144.51.255",
"displayName": "LAN1",
"dns": {
"0": "10.128.8.5",
"arraySize": 1
},
"enable": true,
"enableDhcp": false,
"gateway": "10.144.51.254",
"id": 1,
"ip": "10.144.48.128",
"mac": "00:90:e8:77:06:61",
"name": "eth0",
"netmask": "255.255.252.0",
"status": "connected",
"subnet": "10.144.48.0",
"type": "ethernets",
"wan": true
},
"arraySize": 1
},
"gps": {
"interface": "",
"location": {
"lat": 14,
"lng": 15
},
"mode": "manual",
"type": "gps"
},
"installations": {
"completedTask": 0,
"id": 3,
"isDeleted": false,
"jobID": 3,
"lastState": "",
"owner": "admin",
"parameter": {
"download": false,
"install": true,
"jobID": 2
},
"state": "created"
},
"wifi": {
"0": {
"ap": {
"band": "band24",
"broadcastSsid": true,
"channel": 6,
"region": "TW",
"security": {
"mode": "wpa2",
"password": "",
"encryption": "aes"
},
"ssid": "moxa-sample-ap"
},
"enable": true,
"id": 1,
"type": "wifi",
"name": "wlan0",
"mode": "ap"
},
"arraySize": 1
},
"cellulars": {
"0": {
"autoDetect": false,
"available": true,
"capabilities": {
"sim": 1
},
"currentProfileId": 0,
"displayName": "Cellular1",
"enable": false,
"iccid": "",
"id": 1,
"imei": "",
"imsi": "",
"keepalive": {
"enable": false,
"intervalSec": 120,
"targetHost": "8.8.8.8"
},
"mac": "02:01:02:18:00:0b",
"module": "u-blox TOBY-L2 series",
"name": "usb0",
"operatorName": "",
"pinRetryRemain": 0,
"profileTimeout": 140,
"profiles": {
"0": {
"id": 1,
"init": {
"0": "sim:1",
"arraySize": 1
},
"name": "SIM1",
"pdpContext": {
"apn": "internet",
"auth": {
"password": "",
"protocol": "none",
"username": ""
},
"id": 1,
"static": true,
"type": "ipv4"
},
"pinCode": "0000"
},
"arraySize": 1
},
"rat": "",
"status": "disconnected",
"type": "cellulars",
"wan": true
},
"arraySize": 1
}
}
Module Twin - Desired Properties
ThingsPro Agent allow you to re-configure device and turn on/off services via Desired Properties. In current version, ThingsPro Agent allow below sections to be update via Desired Properties.
Sections of Desired Properties
No | Section | Description |
---|---|---|
1 | httpserver | To enable/disable and change HTTP(s) port. |
2 | sshserver | To enable/disable and change SSH port. |
3 | discovery | To enable/disable device discovery service. |
4 | serialconsole | To enable/disable serial console port. |
5 | dhcpservers | To setup DHCP Server configuration. |
6 | serials | To setup serial port configuration. |
7 | time | To setup time zone, and enable/disable and setup NTP server. |
8 | ethernets | To setup Ethernet configuration. |
9 | general | To update host name and device description. |
10 | gps | To switch GPS mode to auto or manual. |
11 | wifi | To setup Wi-Fi AP configuration. |
12 | cellulars | To setup cellulars configuration. |
There are two keys that is commonly used in the desired properties:
- id: A device may own multiple interfaces of same kind resource, id specifies which interface is to be configured. id starts from 0.
- arraySize: Azure device twin currently does not support array, so an array is encoded to a object containing children objects and an arraySize key. This value should match the number of children objects, else the remaining objects will be discarded.
HTTP(s) Server
Update HTTP(s) Server configuration
{
"desired": {
"httpserver": {
"httpEnable": true,
"httpPort": 80,
"httpsEnable": true,
"httpsPort": 8443
}
}
}
SSH Server
Update SSH Server configuration
{
"desired": {
"sshserver": {
"enable": true,
"port": 22
}
}
}
Discovery Service
Update Discovery Service status
{
"desired": {
"discovery": {
"enable": true
}
}
}
Serial Console Port
Enable / Disable Serial Console Port
{
"desired": {
"serialconsole": {
"enable": true
}
}
}
DHCP Server
Update DHCP Server
{
"desired": {
"dhcpservers": {
"0": {
"id": 1,
"enable": true,
"startIp": "192.168.3.100",
"endIp": "192.168.3.200",
"netmask": "255.255.255.0",
"domainNameServers": {
"0": "8.8.8.8",
"arraySize": 1
},
"domainName": "example.com",
"leaseTime": 2592000
},
"arraySize": 1
}
}
}
Serial Port
Update Serial Port to rs232
{
"desired": {
"serials": {
"0": {
"id": 1,
"mode": "rs232",
"displayName": "PORT 1",
"baudRate": 115200,
"parity": "none",
"dataBits": 8,
"stopBits": 1,
"flowControl": "software"
},
"arraySize": 1
}
}
}
No | Name | Available Values |
---|---|---|
1 | mode | rs232, rs422, rs4852w, rs4854w |
2 | baudRate | 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600 |
3 | parity | none, even, space, mark |
4 | dataBits | 5,6,7,8 |
5 | stopBits | 1,2,1.5 |
6 | flowControl | none, hardware, software |
Time Service
Update NTP Settings
{
"desired": {
"time": {
"ntp": {
"enable": true,
"interval": 6000,
"server": "tock.stdtime.gov.tw"
}
}
}
}Update Time zone
{
"desired": {
"time": {
"timezone": "Asia/Taipei"
}
}
}引用Timezone list can be found at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
Ethernet
Update an Ethernet Interface to Dynamic IP
{
"desired": {
"ethernets": {
"0": {
"id": 1,
"enable": true,
"enableDhcp": true,
"wan": true
},
"arraySize": 1
}
}
}Update an Ethernet Interface to Static IP
{
"desired": {
"ethernets": {
"0": {
"id": 1,
"dns": {
"0": "1.2.3.4",
"arraySize": 1
},
"enable": true,
"enableDhcp": false,
"gateway": "1.2.3.5",
"ip": "1.2.3.6",
"netmask": "255.255.255.0",
"wan": true
},
"arraySize": 1
}
}
}
General
Update device host name
{
"desired": {
"general": {
"hostName": "MyHost"
}
}
}Update device description
{
"desired": {
"general": {
"description": "MyDevice"
}
}
}
GPS
Update GPS lat, lng by manual mode
{
"desired": {
"gps":{
"mode": "manual",
"location": {
"lat": 11,
"lng": 12
}
}
}
}Update GPS by auto mode
{
"desired": {
"gps":{
"mode": "auto",
"interface": "/dev/ttyUSB0"
}
}
}
Wi-Fi
Enable / Disable Wi-Fi AP mode
{
"desired": {
"wifi": {
"0": {
"ap": {
"band": "band24",
"broadcastSsid": true,
"channel": 6,
"region": "TW",
"security": {
"mode": "wpa2",
"password": "",
"encryption": "aes"
},
"ssid": "moxa-sample-ap"
},
"enable": true,
"id": 1,
"type": "wifi",
"name": "wlan0",
"mode": "ap"
},
"arraySize": 1
}
}
}
Cellulars
- Update cellular pin code
{
"desired": {
"cellulars": {
"0": {
"autoDetect": false,
"available": true,
"capabilities": {
"sim": 1
},
"currentProfileId": 0,
"displayName": "Cellular1",
"enable": false,
"iccid": "",
"id": 1,
"imei": "358503060483337",
"imsi": "",
"keepalive": {
"enable": false,
"intervalSec": 120,
"targetHost": "8.8.8.8"
},
"mac": "02:01:02:18:00:0b",
"module": "u-blox TOBY-L2 series",
"name": "usb0",
"operatorName": "",
"pinRetryRemain": 0,
"profileTimeout": 140,
"profiles": {
"0": {
"id": 1,
"init": {
"0": "sim:1",
"arraySize": 1
},
"name": "SIM1",
"pdpContext": {
"apn": "internet",
"auth": {
"password": "",
"protocol": "none",
"username": ""
},
"id": 1,
"static": true,
"type": "ipv4"
},
"pinCode": "0000"
},
"arraySize": 1
},
"rat": "",
"signal": {
"csq": 0,
"ecio": 0,
"indicator": "",
"level": 0,
"rat": "",
"rscp": 0,
"rsrp": 0,
"rsrq": 0,
"rssi": 0,
"rxqual": 0
},
"status": "disconnected",
"type": "cellulars",
"wan": true
},
"arraySize": 1
}
}
}
Last updated on 2022-05-31 by Aeluin Chen (陳映攸)