This guide introduces you to a possibility to feed AllThingsTalk Cloud with sensor data over UDP protocol.
UDP is a minimal message-oriented protocol that provides best-effort sending and receiving of data between two hosts in a connectionless manner.
UDP is becoming a popular protocol for Internet of Things applications since its low overhead and energy efficiency match the needs of battery-operated connected devices and the operational deployment of LPWA networks like NB-IoT.
Send UDP packets to:
api.allthingstalk.io
on port 8891
20.61.15.37
on port 8891
Note: We strongly recommend that you implement your devices to use DNS name to send their data toward our platform, e.g, api.allthingstalk.io:8891
. Using the static IP address might be needed for clients which cannot resolve DNS, but please note that even though the above IP address is static it might change in the future.
A packet sent by the UDP client should be formatted as follows:
DeviceID NEWLINE_CHARACTER
DeviceToken NEWLINE_CHARACTER
DeviceState
NEWLINE_CHARACTER
is \n
(0x0A
). There are no spaces between Device ID, Device Token, Device State and newlines.
These can be obtained from AllThingsTalk Maker by going into device S**ettings > Authentication**.
AllThingsTalk Device State is a payload that can be encoded using JSON, CBOR and ABCL that represents a state of some or all device assets.
→ Read more about device state in Data formats
Let’s consider a device that sends a temperature t
and a daylight dl
.
Device state
{
"t": { "value": 33 },
"dl": { "value": true }
}
UDP payload
LA1Sn4yuYx16YBAABqQQnSan\nmaker:4VyRL0fr22kOm01qFyHqw3gE91MahfK1Q3zEfRg0\n{"t":{"value":33},"dl":{"value":true}}
Diagnostic notation
{
"t": 33,
"dl": true
}
CBOR payload
A2 61 74 18 21 62 64 6C F5
UDP payload
LA1Sn4yuYx16YBAABqQQnSan\nmaker:4VyRL0fr22kOm01qFyHqw3gE91MahfK1Q3zEfRg0\n\xA2\x61\x74\x18\x21\x62\x64\x6C\xF5
For working with ABCL, please read the ABCL guide.
Payload conversion
{"sense": [
{"asset": "t", "value": {"byte": 0, "type": "integer"}},
{"asset": "dl", "value": {"byte": 1, "type": "boolean"}}
]}
UDP payload
LA1Sn4yuYx16YBAABqQQnSan\nmaker:4VyRL0fr22kOm01qFyHqw3gE91MahfK1Q3zEfRg0\n\x21\x01
For sending messages using AllThingsTalk UDP Messaging, you need a UDP capable client.
We suggest using PacketSender, as it’s a simple multiplatform program that should be easy to set up for sending AllThingsTalk UDP packets.
Currently, downlinks and request confirmations are not supported.