All Products
Search
Document Center

IoT Platform:Messaging

Last Updated:Nov 30, 2023

If you use GB/T 32960 cloud gateway devices, you can forward the messages of the devices to a user-managed server by using the data forwarding feature. The messages include device logon and verification messages, device unregistration messages, and device data submission messages. You can push messages that are submitted by devices to the server by using the Advanced Message Queuing Protocol (AMQP) subscription feature. This topic describes how to use the data forwarding feature to forward messages. This topic also provides instructions on the required topics and data types.

Usage notes

When you forward messages, take note of the following items:

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

  • You cannot subscribe to topics for GB/T 32960 cloud gateway devices. Therefore, you cannot forward the data of GB/T 32960 cloud gateway devices from a topic to another topic.

  • If you want to forward the messages of GB/T 32960 cloud gateway devices, you can add the following types of topics as a data source: Custom, Device Status Change Notification, and Device Changes Throughout Lifecycle. If you want to add a custom topic as a data source, you must specify the Vehicle Identification Number (VIN) of the vehicle in the topic name. For more information, see Create a data source.

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

Note

The parameters of a device message must conform to the GB/T 32960 protocol. For more information, see GB/T 32960-2016.

Device logon

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

{
    "header": {
        "command": 1,
        "responseFlag": 254,
        "vin": "onepart1234567891"
    },
    "body": {
        "iccid": "12345678901234567890",
        "month": 3,
        "hour": 16,
        "year": 23,
        "subSystemNumber": 2,
        "systemEncode": [
            "12345678",
            "87654321"
        ],
        "systemEncodeLength": 8,
        "day": 21,
        "serialNo": 1,
        "minute": 20,
        "second": 12
    }
}

Parameter

Type

Description

header

Object

The data of the message header.

command

Integer

The ID of the command.

responseFlag

Integer

The ID of the response.

vin

String

The VIN of the vehicle.

body

Object

The data of the message body.

iccid

String

The ICCID of the vehicle.

year

Integer

The year in which the vehicle logged on to the system.

month

Integer

The month in which the vehicle logged on to the system.

day

Integer

The day on which the vehicle logged on to the system.

hour

Integer

The hour at which the vehicle logged on to the system.

minute

Integer

The minute at which the vehicle logged on to the system.

second

Integer

The second at which the vehicle logged on to the system.

subSystemNumber

Integer

The number of sub-systems that can be charged and store electricity.

systemEncode

List

The codes of the sub-systems.

systemEncodeLength

Integer

The length of the code.

serialNo

Integer

The record number of the vehicle logon.

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": "gb32960",
        "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": "gb32960",
        "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"
    }

Parameter description

Field

Category

Description

protocol

String

If you use a GB/T 32960 cloud gateway, set the value to gb32960.

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.

{
    "header": {
        "command": 123,
        "responseFlag":1,
        "vin":""
    },
    "body": {
        "data":""
    }
}

Parameter name

Data type

Description

header

Object

The data of the message header.

command

Integer

The ID of the command.

responseFlag

Integer

The ID of the response.

vin

String

The VIN of the vehicle.

body

Object

The data of the message body. The data is encoded in Base64.

Device unregistration

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

{
    "header": {
        "command": 4,
        "responseFlag": 254,
        "vin": "onepart1234567891"
    },
    "body": {
        "month": 3,
        "hour": 16,
        "year": 23,
        "day": 21,
        "minute": 20,
        "second": 12,
        "serialNo": 1
    }
}  

Parameter name

Data type

Description

header

Object

The data of the message header.

command

Integer

The ID of the command.

responseFlag

Integer

The ID of the response.

vin

String

The VIN of the vehicle.

body

Object

The data of the message body.

year

Integer

The year in which the vehicle was unregistered.

month

Integer

The year in which the vehicle was unregistered.

day

Integer

The month in which the vehicle was unregistered.

hour

Integer

The hour at which the vehicle was unregistered.

minute

Integer

The minute at which the vehicle was unregistered.

second

Integer

The second at which the vehicle was unregistered.

serialNo

Integer

The record number of the vehicle unregistration.