Versions Compared

Key

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

...

The directory path to the manifest.

Expand
titleExample
Code Block
languagejs
gumbandSDK.setManifest('./path/to/manifest.json');

getOperatingMode( ): Promise<boolean>

Get the current operating mode for the exhibit from Gumband.

Expand
titleExample
Code Block
languagejs
let operatingMode = await gumbandSDK.getOperatingMode();

console.log(`Operating Mode: ${operatingMode}`);
// Operating Mode: true

setOperatingMode(opMode: boolean): Promise<void>

...

The target operating mode.

Expand
titleExample
Code Block
languagejs
await gumbandSDK.setOperatingMode(true);

getStatus(statusName: string): Promise<string>

...

The “id” field of the status in the manifest.

Expand
titleExample
Code Block
languagejs
let statusValue = await gumbandSDK.getStatus('cpu-usage');

console.log(`CPU Usage: ${statusValue}`);
// CPU Usage: 50%

setStatus(statusName: string, value: string): Promise<void>

...

The target value to which the status should be set.

Expand
titleExample
Code Block
languagejs
await gumbandSDK.setStatus('cpu-usage', "50%");

getSetting(manifestId: string): Promise<string>

...

The “id” field of the setting in the manifest.

Expand
titleExample
Code Block
languagejs
let motorRPM = await gumbandSDK.getSetting('motor-rpm');

console.log(`Motor RPM: ${motorRPM}`);
// Motor RPM: 30

setSetting(settingName: string, value: string): Promise<void>

...

The target value to which the setting should be set.

Expand
titleExample
Code Block
languagejs
await gumbandSDK.setSetting('motor-rpm', '30');

getAllSettings( ): Promise<Map<Setting>>

Get all settings as a map, where the key is the “id” field of each setting in the manifest.

Expand
titleExample
Code Block
languagejs
console.log(await gumbandSDK.getAllSettings());

//{
//  'motor-rpm': {
//    id: 14,
//    manifestId: 'motor-rpm',
//    exhibitId: 1,
//    type: 'IntegerInput',
//    display: 'Motor RPM',
//    enabledOpMode: null,
//    value: 30,
//    default: 0,
//    order: 0,
//    touchless: null,
//    listId: null,
//    groupId: null,
//    read: true,
//    write: true
//  }
//}

getAllSettingLists( ): Promise<SettingList[ ]>

Get all setting lists in the manifest as an array.

Expand
titleExample
Code Block
languagejs
console.log(await gumbandSDK.getAllSettingLists());

//[
//  {
//    id: 1,
//    exhibitId: 1,
//    manifestId: 'my-list',
//    listDisplay: 'List Label',
//    listParent: null,
//    schema: [ [Object], [Object] ],
//    listItemCount: 1,
//    order: [ 'item 1' ],
//    orderSelf: null,
//    groupId: null,
//    settinglistitems: [ [Object] ],
//    type: 'SettingsList'
//  }
//]

getOnlineHardware( ): Hardware[ ]

Get the list of Gumband Hardware that are currently connected to the SDK.

Expand
titleExample
Code Block
languagejs
console.log(gumbandSDK.getOnlineHardware());

//[
//  {
//    hardwareId: 83,
//    name: 'Gumband SDK Tutorial',
//    peripherals: { Button: [Object], LED: [Object] }
//  }
//]

exhibit.getManifest( ): Promise<Manifest>

Get the full manifest of this exhibit from Gumband.

Expand
titleExample
Code Block
languagejs
console.log(await gumbandSDK.exhibit.getManifest());

//{
//  manifest: {
//    id: 249,
//    siteId: 34,
//    name: 'Gumband SDK Tutorial',
//    mqttPath: '',
//    online: true,
//    manifestLocked: false,
//    opMode: 'On',
//    settingLists: [],
//    settingGroups: [ [Object], [Object] ],
//    settings: [ [Object] ],
//    statuses: [ [Object], [Object], [Object] ],
//    controls: [ [Object], [Object] ],
//    strapiContent: []
//  }
//}

exhibit.getStrapiContentSetting(id: number): Promise<StrapiContent>

...

The new value to which the property will be set.

Expand
titleExample
Code Block
languagejs
//gmbnd_bool property type
await gumbandSDK.hardware.set("1/My Peripheral/My Property", 1);

hardware.getExhibitHardware( ): Promise<Response<Hardware[ ]>>

Get all hardware associated with this exhibit in the Gumband UI.

Expand
titleExample
Code Block
languagejs
console.log(await gumbandSDK.hardware.getExhibitHardware());

//{
//  response: 'success',
//  hardware: [
//    {
//      id: 83,
//      siteId: 34,
//      exhibitId: 249,
//      mac: '16:95:62:21:1h:h2',
//      name: 'Gumband SDK Tutorial',
//      lastHeartbeat: '2023-08-21T16:02:12.133Z',
//      online: true,
//      numPeripherals: 2,
//      controlDebug: true,
//      gumband_fw: '47',
//      user_fw: '0',
//      ip: '192.168.2.2',
//      exhibitIP: '192.168.83.17:1884',
//      exhibitState: 1,
//      temp: '43.217',
//      voltage: '4.609',
//      uptime: '49',
//      createdAt: '2023-08-08T17:42:11.390Z',
//      updatedAt: '2023-08-21T16:02:12.131Z'
//    }
//  ]
//}

hardware.sendMqttMessage(topic: string, rawPayload): Promise<void>

...

Get a list of all remote file names. These file names will match the files list under the Exhibit/Files tab in the Gumband UI.

Expand
titleExample
Code Block
languagejs
let remoteFiles = await gumbandSDK.content.getRemoteFileList();

console.log(remoteFiles);
//{
//  response: 'OK',
//  files: [
//    {
//      file: 'gumband-cassette.png',
//      name: 'gumband-cassette.png',
//      hash: 'SlTZJxaq+s5YH4R1KX6wHA==',
//      lastUpdated: '2023-08-14T19:22:08.547Z',
//      size: '81204'
//    }
//  ],
//  errors: []
//}

content.getLocalFileList( ): File[ ]

Get a list of all locally saved file names for the exhibit.

Expand
titleExample
Code Block
languagejs
let localFiles = gumbandSDK.content.getLocalFileList();

console.log(localFiles);
//{
//  files: [
//    {
//      file: 'gumband-cassette.png',
//      name: 'gumband-cassette.png',
//      hash: 'SlTZJxaq+s5YH4R1KX6wHA==',
//      lastUpdated: '2023-08-14T19:22:08.547Z',
//      size: '81204'
//    }
//  ]
//}

content.sync( ): Promise<void>

Sync locally saved files with the list of remote files. This is called whenever the SDK makes a connection to Gumband if local files is enabled.

Expand
titleExample
Code Block
languagejs
await gumbandSDK.content.sync();

content.uploadFile(fileStream: ReadStream): Promise<void>

...

A stream of data from a function such as fs.createReadStream("path/to/file").

Expand
titleExample
Code Block
languagejs
const fileStream = fs.createReadStream("path/to/file");
await gumbandSDK.content.uploadFile(fileStream);

content.downloadFile(file: string): Promise<void>

...

file

The name of the file.

Expand
titleExample
Code Block
languagejs
await gumbandSDK.content.downloadFile("gumband-cassette.png");

event.create(eventName: string, data: any): Promise<void>

...

Any data object to be associated with the event.

Expand
titleExample
Code Block
languagejs
await gumbandSDK.event.create("Red Button Pressed", { holdTime: 2.52 });

logger.info(message: string): Promise<void>

...

message

The message for the log.

Expand
titleExample
Code Block
languagejs
await gumbandSDK.logger.info("This is an info log message");

logger.debug(message: string): Promise<void>

...

message

The message for the log.

Expand
titleExample
Code Block
languagejs
await gumbandSDK.logger.debug("This is a debug log message");

logger.warn(message: string): Promise<void>

...

message

The message for the log.

Expand
titleExample
Code Block
languagejs
await gumbandSDK.logger.warn("This is a warning log message");

logger.error(message: string): Promise<void>

...

message

The message for the log.

Expand
titleExample
Code Block
languagejs
await gumbandSDK.logger.error("This is an error log message");

notifications.email(message: string): Promise<void>

...

The message for the custom email notification.

Expand
titleExample
Code Block
languagejs
await gumbandSDK.notification.email("Your exhibit requires maintenance");

Websocket Events

This is a list of the possible websocket events that may be emitted by the SDK; for example:

...

Emitted after the SDK successfully authenticates with Gumband, comes online, and is ready to make requests to Gumband.

Sockets.EXHIBIT_ONLINE

Emitted when the SDK successfully authenticates with Gumband and comes online.

Sockets.EXHIBIT_OFFLINE

Emitted when the SDK losses its websocket connection with Gumband.

Sockets.CONTROL_RECEIVED

Emitted when a control is triggered, usually through the Exhibit/Controls tab in the Gumband UI.

Sockets.SETTING_RECEIVED

Emitted when a setting is changed, usually through the Exhibit/Settings tab in the Gumband UI.

Sockets.SETTING_LIST_RECEIVED

Emitted when a new setting list item is added or deleted, when the setting list items have their order changed, or when a setting within a setting list item is changed. The payload is the new setting list with all of its items.

Sockets.SETTING_LIST_ITEM_DELETED

Emitted when a setting list item is deleted. The payload is the setting list item that was deleted.

Sockets.OP_MODE_RECEIVED

Emitted when the Operation Mode is changed, usually through the Exhibit dashboard in the Gumband UI.

Sockets.HARDWARE_ONLINE

Emitted when a Gumband Hardware associated with the exhibit connects to the exhibit.

Sockets.HARDWARE_OFFLINE

Emitted when a Gumband Hardware associated with the exhibit disconnects from the exhibit.

Sockets.HARDWARE_PROPERTY_RECEIVED

Emitted when a property is changed in a Gumband Hardware that is connected to the exhibit.

Sockets.FILE_UPLOADED

Emitted when a new file has been uploaded to Gumband, usually through the Exhibit/Files tab of the Gumband UI.

Sockets.FILE_DELETED

...

Expand
titleExample
Code Block
languagejs
gumbandSDK.on(Sockets.READY, (manifest) => {
    console.log(manifest);
    
    // {
    //     id: 1,
    //     siteId: 1,
    //     name: 'E',
    //     mqttPath: null,
    //     online: true,
    //     manifestLocked: false,
    //     opMode: 'Off',
    //     settingLists: [...],
    //     settingGroups: [...],
    //     settings: [...],
    //     statuses: [...],
    //     controls: [...],
    //     strapiContent: [...]
    // }
});

Sockets.EXHIBIT_ONLINE

Emitted when the SDK successfully authenticates with Gumband and comes online.

Expand
titleExample
Code Block
languagejs
gumbandSDK.on(Sockets.EXHIBIT_ONLINE, () => {
    //no payload for the the Sockets.EXHIBIT_ONLINE event.
});

Sockets.EXHIBIT_OFFLINE

Emitted when the SDK losses its websocket connection with Gumband.

Expand
titleExample
Code Block
languagejs
gumbandSDK.on(Sockets.EXHIBIT_OFFLINE, () => {
    //no payload for the the Sockets.EXHIBIT_OFFLINE event.
});

Sockets.CONTROL_RECEIVED

Emitted when a control is triggered, usually through the Exhibit/Controls tab in the Gumband UI.

Expand
titleExample
Code Block
languagejs
gumbandSDK.on(Sockets.CONTROL_RECEIVED, async (payload) => {
    console.log(payload);

    // {
    //   id: 'control_manifest_id',
    //   touchless: undefined,
    //   sessionId: undefined,
    //   sessionUser: undefined
    // }
});

Sockets.SETTING_RECEIVED

Emitted when a setting is changed, usually through the Exhibit/Settings tab in the Gumband UI.

Expand
titleExample
Code Block
languagejs
gumbandSDK.on(Sockets.SETTING_RECEIVED, (payload) => {
    console.log(payload);
    
    // {
    //     id: 'setting_manifest_id',
    //     value: 'new value',
    //     touchless: undefined,
    //     sessionId: undefined,
    //     sessionUser: undefined
    // }
});

Sockets.SETTING_LIST_RECEIVED

Emitted when a new setting list item is added or deleted, when the setting list items have their order changed, or when a setting within a setting list item is changed. The payload is the new setting list with all of its items.

Expand
titleExample
Code Block
languagejs
gumbandSDK.on(Sockets.SETTING_LIST_RECEIVED, (payload) => {
    console.log(payload);
    
    // { 
    //     id: 'setting_list_manifest_id', 
    //     value: [
    //         ...settingListItems
    //     ]
    // }
});

Sockets.SETTING_LIST_ITEM_DELETED

Emitted when a setting list item is deleted. The payload is the setting list item that was deleted.

Expand
titleExample
Code Block
languagejs
gumbandSDK.on(Sockets.SETTING_LIST_ITEM_DELETED, (payload) => {
    console.log(payload);
    
    // {
    //   "id": "list_manifest_id",
    //   "value": [
    //     {
    //       "id": "deleted_list_item_name",
    //       "value": [ ...listItemValues ]
    //     }
    //   ]
    // }
});

Sockets.OP_MODE_RECEIVED

Emitted when the Operation Mode is changed, usually through the Exhibit dashboard in the Gumband UI.

Expand
titleExample
Code Block
languagejs
gumbandSDK.on(Sockets.OP_MODE_RECEIVED, (payload) => {
    console.log(payload);
    
    // {
    //   value: true
    // }
});

Sockets.HARDWARE_ONLINE

Emitted when a Gumband Hardware associated with the exhibit connects to the exhibit.

Expand
titleExample
Code Block
languagejs
gumbandSDK.on(Sockets.HARDWARE_ONLINE, (payload) => {
    console.log(payload);
    
    // {
    //   hardwareId: 1,
    //   name: 'Gumband Hardware Name',
    //   peripherals: { Button: { Press: [Object] }, LED: { Toggle: [Object] } }
    // }
});

Sockets.HARDWARE_OFFLINE

Emitted when a Gumband Hardware associated with the exhibit disconnects from the exhibit.

Expand
titleExample
Code Block
languagejs
gumbandSDK.on(Sockets.HARDWARE_OFFLINE, (payload) => {
    console.log(payload);
    
    // {
    //   hardwareId: 1,
    //   name: 'Gumband Hardware Name'
    // }
});

Sockets.HARDWARE_PROPERTY_RECEIVED

Emitted when a property is changed in a Gumband Hardware that is connected to the exhibit.

Expand
titleExample
Code Block
languagejs
gumbandSDK.on(Sockets.HARDWARE_PROPERTY_RECEIVED, async (payload) => {
    console.log(payload);
    
    // {
    //   hardwareId: '1',
    //   name: 'Gumband Hardware Name',
    //   value: 1,
    //   peripheral: 'Button',
    //   property: 'Press'
    // }
});

Sockets.FILE_UPLOADED

Emitted when a new file has been uploaded to Gumband, usually through the Exhibit/Files tab of the Gumband UI.

Expand
titleExample
Code Block
languagejs
gumbandSDK.on(Sockets.FILE_UPLOADED, (payload) => {
    console.log(payload);
    
    // {
    //   file: 'uploadedFileName.png',
    //   size: 7891,
    //   exhibitId: '1',
    //   lastUpdated: '2023-08-28T16:14:54.418Z'
    // }
});

Sockets.FILE_DELETED

Emitted when a file is deleted from Gumband, usually through the Exhibit/Files tab of the Gumband UI.

Expand
titleExample
Code Block
languagejs
gumbandSDK.on(Sockets.FILE_DELETED, (payload) => {
    console.log(payload);
    
    // { 
    //   file: 'deletedFileName.png'
    // }
});