Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents
minLevel1
maxLevel7

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: {hardwareId}/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: {hardwareId}/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 errorevent 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

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.

...

Code Block
{
  "hardwareId": ##,
  "peripheral": "lamp", 
  "property": "power",
  "numProperties": ##,
  "type": "xxxxx",
  "length": 1,
  "settable": true,
  "hide": true,
  "info":"Mouse Over Text"
}

Registration Flow

Cloud Registration

Sequence

Source

Message

Destination

1

Gumband Hardware

Subscribe Authenticate

Cloud Server

2

Cloud Server

Authenticate request

Gumband Hardware

3

Gumband Hardware

Authenticate token

Cloud Server

4

Cloud Server

Authenticate response true

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

...

  1. For Debug only

  2. 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

  3. 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 request

Gumband Hardware

3

Gumband Hardware

Authenticate token

Exhibit Server

4

Exhibit Server

Authenticate response true

Gumband Hardware

5

Gumband Hardware

Subscribe all peripheral topics

Exhibit Server

6

Gumband Hardware

Heartbeat (Every 16s)

Exhibit Server


...

SYNC Messages

Gumband needs some way to make sure its knowledge of peripheral properties are up to date if the Gumband server or MQTT go down at any point and publication messages are missed. In these cases, a SYNC request will be made to each out of date board as soon as the server comes back up. 

  • Sync topic: {hardwareId}/sync

  • Immediately after registration every Gumband Hardware device subscribes to this sync topic so should always be ready to receive it.

  • In response to a sync topic the hardware will issue a registration and resubscribe to all topics.

  • If the cloud wants read the status of specific peripheral properties it can then poll all readable properties: {hardwareId}/{peripheral_name}/{property_name}/get

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.

...

"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: {hardwareId}/heartbeat

...

  • 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 - Connected)

    • Temperature - Hardware temperature in degrees C (this is actually the Die temp for most current hardware)

    • Voltage - System supply voltage in mV

  • The time of last heartbeat should be logged

Logs

  • Gumband debug, error and log messages are published to the Cloud Server at the topic:

    • {hardwareId}/log/debug

    • {hardwareId}/log/error

    • And should have the message body:

Code Block
{
  "text": "<event message text>",
}

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:

    • {hardwareId}/log/notify

    • And should have the message body:

Code Block
{
  "text": "<notification message text>",
}

Events

  • Gumband events can be viewed on the “Reports” tab and are published to the Cloud Server at the topic:

    • {hardwareId}/log/event

    • And should have the message body:

Code Block
{
  "text": "<event message text>",
  "value": <event value>
}

Exhibit Events

...

  • Controllable exhibit events are structured as "settable" properties

  • Writing to properties:

    • For every "settable" property, gumband hardware is subscribed to:

    • {hardwareId}/{peripheralName}/{propertyName}/set

  • Reading/Polling properties

    • For every property the gumband hardware is subscribed to:

    • {hardwareId}/{peripheralName}/{propertyName}/get

    • Note that this callback is intended to initiate a publish to the associated property but ultimately this is handled in user code so implementation is not guaranteed.

  • The Exhibit Broker should be subscribed to every property exposed in the capabilities registration

    • {hardwareId}/{peripheralName}/{propertyName}

Dynamic Hardware ID

Note: This is a suggested method to address a potential issue - this is not currently implemented

If Hardware boots and no hardwareId exists in memory but an auth token exists, Hardware will attempt to assign itself directly to an Exhibit using this process. This can be used to mass-assign Hardware to an Exhibit.

Overview

  • Hardware listens to <mac_address>/new-hardware-id on Cloud Server

  • Hardware publishes hardwareId request to Cloud Server at topic new-hardware-id

  • Gumband uses auth token to lookup Exhibit and generate new Hardware assigned to that Exhibit

  • Gumband publishes hardwareId over Cloud Server at topic <mac_address>/new-hardware-id

  • Hardware can proceed with normal registration flow

Message Outline:

Data flow = Hardware -> Cloud Server -> Gumband

...