MQTT API

The following topics are used for read/write interaction between client and neuron.

The {node_name} in all topics refers to the actual MQTT northbound application name, which is set in the Neuron UI’s northbound application management.

Upload Data

Response

Default topic /neuron/{node_name}/upload

Body (Tags format)

  1. {
  2. "node": "modbus-tcp-2",
  3. "group": "group-1",
  4. "timestamp": 1647497389075,
  5. "tags": [
  6. {
  7. "value": 123,
  8. "name": "data1",
  9. },
  10. {
  11. "name": "data2",
  12. "error": 2014
  13. }
  14. ]
  15. }

Body (Values format)

  1. {
  2. "node": "opcua-1",
  3. "group": "group-1",
  4. "timestamp": 1650006388943,
  5. "values":
  6. {
  7. "cstr01": "hello!"
  8. },
  9. "errors":
  10. {
  11. "cstr100": 10002
  12. }
  13. }

TIP

The value is displayed only when the value is read correctly, when the value is read incorrectly, the error code is displayed, not the value.A group sends a message.

The upload topic can be set in the driver configuration form. Once set to a custom topic, the default topic will be disabled.

There are two message formats for the body. You can choose one of two different formats in the mqtt configuration form.

Heartbeat

Response

Default topic /neuron/{node_name}/heartbeat

Body

  1. {
  2. "version": "2.1.0",
  3. "timestamp": 1658134132237,
  4. "states": [
  5. {
  6. "node": "mqtt-client",
  7. "link": 2,
  8. "running": 3
  9. },
  10. {
  11. "node": "fx5u-client",
  12. "link": 2,
  13. "running": 3
  14. }
  15. ]
  16. }

The heartbeat topic can be set in the driver configuration form. Once set to a custom topic, the default topic will be disabled.

Heartbeat messages are currently set to be sent every 1 seconds by default.

Read Tags

Request

Topic /neuron/{node_name}/read/req

Body

  1. {
  2. "uuid": "bca54fe7-a2b1-43e2-a4b4-1da715d28eab",
  3. "node": "modbus-tcp-1",
  4. "group": "group-2"
  5. }
  • “uuid”: a unique identifier generated by the user, which will be carried in the response to identify the correspondence between a single request and a response;
  • “node”: the name of the requested southbound device;
  • “group”: the group name set in the requested southbound device.

Response

Topic /neuron/{node_name}/read/resp

Body

  1. {
  2. "uuid": "bca54fe7-a2b1-43e2-a4b4-1da715d28eab",
  3. "tags": [
  4. {
  5. "value": 4,
  6. "name": "data1",
  7. },
  8. {
  9. "name": "data2",
  10. "error": 2014
  11. }
  12. ]
  13. }

TIP

The value is displayed only when the value is read correctly , when the value is read incorrectly, the error code is displayed, not the value.

Write Tag

Request

Topic /neuron/{node_name}/write/req

Body

  1. {
  2. "uuid": "cd32be1b-c8b1-3257-94af-77f847b1ed3e",
  3. "node": "modbus-tcp-1",
  4. "group": "group-2",
  5. "tag": "tag1",
  6. "value": 1234
  7. }
  • “uuid”: a unique identifier generated by the user, which will be carried in the response to identify the correspondence between a single request and a response;
  • “node”: the name of the requested southbound device;
  • “group”: the group name set in the requested southbound device;
  • “tag”: the name of the target measuring point in the requested group;
  • “value”: The value to write.

Response

Topic /neuron/{node_name}/write/resp

Body

  1. {
  2. "uuid": "cd32be1b-c8b1-3257-94af-77f847b1ed3e",
  3. "error": 0
  4. }