Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Expand
titleSteps to connect hardware manually

For instances where you want to bypass hardware authentication and management through Gumband Cloud. This could include an on-site installation where there is flakey or non-existent cloud access.

Whitelist the Hardware ID in the SDK

Code Block
languagejs
const { Gumband, Sockets } = require('@deeplocal/gumband-node-sdk');

const EXHIBIT_ID = '40';
const EXHIBIT_TOKEN = 'a45ne3...';

const gb = new Gumband(
    EXHIBIT_TOKEN,
    EXHIBIT_ID,
    './manifest.json',
    {
      gbttEnabled: true, // Enable the hardware MQTT broker
      gbttPort: 1883, // (Optional) port for the MQTT broker, defaults to 1883
      noInternetConnection: true, // SDK needs to run in offline mode to use Hardware ID whitelist
      noInternetHardwareIds: [] // Array of offline hardware IDs
    }
);

gb.on(Sockets.READY, async () => {
    console.log('Gumband Ready!');
});

Configure the Exhibit Application IP on the Hardware

The hardware needs to know the IP of the computer running the SDK application so it knows where to connect to. We’ll configure the hardware to use this IP using the serial configuration interface, and disable the Gumband Cloud from being able to change it.

Description

Command

Set Exhibit Server to Static

write static_exhibit true

Set Exhibit Server

write exhibit_server XX.XX.XX.XX:1883

...

The hardware’s LED status will correspond to how it is connected.

Color

Description

Image Modified

Cyan

Only Cloud server connected

Image Modified

Blue

Only Application server connected

Image Modified

Green

Both Cloud server and Application server connected

...

Interacting with the SDK

See SDK Events for more information about these events and the available data in the payloads.

...

Button presses from the hardware get sent to the SDK, and the SDK toggles the hardware LED in return.

The firmware for the hardware is the Remote LED and Button example in Arduino (version 1.8.4 or newer).

...

Expand
titleRemote LED and Button Hardware Arduino sketch
Code Block
languagearduino
/*
 * Gumband Remote Button/LED Example
 * 
 * Demonstrates how to control hardware using an Exhibit Application
 *   - sets up a property to turn the on-board LED on/off.
 *   - sets up a property that updates when on-board button is pressed/released.
 */

// Create the Gumband Properties
GumbandProp button_prop = gumbandCreate("Button", "Press", gmbnd_bool);
GumbandProp led_toggle_prop = gumbandCreate("LED", "Toggle", gmbnd_bool);

// Local variable that keeps track of the button state
static bool button_currently_pressed = false;

// Define our LED/Toggle property write callback
void led_toggle_callback(uint16_t length, void* data)
{
    // Cast our received value to our intended value (we can ignore length since we are expecting one value)
    gmbnd_bool_t toggle_val = GUMBAND_BOOL(data);

    // Turn the on-board LED on or off using the toggle value
    if(toggle_val == 1) {
      gumbandLedOn();
    }
    else {
      gumbandLedOff();
    }
}

void setup()
{
  // Attach the callback to executes when something is written to the LED/Toggle property
  gumbandSetWriteCallback(led_toggle_prop, led_toggle_callback);
}

void loop()
{
  // If the on-board button is pressed
  if(gumbandButtonPressed() && button_currently_pressed == false) {
    
    // Tell the exhibit application the button has been pressed
    gumbandPublish(button_prop, true);

    button_currently_pressed = true;
  }
  else if(!gumbandButtonPressed() && button_currently_pressed == true)
  {
    // Tell the exhibit application the button has been released
    gumbandPublish(button_prop, false);

    button_currently_pressed = false;
  }
}

...