v1 MQTT Reference Guide
MQTT Overview
Each Gumband Hardware Device maintains two MQTT broker connections: one to handle global gumband events (Cloud), and one to handle exhibit events (Exhibit). The purpose is to keep exhibit events on the lowest latency and most reliable connection to ensure super responsive performance and improve up time (especially when the Cloud server is remote). The hardware can also be run without a connection to the Cloud server but maintaining the Gumband messaging protocol. When a Gumband device registers through the cloud and is attached to an active exhibit, the Exhibit server IP/hostname will be returned. Note: this could be the same IP/hostname as the Cloud server in the case of an on-premises Cloud server (but it can't be the same port).
Cloud Server
Firmware updates
Device Registration
Heartbeat
Error/Warnings
Logs
Lifecycle commands (restart, shutdown, etc)
When in Debug Mode supports all control events (for test and debug)
Exhibit Server
Device Registration
Heartbeats
All peripheral/property events specific to exhibits
Hardware Authentication
The user creates a hardware auth token from the "Auth" tab for that hardware within the Gumband UI.
That token needs to be written to the hardware either through the serial interface or the firmware API.
On boot the hardware will subscribe to the topic: <hardware_id>/authenticate
At this point no other subscribe or publish is allowed by the Cloud until authentication has completed
When an unknown hardware device attempts to open a socket with the GBTT server and subscribe to the authenticate topic (Note: The Cloud must wait for the HW to subscribe to this), the Cloud will issue a request event to this topic: <hardware_id>/authenticate
{
"text": "request"
}
The HW responds to a request with it's authentication token in the following format:
Topic = <hardware_id>/authenticate
{
"token": 32 char alphanumeric
}
If the token and hardwareId are valid, the server will respond on the authenticate topic with “true”.
Topic = <hardware_id>/authenticate
{
"text": "true"
}
If the token is not valid, the server will respond on the authenticate topic with “false”.
Topic = <hardware_id>/authenticate
If the hardwareId is not valid, the server will respond on the authenticate topic with “id”.
Topic = <hardware_id>/authenticate
If the authentication fails or the HW fails to respond to the authentication request then the GBTT server ignores all data on this socket (but does not explicitly close it).
Any events/topics published without first authenticating will be responded with an error event on the info topic (see INFO). Note no other subscribe or publish is allowed during the authentication handshake or the auth will fail, so it’s important not to send anything else until this is completed.
All topic subscriptions (other than authenticate) will be rejected until the auth sequence is completed.
Hardware Registration
Updated 8/15/2023
This occurs whenever the initial connection is made to the MQTT cloud server after authentication, this contains the device capabilities only. To obtain actual property states readable topics can be polled.
Registration can also occur when a registration request is received from the server (the INFO topic “register” command).
Once authenticated, the HW sends Gumband registration event to the Cloud Server and Exhibit Server at the topic: <hardware_id>/registration
Registration events should be logged on the server side
Registration events have an initial JSON message body identifying the device and the total number of peripherals, followed by individual registration messages for each property of every peripheral. Outline below:
Topic = <hardware_id>/registration
Topic = <hardware_id>/registration/property
Registration Flow
Cloud Registration
Sequence | Source | Message | Destination |
1 | Gumband Hardware | Subscribe Authenticate | Cloud Server |
2 | Cloud Server | Authenticate | Gumband Hardware |
3 | Gumband Hardware | Authenticate | Cloud Server |
4 | Cloud Server | Authenticate response | Gumband Hardware |
5 | Gumband Hardware | Subscribe SYNC | Cloud Server |
6 | Gumband Hardware | Subscribe INFO | Cloud Server |
7 | Gumband Hardware | Subscribe all peripheral topics1 | Cloud Server |
8 | Gumband Hardware | Publish REGISTRATION | Cloud Server |
9 | Cloud Server | Publish exhibit HOST to INFO2 | Gumband Hardware |
10 | Cloud Server | Publish Debug status | Gumband Hardware |
11 | Gumband Hardware | Start Exhibit Registration3 | Exhibit Server |
12 | Gumband Hardware | Heartbeat (Every 16s) | Cloud Server |
Note:
For Debug only
Should be implemented on every connection but only required if the hardware does not already have a saved exhibit server address or if the address has changed
If the hardware already holds an exhibit address this will happen in parallel with the master connection
Exhibit Registration
Sequence | Source | Message | Destination |
1 | Gumband Hardware | Subscribe Authenticate | Exhibit Server |
2 | Exhibit Server | Authenticate | Gumband Hardware |
3 | Gumband Hardware | Authenticate | Exhibit Server |
4 | Exhibit Server | Authenticate response | Gumband Hardware |
5 | Gumband Hardware | Subscribe all peripheral topics | Exhibit Server |
6 | Gumband Hardware | Heartbeat (Every 16s) | Exhibit Server |
INFO Messages
Gumband Cloud Server needs a way to signal each hardware device to send simple control commands. In this case, the information is published to the device INFO topic to which each device subscribes first (before publishing its initial authentication/registration). The INFO topic is also used during the initial handshake to share the exhibit broker host details.
Every Gumband hardware device should be subscribed to the topic: <hardware_id>/info
This subscription occurs prior to every registration
The contents of the info topic is a 2 parameter JSON structure:
Command | Text | Description |
host | xxx.xxx.xxx.xxx:xxxx | Exhibit server host IP and Port |
reboot | - | Reboot the Gumband Hardware |
register | - | Request the hardware to register with the Cloud Server |
get | - | Request the hardware to publish all of it’s current property values |
firmware | - | Enter Device Firmware Update (DFU) mode on Gumband Hardware using the existing Cloud MQTT socket |
firmware_socket | - | Enter Device Firmware Update (DFU) mode on Gumband Hardware using a dedicated TCP socket on port 23 (this only works if that port is not already connected) |
control | true/false | Set to true to enable debug mode whereby peripheral control messages can be sent from the Cloud |
identify | - | Blink the on board LED to identify this hardware device |
error | (see below table) | Allows Gumband server to send error codes to the hardware |
"Error" Command Text | Description |
E_NO_HW_ID | When an MQTT message is sent to Gumband for a hardwareId that does not exist |
NOT_AUTHED | When an MQTT message is sent to Gumband from a client that has not authenticated yet |
Heartbeats
Heartbeats are sent from the Gumband Hardware every 16 seconds and are published to the topic: <hardware_id>/heartbeat
With the payload:
Board metrics
Uptime - Time in minutes since last reboot
Exhibit IP - The exhibit server IP currently saved on the hardware
Exhibit State - The state of the connection from the exhibit hardware to the exhibit server (0 = No connection, 1 = Connection, -1 = Not Set)
Temperature - Hardware temperature in degrees C (this is actually the Die temp for most current hardware)
Voltage - System supply voltage in V
The time of the last heartbeat is displayed on the “Overview” page under “Last Updated”
Logs
Gumband debug, error and log messages are published to the Cloud Server at the topic:
<hardware_id>/log/debug
<hardware_id>/log/error
And should have the message body:
Notifications
Gumband notification messages are immediately sent to any user subscribed to hardware notifications in the main are published to the Cloud Server at the topic:
<hardware_id>/log/notify
And should have the message body:
Events
Gumband events can be viewed on the “Reports” tab and are published to the Cloud Server at the topic:
<hardware_id>/log/event
And should have the message body:
Properties
Properties are user defined endpoints that control individual aspects of the application (motor speed, light color, power on/off etc.).
Properties are grouped into a specific “Peripherals” which serves only as a hierarchical organizational structure.
Writing Properties
Any property with write permissions is a “settable” property.
For every "settable" property, gumband hardware is subscribed to:
<hardware_id>/{peripheralName}/{propertyName}/set
Data sent to this endpoint will be received by the gumband hardware and routed to the appropriate callback.
The message body is a raw data byte packet (not ASCII or JSON encoded)
Reading Properties
Every property is readable or “gettable” however a Publish can be triggered at any time by the user code so this does not need to be polled in normal operation.
Gumband hardware will publish property data to the following topic, therefore the GBTT Broker should be subscribed to this topic for every property exposed in the capabilities registration:
<hardware_id>/{peripheralName}/{propertyName}
For every property the gumband hardware is subscribed to the following topic and the value of a property can be actively requested by publishing to it:
<hardware_id>/{peripheralName}/{propertyName}/get
The “get” publish triggers a read callback which is a request to initiate a publish to the associated property but ultimately this callback is handled in user code so implementation is not guaranteed.
See more SDK-Hardware Interface Notesarchived