Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

BLAST node

@blast/node is a library enabling usage of Web of Things (WoT) Thing Descriptions (TDs) for Bluetooth devices in Node.js.

Building this library produces 3 files inside the dist directory:

Install & build

To install and build @blast/core, open a terminal and execute the following commands from withing this directory.

  1. install the dependencies yarn install
  2. run the build script yarn build

Alternatively you could run yarn build:tds, yarn build:node, or yarn build:browser to only build the respective file.

Note

You might have to set yarn version using yarn set version berry before installing

Important

in order to access the Bluetooth HCI layer from Node.js, either you need to run node using sudo every time or execute sudo setcap cap_net_admin=ep $(eval readlink -f `which node`) first to give the node binary access to use Bluetooth HCI.

Usage

This section describes using the pre-defined TDs (of dist/blast.tds.cjs) with Node.js using dist/blast.node.cjs. For an example on how to use blast.browser.js see packages/web/. If you don't have a dist folder make sure to install & build first.

Example

import {createThing} from './dist/blast.node.cjs';
import {BleRgbController} from './dist/blast.tds.cjs';

const mac = 'BE5860018744';

const thing = await createThing(BleRgbController, mac);

await thing.writeProperty('colour', {R: 255, G: 0, B: 0});

API

createThing

Syntax
await createThing(td, id)
Definition

Creates a consumedThing from the provided Thing description and id

Parameters
Parameter Description
td Thing description of the thing to expose
id The things identifier, as a string containing its mac address or the BluetoothDevice.id
Import
import {createThing} from 'blast.node.js'`

EddystoneHelpers

Object containg helper methods for interacting with Eddystone devices.

Import
import {EddystoneHelpers} from 'blast.node.js'`
Properties
Identifier Description
EDDYSTONE_CONFIG_SERVICE The BluetoothServiceUUID of the [Eddystone Configuration GATT Service](Eddystone Configuration GATT Service)
EDDYSTONE_CHARACTERISTICS Maps BluetoothCharacteristicUUIDs to their respective Characteristic
parseCapabilities Parses the response of a readProperty operation on the capabilities property and returns an object with human-readable values. e.g parseCapabilities(00040103000fe2ecf0f4f8fc0004) returns
{
  specVersion: 0,
  maxSlots: 4,
  maxEidPerSlot: 1,
  isVarriableAdvIntervalSupported: true,
  isVariableTxPowerSupported: true,
  isUidSupported: true,
  isUrlSupported: true,
  isTlmSupported: true,
  isEidSupported: true,
  supportedTxPowerLevels: [
    -30, -20, -16, -12,
     -8,  -4,   0,   4
  ]
}
decodeAdvertisingData Decodes the response of a readProperty operation on the AdvertisingData property and returns a human-readable string.
encodeAdvertisingData Encodes a string using the Eddystone protocol specification for writing it to the AdvertisingData property.