UDP Messaging API

This guide introduces you to a possibility to feed AllThingsTalk Cloud with sensor data over UDP protocol.

What is UDP

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.

UDP endpoint

Send UDP packets to:

  • api.allthingstalk.io on port 8891
  • 40.68.172.187 on port 8891

Message format (preview version)

A packet sent by the UDP client should be formatted as follows:

  1. DeviceID NEWLINE_CHARACTER
  2. DeviceToken NEWLINE_CHARACTER
  3. DeviceState

NEWLINE_CHARACTER is \n (0x0A). There are no spaces between Device ID, Device Token, Device State and newlines.

Device ID & Token

These can be obtained from AllThingsTalk Maker by going into device S**ettings > Authentication**.

Device ID and Token

Device State

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

Example packets

Let’s consider a device that sends a temperature t and a daylight dl.

Using JSON

Device state

{

"t": { "value": 33 },

"dl": { "value": true }

}

 

UDP payload

LA1Sn4yuYx16YBAABqQQnSan\nmaker:4VyRL0fr22kOm01qFyHqw3gE91MahfK1Q3zEfRg0\n{"t":{"value":33},"dl":{"value":true}}

Using CBOR

Diagnostic notation

{

"t": 33,

"dl": true

}

CBOR payload

  1. A2 61 74 18 21 62 64 6C F5

UDP payload

  1. LA1Sn4yuYx16YBAABqQQnSan\nmaker:4VyRL0fr22kOm01qFyHqw3gE91MahfK1Q3zEfRg0\n\xA2\x61\x74\x18\x21\x62\x64\x6C\xF5

Using ABCL

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

  1. LA1Sn4yuYx16YBAABqQQnSan\nmaker:4VyRL0fr22kOm01qFyHqw3gE91MahfK1Q3zEfRg0\n\x21\x01

Try it

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.

Other

Currently, downlinks and request confirmations are not supported.