All Products
Search
Document Center

IoT Platform:Messaging

Last Updated:Nov 29, 2023

You can use the data forwarding feature of the rules engine in IoT Platform to send messages of JT/T 808 gateway devices to your servers. The messages are related to device registration, device deregistration, and data submission. Advanced Message Queuing Protocol (AMQP) server-side subscriptions are used to send data submission messages to your servers. This topic describes how to use the rules engine to forward messages. This topic also provides instructions on the required topics and data types.

Usage notes

When you configure data forwarding rules, take note of the following items:

  • You can use only the new version of the data forwarding feature to configure data forwarding rules for gateway devices. For more information, see Configure a data forwarding parser.

  • Devices that are added to JT/T 808 cloud gateways cannot subscribe to topics. You cannot forward data of JT/T 808 cloud gateway devices to a topic.

  • If you want to use data forwarding for JT/T 808 cloud gateway devices, you can add topics of the following types as the data source: Custom, Device Status Change Notification, and Device Changes Throughout Lifecycle. If you want to add a custom topic as the data source, you must specify the manufacturer ID, device model, and device ID in the topic name. For more information, see Create a data source.

  • You can use server-side subscriptions to push data of only the Device Upstream Notification, Device Status Change Notification, and Device Changes Throughout Lifecycle types. For more information, see Configure an AMQP server-side subscription.

Device registration

Topic: /sys/${productKey}/${deviceName}/device/identity/register.

payload: {
    "createTime": 1669968170000,
    "deviceId": "device05",
    "deviceModel": "model1",
    "deviceName": "manufactor_model1_device05",
    "instanceId": "iotx-o****",
    "iotId": "PkhDL********00101",
    "licensePlateColour": "1",
    "licensePlateNumber": "Zhe A****",
    "manufacturer": "manufactor",
    "productKey": "a16h****",
    "status": "register",
    "tenantId": "58CAC7******37C956"
}

Parameter

Type

Description

payload

Object

The content of the device registration message.

createTime

Long

The start time of device registration.

deviceId

String

The device ID that was registered by the user.

deviceModel

String

The device model that was registered by the user.

deviceName

String

The DeviceName. Format: ${manufacturer}_${deviceModel}_${deviceId}.

instanceId

String

The ID of the instance to which the device belongs.

iotId

String

The unique identifier of the device in IoT Platform.

licensePlateColour

String

The license plate color. The value must meet the requirements of the JT/T 808 protocol. For more information, see JT/T 808-2019.

licensePlateNumber

String

The license plate number.

manufacturer

String

The ID of the device manufacturer.

productKey

String

The unique identifier of the product to which the device belongs.

status

String

The status of the device. Set the value to register, which indicates that the device is registered.

tenantId

String

The ID of the user to which the device belongs.

Submit device status

Topic: /sys/${productKey}/${deviceName}/device/status/notify.

  • Format of data that is submitted by a device when the device goes online:

    {
        "protocol": "jt808",
        "status":"online",
        "iotId":"4z819VQHk6VSLmmBJfrf00107e****",
        "productKey":"al12345****",
        "deviceName":"deviceName1234",
        "time":"2018-08-31 15:32:28.205",
        "utcTime":"2018-08-31T07:32:28.205Z",
        "lastTime":"2018-08-31 15:32:28.195",
        "utcLastTime":"2018-08-31T07:32:28.195Z",
        "clientIp":"192.0.2.1"
    }
  • Format of data that is submitted by a device when the device goes offline:

    {
        "protocol": "jt808",
        "status":"offline",
        "iotId":"4z819VQHk6VSLmmBJfrf00107e****",
        "offlineReasonCode":427,
        "productKey":"al12345****",
        "deviceName":"deviceName1234",
        "time":"2018-08-31 15:32:28.205",
        "utcTime":"2018-08-31T07:32:28.205Z",
        "lastTime":"2018-08-31 15:32:28.195",
        "utcLastTime":"2018-08-31T07:32:28.195Z",
        "clientIp":"192.0.2.1"
    }

Parameters

Parameter

Type

Description

protocol

String

If you use a JT/T 808 cloud gateway, set the value to jt808.

status

String

The status of the device. Valid values:

  • offline

iotId

String

The unique identifier of the device in IoT Platform.

offlineReasonCode

Integer

The error code that is returned when the device goes offline. For more information, see Error codes that are related to device behaviors.

productKey

String

The unique identifier of the product to which the device belongs.

deviceName

String

The DeviceName of the device.

lastTime

String

These parameters are no longer valid.

utcLastTime

String

time

String

The time when the device was online or offline.

The returned messages are not sorted by time. You need to manually sort the messages.

For example, you received the following messages in sequence:

  1. Online time: 2018-08-31 10:02:28.195

  2. Offline time: 2018-08-31 10:01:28.195

  3. Offline time: 2018-08-31 10:03:28.195

The preceding messages indicate that the device was disconnected, reconnected, and then disconnected again.

utcTime

String

The time when the device went online or offline. The time is in the UTC format.

clientIp

String

The public IP address of the device.

Device data submission

Topic: /sys/${productKey}/${deviceName}/device/message/uplink.

payload: {
    header:{
        messageId:"",
        version:"",
        phone:"",
        serialNumber:""
    },
    body:{
        data:"dGVzdDEyMw==",
        type: 65
    }
}

Parameter

Type

Description

payload

Object

The message that is submitted by the device. The message includes the header and body parameters. The content of the message can be pass-through data, location statistics, or GPS data.

header

Object

The header that is submitted by the device.

  • messageId: the message ID.

  • version: the protocol version.

  • phone: the phone number.

  • serialNumber: the serial number of the message. Valid values: 0 to 65535. The device increases the serial number by one for each message that is submitted by the device.

The values of the messageId, version, and phone parameters must meet the requirements of the JT/T 808 protocol. For more information, see JT/T 808-2019.

body

Object

The message body that is submitted by the device.

  • data: the content of the message. The content is encoded in Base64.

  • type: the type of the pass-through message. In this example, 65 represents 0x41, which indicates that Serial Port 1 is used to pass through data.

The message body must meet the requirements of the JT/T 808 protocol. For more information, see JT/T 808-2019.

Device deregistration

Topic: /sys/${productKey}/${deviceName}/device/identity/unregister.

payload: {
    "createTime": 1669968170000,
    "deviceId": "device05",
    "deviceModel": "model1",
    "deviceName": "manufactor_model1_device05",
    "instanceId": "iotx-o****",
    "iotId": "PkhDL********00101",
    "licensePlateColour": "1",
    "licensePlateNumber": "Zhe A****",
    "manufacturer": "manufactor",
    "productKey": "a16h****",
    "status": "register",
    "tenantId": "58CAC7******37C956"
}

Parameter

Type

Description

payload

Object

The content of the device deregistration message.

createTime

Long

The start time of the device deregistration.

deviceId

String

The device ID.

deviceModel

String

The model of the device.

deviceName

String

The DeviceName. Format: ${manufacturer}_${deviceModel}_${deviceId}.

instanceId

String

The ID of the instance to which the device belongs.

iotId

String

The unique identifier of the device in IoT Platform.

licensePlateColour

String

The license plate color. The value must meet the requirements of the JT/T 808 protocol. For more information, see JT/T 808-2019.

licensePlateNumber

String

The license plate number.

manufacturer

String

The ID of the device manufacturer.

productKey

String

The unique identifier of the product to which the device belongs.

status

String

The status of the device. Set the value to unregister, which indicates that the device is deregistered.

tenantId

String

The ID of the user to which the device belongs.