English
PTL-D01-IoT Terminal Application Layer General Protocol V1.3
1. Protocol Description
The purpose of this protocol is to establish an application layer communication standard for IoT terminals. The design of this protocol primarily considers future compatibility and scalability. The port rules and protocol specifications mentioned below may not all be used in a single project, but reserving the extension space and fields of the protocol reduces compatibility issues caused by a lack of specifications in the future.
2. Related Terms
2.1 Data Transfer Unit (DTU)
Data Transfer Unit (hereinafter referred to as DTU) refers to a device used for data forwarding. In this protocol, it refers to a device that reads water and electricity meters and other sensor data via RS-485 and then forwards it through a wireless network.
2.2 Terminal Device
Refers to the end collection device, such as electricity meters and water meters, which are all terminal devices. Some sensors come with wireless transmission functions, in which case the sensor has the attributes of a collection device.
2.3 Collection Device
A collection device refers to a device that communicates with a base station or gateway for data, such as a DTU. The DTU communicates with terminal devices to obtain sensor data from them and communicates with the platform through a wireless network.
2.4 Multi-Application Platform (MAP)
Multi-Application Platform (hereinafter referred to as MAP) communicates with the core network to achieve business layer data management, device management, parameter configuration, device firmware upgrades, and other functions.
2.5 Unconfirm Data Packet and Confirm Data Packet
LoRaWAN network layer concept. Both unconfirm and confirm data packets have a retransmission mechanism. When sending a confirm data packet, if the node does not receive an ACK from the server, it considers the transmission failed and retransmits. When the node receives an ACK, it considers the transmission successful. Unconfirm data packets do not require ACK confirmation. Both confirm and unconfirm data packets can set the number of retransmissions.
2.6 Data Uplink and Data Downlink
Data uplink refers to data sent from a terminal device or collection device to the MAP platform.
Data downlink refers to data sent from the MAP platform to a terminal device or collection device.
2.7 Port
LoRaWAN network layer concept. Each LoRaWAN data packet carries 1 byte of port attribute. Ports 0, 200-255 are reserved ports.
2.8 Manufacturer ID
Each vendor in the network has a unique ID. Each device has a unique serial number, which includes the manufacturer ID.
2.9 Device Model
The corresponding model of the collection device or terminal device.
2.10 Hardware Version Number
Refers to the hardware version number of the collection device or terminal device. When upgrading the device, it must correspond to the appropriate hardware version.
2.11 Operating System Version Number
Operating System Version Number (hereinafter referred to as OS Version Number) refers to the version number of the operating system of the embedded device, mainly used for device upgrade control.
2.12 Software Version Number
Software Version Number refers to the version number of the software in the embedded device. In this protocol, it refers to the software version number of the DTU.
3. LoRaWAN Network Parameter Configuration
When a terminal or DTU uses the LoRaWAN network as a communication method, it must meet the following network parameter requirements:
3.1 Port Allocation
LoRaWAN has 1-200 available application layer ports. This protocol ensures data type segmentation through ports and reserves its extensibility.
| Port Number | Function Description |
|---|---|
| 11-20 (Uplink data, can be selected according to different data types, default is 11) | Regular data reporting port |
| 21-30 (Default 21) | Encrypted data reporting port |
| 31-40 (Uplink data, default 31) | Threshold trigger port |
| 41-50 (Default 41) | Threshold trigger encrypted reporting port |
| 51 (Uplink + Downlink data) | Transparent transmission mode port |
| 61 (Uplink data) | DTU heartbeat reporting port |
| 71 (Uplink + Downlink data) | Parameter configuration and control port |
| 81 (Uplink + Downlink) | Firmware upgrade port |
3.2 ADR Function
LoRaWAN nodes have an ADR function, which can adjust the communication rate according to the actual network environment to maximize network utilization. This protocol standard requires the node side to enable the local ADR function to automatically adjust the rate.
3.3 Time Synchronization Function
LoRaWAN has the function of synchronizing time with the Server side. This protocol requires node devices to achieve a local time deviation of <5 seconds/day. Time synchronization can use the LoRaWAN application layer standard function, or the deviceTimeReq MAC layer command can be used for time synchronization.
3.4 Data Type
For data that can tolerate packet loss, unconfirm data packets are used for uplink. For important data, confirm data packets are used.
3.5 Working Mode
For battery-powered devices, ClassA working mode is adopted. For always-on devices, ClassC working mode is adopted.
3.6 Data Uplink Method
There are three data uplink methods: active reporting, event triggering, and passive polling.
- For sensor data and heartbeat data, active reporting is performed periodically. After the device is powered on again, it actively collects and reports heartbeat data and sensor data once each, and then enters the normal collection and reporting cycle. Note that the DTU should adopt a random hash delay sending mechanism to ensure that a large number of devices do not cause congestion due to simultaneous data reporting when powered on at the same time.
- For alarm data and other non-periodic data, uplink is performed by event triggering. Events can include threshold triggers or alarm information triggers.
- For attribute information, passive polling can be performed or sent by heartbeat.
3.7 Default Parameters
- The default number of unconfirm packets sent is 1.
- The default number of retransmissions for confirm data packets is 5.
- The ADR function is enabled by default.
4. Basic Data Format
4.1 Basic Format Definition
| Version Identifier | Control Word | Data Identifier | Data |
|---|---|---|---|
| 1 byte | 1 byte | 1 byte | n byte |
4.1.1 Version Identifier
The version identifier is 1 byte long and defines the communication protocol version.
| bit 7 | 6:4 | 3:0 |
|---|---|---|
| Description | Version Identifier Enable | RFU |
Example: If the protocol version number is 2.0, the binary number for this field is 1000 0010, which is 0x82.
4.1.2 Control Word
The control word is 1 byte long and defines different functions of the message.
| bit 7 | 6 | 5 | 4 |
|---|---|---|---|
| Description | Message Source | Operation Mode | Instruction Execution Result |
Message Source: 0 message from device side (uplink), 1 message from control side (downlink).
Operation Mode: 0 control side reads device data, 1 control side writes data to device.
Instruction Execution Result: 0 instruction execution failed, 1 instruction execution successful.
Data Response Type: 0 no response data, 1 has response data.
Control Word Function: Used as industry identifier.
4.1.3 Data Identifier
The data identifier is 1 byte long and is used to identify the data format of the data segment. The DTU's data identifier inherits the definition from the coal-to-electricity project. In the future, DTUs will continue to use the general format in various scenarios.
| Type | Value |
|---|---|
| Parameter | 0x01 |
| Heartbeat | 0x03 |
4.1.4 No Response Data Format
| Version Identifier | Control Word | Data Identifier | Data |
|---|---|---|---|
| 1 byte | 1 byte | 1 byte | n byte |
4.1.4 Data Format with Response
| Version Identifier | Control Word | Data Identifier | Register Start Address | Number of Operation Bytes |
|---|---|---|---|---|
| 1 byte | 1 byte | 1 byte | 1 byte | 1 byte |
4.1.5 Response Data Format
| Version Identifier | Control Word | Data Identifier | RESULT | Register Start Address | Number of Operation Bytes |
|---|---|---|---|---|---|
| 1 byte | 1 byte | 1 byte | 1 byte | 1 byte | 1 byte |
The response data is feedback to the data with response. [RESULT] is the execution result of sending data. [RESULT] = 0 means successful execution. If it is a read operation, it will carry [Start Address], [Number of Operation Bytes] and [Data] afterwards. If [RESULT] is not 0, the operation failed, [RESULT] shows the reason for failure, and [Data] content is empty. See Appendix "RESULT List" for failure reasons.
5. Parameter Modification
This chapter describes functions that only apply to ManThink LoRaWAN devices. LoRaWAN device parameters can be modified by sending commands through the LoRaWAN NS platform.
The premise for modifying device parameters through the NS platform is that the LoRaWAN device must be online, there must be a gateway nearby that can cover the device, and it must be connected to the NS platform.
For ClassA devices, the data to be modified can only be sent after an uplink data packet is received. For ClassC devices, configuration parameters can be sent through the LoRaWAN channel at any time.
5.1. Parameter Format
5.1.1. Port
Device parameter modification is done by sending data through LoRaWAN port 214. The device also replies to parameter modifications through port 214.
5.1.2. Device Reply
If the parameter modification is successful, the device will reply "[Function Code & 0x7F] 01 00" on port 214.
If the parameter modification fails, the device will reply with an error code.
If the device does not receive the sent parameters, there will be no reply message.
5.1.3. Command Format
5.1.3.1. Format Description
| Function | Example | Bytes | Description |
|---|---|---|---|
| Function Code | 0xCF | 1 | The function code for modifying frequency points is 0xC2, and the function code for modifying business parameters is |
| Control Word | 0x04 | 1 | The control word for modifying frequency points is 0x2A, and the control word for modifying business parameters is |
| Start Address | 0x3D | 1 | According to the different addresses of the parameters, refer to the specific device manual |
| Byte Length | n | 2 | 2 bytes length |
| Modification Content | n | n bytes |
5.1.3.2. Example
For example, to modify the heartbeat period:
Function Code = 0xCF, Control Word = 0x04, Start Address = 0x3D, Byte Length = 2 bytes, modification period is 08 07 (1800 minutes, refer to the specific device manual). Then the command to send is 0xCF043D020807 through port 214.
After successful modification, the device will reply 0x6F 01 00.
5.1.4. Special Command Description
The following commands are supported by ManThink devices. The commands for modifying frequency points are the same for all devices.
The heartbeat period commands SE72, RDI21, RDO21 are all supported. Other devices need to refer to their specific device manuals.
5.1.4.1. Modify Frequency Points
The method for modifying frequency points for all ManThink LoRaWAN devices is the same:
Function Code = 0xC2
Control Word = 0x2A
Its parameter addresses are as follows:
| Function | Start Address | Example | Bytes | Description |
|---|---|---|---|---|
| channelMap | 6 | 0x00FF | 2 | Bit-wise enable frequency points, default is |
| Frequency Point 1 | 8 | 0x1C083560 (decimal 470300000) | 4 | Little-endian format;Unit: Hz |
| DRRange1 | 12 | 0x52 | 1 | DR,DR5-DR2 |
| Frequency Point 2 | 13 | 0x1C0B42A1 (decimal 470500001) | 4 | Little-endian format;Unit: Hz |
| DRRange2 | 17 | 0x52 | 1 | DR,DR5-DR2 |
| Frequency Point 3 | 18 | 0x1C0E4FE2 (decimal 470700002) | 4 | Little-endian format;Unit: Hz |
| DRRange3 | 22 | 0x52 | 1 | DR,DR5-DR2 |
| Frequency Point4 | 23 | 0x1C115D23 (decimal 470900003) | 4 | Little-endian format;Unit: Hz |
| DRRange4 | 27 | 0x52 | 1 | DR,DR5-DR2 |
| Frequency Point5 | 28 | 0x1C146A60 (decimal 471100000) | 4 | Little-endian format;Unit: Hz |
| DRRange5 | 32 | 0x52 | 1 | DR,DR5-DR2 |
| Frequency Point** **6 | 33 | 0x1C1777A1 (decimal 471300001) | 4 | Little-endian format;Unit: Hz |
| DRRange6 | 37 | 0x52 | 1 | DR,DR5-DR2 |
| Frequency Point 7 | 38 | 0x1C1A84E2 (decimal 471500002) | 4 | Little-endian format;Unit: Hz |
| DRRange7 | 42 | 0x52 | 1 | DR,DR5-DR2 |
| Frequency Point 8 | 43 | 0x1C1D9223 (decimal 471700003) | 4 | Little-endian format;Unit: Hz |
| DRRange8 | 47 | 0x52 | 1 | DR,DR5-DR2 |
As above, if you want to modify the values of 8 frequency points, send the command:
C2 2A 08 28 60 35 08 1C 52 A1 42 0B 1C 52 E2 4F 0E 1C 52 23 5D 11 1C 52 60 6A 14 1C 52 A1 77 17 1C 52 E2 84 1A 1C 52 23 92 1D 1C 52
- Successful configuration will reply 0x620100.
5.1.4.2. Device Reset
Some parameter modifications require a device reset to take effect.
Function Code = 0xCF
Control Word = 0x03
Start Address = 0x09
Byte Length = 0x01
Content to write is 0x01
Sending 0xCF 03 09 01 01 through port 214 will reset the device.
Successful reset will reply 0x6F0100.
5.1.4.3. Heartbeat Period
Function Code = 0xCF
Control Word = 0x04
Start Address = 0x3A
Byte Length = 0x02, 2 bytes little-endian mode, unit is minutes
For example, to modify the period to 1800 minutes = 0x0708, the byte content should be sent as 0x0807. The command content to send should be 0xCF043A020807.
Modifying the heartbeat period separately requires a device reset to take effect.
Successful sending will reply 0x6F0100.
6. Transparent Data
Transparent data description:
- DTU does not process data, it is completely forwarded to the platform or terminal.
- Port number = 51
- Sent as unconfirm packet.
7. Contact Us
Website: www.manthink.cn
Email: info@manthink.cn
Phone: +86-15810684257