Forwarding format
What your ThingsBoard, MQTT broker, AWS IoT Core or Azure IoT Hub receives, and how to decode it.
Message format
For every message a device uploads, CeresGate forwards one message to the destination assigned to that device. All four destination types receive the same content, this JSON:
{"IMSI": "001013453258396", "Payload": "7b226c72223a205b2230303330383637642c3031303330343061373031336230663462342c2d36312c3130222c20302c20315d7d"}
| Field | Description |
|---|---|
IMSI | The IMSI of the device that uploaded the data, as a 15-digit string. |
Payload | What the device uploaded, as a hexadecimal string (two characters per byte). CeresGate neither decodes nor changes it. Hex is only an encoding, not encryption. |
The Payload above decodes to {"lr": ["0030867d,0103040a7013b0f4b4,-61,10", 0, 1]}. Its format is up to your device: it may be JSON, plain text or binary data.
How each destination receives it
| Destination | Delivery | Counted as success |
|---|---|---|
| ThingsBoard | HTTP POST to the adapter's httpurl, with Content-Type: application/json and the adapter's username and password as headers; the body is the JSON above | An HTTP 200 response |
| MQTT Broker | Published to the adapter's uplinktopic with its QoS, not retained (retain = false) | The broker acknowledges it |
| AWS IoT Core | Published to the adapter's uplinktopic with its QoS | IoT Core acknowledges it |
| Azure IoT Hub | Published over MQTT to the adapter's uplinktopic (usually devices/<Device ID>/messages/events/) with its QoS | IoT Hub acknowledges it |
Decoding the payload
Node.js:
const message = JSON.parse(body);
const text = Buffer.from(message.Payload, "hex").toString("utf8");
Python:
import json
message = json.loads(body)
text = bytes.fromhex(message["Payload"]).decode("utf-8")
For binary data, use the decoded bytes directly rather than turning them into text.
Handle unexpected content on your side
CeresGate forwards whatever your device sends, as it is. If your receiving side (such as a ThingsBoard data converter) assumes the content is always JSON, a plain-text test message from a device (for example hello udp :0, hex 68656c6c6f20756470203a30) makes the converter fail, the destination answers with an error, and the forwarding log shows "failed" with the HTTP status code (for example 500). Check before parsing, for example (a sketch for a JavaScript converter such as ThingsBoard's):
function hexToString(hex) {
var text = "";
for (var i = 0; i < hex.length; i += 2) {
text += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
}
return text;
}
var text = hexToString(message.Payload);
var values;
try {
values = JSON.parse(text); // the device sent JSON
} catch (e) {
values = { raw: text }; // not JSON: keep the text instead of failing
}
The hexToString above is for ASCII content; for text with multi-byte characters, use your platform's UTF-8 decoding instead.
Delivery rules
- Best effort: each message is forwarded once and not retried if it fails. Every result is recorded in the portal's forwarding logs.
- When nothing is forwarded: while the account is suspended, after a POC period has ended, or when the device has no adapter, data is not forwarded, but it is still logged with the reason.
- Retention: forwarding logs, including the forwarded content, are kept for 7 days and then deleted automatically. Keep the data you need in your own systems.