Trb255 fw 07.08.02

Hello,
i’ve seen that with the latest FW it wa sintroduced the possibility to set the message type to JSON in the modbus mqtt gateway.
This should give the possibility to send mqtt commands to the TRB in JSON, but what is the correct syntax or formatting of the JSON command?

Thank you
image

Hello,
This information is currently in the process of being updated on Teltonika Networks Wiki. I think it will be available soon. For MQTT JSON format is like this:Read uptime from Modbus TCP Server (using tcp)

Request:
{
“cookie”: 65432,
“type”: 0,
“host”: “192.168.1.1”,
“port”: 502,
“timeout”: 1,
“server_id”: 1,
“function”: 3,
“register_number”: 2,
“register_count”: 2
}
Response:
{
“cookie”: 65432,
“success”: true,
“data”: [0, 5590]
}

Read uptime from Modbus RTUServer (using serial)

Request:
{
“cookie”: 65432,
“type”: 1,
“device_id”: “my_serial_device”,
“timeout”: 1,
“server_id”: 1,
“function”: 3,
“register_number”: 2,
“register_count”: 2
}
Response:
{
“cookie”: 65432,
“success”: true,
“data”: [0, 5590]
}

Read coils from server

Request:
{
“cookie”: 65432,
“type”: 0,
“host”: “192.168.1.1”,
“port”: 502,
“timeout”: 1,
“server_id”: 1,
“function”: 1,
“coil_number”: 2,
“coil_count”: 2
}
Response:
{
“cookie”: 65432,
“success”: true,
“data”: [0, 1]
}

Write multiple registers to server

Request:
{
“cookie”: 65432,
“type”: 0,
“host”: “192.168.1.1”,
“port”: 502,
“timeout”: 1,
“server_id”: 1,
“function”: 16,
“register_number”: 2,
“values”: [1, 2, 3]
}
Response:
{
“cookie”: 65432,
“success”: true
}

Thanks a lot AndriiL!

Just another question.
If i try to read the device uptime as in you example i get the following:
{
“cookie” : 0,
“success” : true,
“data” : [ 15, -21686 ]
}
How should i interpreter the 2 values?

thanks in advance

Hello, here you need to convert the value to another register.
link to Interpreting the response: RUT955 Monitoring via Modbus - Teltonika Networks Wiki.

Hi @PiM,

the second value is interpreted as a signed 16bit-integer, that means if its
value is negative then you have to add 65536 to the number.

In your example the uptime is
15*65536 + (-21686+65536) = 983040 + 43850 = 1026890s or
(roughly) 11 days 21 hours and 15 minutes.

Regards
Timelapse Admin

Thank you!