SDK-Hardware Interface Notes

SDK HARDWARE_ONLINE & HARDWARE_OFFLINE Callbacks

The exhibit SDK emits a HARDWARE_ONLINE event with the after a hardware connection is established and successfully authenticates. It also emits a HARDWARE_OFFLINE event if the MQTT heartbeat for a particular harwareId connection isn’t received by the SDK within 20 seconds.

// gumband sdk initalization above... // register hardware connection callbacks gb.on(Sockets.HARDWARE_ONLINE, (payload) => { console.log(payload); }); gb.on(Sockets.HARDWARE_OFFLINE, (payload) => { console.log(payload); });

Both events contain the following payload:

{ hardwareId: 123, name: 'Exhibit Gizmo' }

SDK Hardware Authentication Scenarios

Exhibit Online

noInternetConnection: false

Normal Gumband Cloud connectivity

Once the exhibit SDK has initialized, it will use hardware list (ie. connected hardware from the web UI) to know which hardwareIds to allow. It then authenticates using the token against the Gumband Cloud before allowing peripheral messages.

If the exhibit SDK does not yet have the hardware list when hardware connects, those hardware connections are added to a "Waiting for Auth" queue.

Exhibit Offline

noInternetConnection: false

No Gumband Cloud connectivity

Once the exhibit SDK has initialized, it will use hardware list to allow future connections to those hardwareIds without authentication (as if noInternetConnection: true) until the Gumband Cloud connection is re-established. Once the connection is re-established, any existing hardwareId connections that are no longer valid are immediately disconnected.

Exhibit Offline Mode

noInternetConnection: true

No Gumband Cloud connectivity

Once the exhibit SDK has initialized, it will use the noInternetHardwareIds list to allow connections to those hardwareIds without authentication.

 

SDK “Waiting for Auth” Queue

If the exhibit SDK has not yet received the hardware list from the Gumband Cloud but is expecting to (ie. noInternetConnection: false and the SDK is initializing or the exhibit is temporarily offline), the SDK holds hardware connections in a “Waiting for Auth” queue as it waits for the hardware list. When the SDK adds connections to this queue, it doesn’t request the auth token from the connection immediately but instead just holds the connection. If the SDK doesn’t receive the hardware list from the Gumband Cloud within 10 seconds, it will disconnect the hardware connection assuming that the hardware will try to reconnect, and repeat that cycle until the Gumband Cloud connection is re-established.

How Two MQTT Connections for the Same Hardware ID Respond

If two connections try to authenticate with the same hardwareId, the SDK responds whether or not the existing connection is authenticated. If that case is true, then the new hardware connection is rejected. If the existing connection is not authenticated (ie. in the “Waiting for Auth” queue), then that connection will be severed and the new connection will be accepted.