RadiusNetworks / javascript-beacon-library

A JavaScript library for broadcasting Beacon advertisements
Apache License 2.0
9 stars 1 forks source link

Rework library, incorporate custom beacon types #2

Closed jnebeker closed 8 years ago

jnebeker commented 8 years ago

This updates the structure of the library to mimic that of the Eddystone Advertising Library (I was struggling to build and test with the initial yeoman generated setup I started with).

In addition, this incorporates the usage for registering advertisements as well as registering custom beacon types initially discussed in #1. A beacon type can be registered by specifying a beacon layout string and either a manufacturer ID or a service UUID:

beacon.registerBeaconType({
  type: 'cool_beacon',
  beaconLayout: 'm:2-3=0000,i:4-19,i:20-21,i:22-23,p:24-24',
  manufacturerId: 0x1234
})

There are three beacon types included by default:

To register a beacon advertisement (i.e., broadcast as a beacon), you need to specify a beacon type along with the beacon ids and measured power:

beacon.registerAdvertisement({
  type: 'altbeacon',
  ids: ['2F234454CF6D4A0FADF2F4911BA9FFA6', 1, 1],
  advertisedTxPower: -59,
})

The beacon layout of the beacon type is then used to build the advertisement data with the ids and power and relay that to the Chrome OS BLE API.

Resolves #1

csexton commented 8 years ago

image Nice.

jnebeker commented 8 years ago

Tested this on a Chromebit and broadcasting of all beacon types works (including iBeacon) šŸŽ‰

syoder commented 8 years ago

šŸ»