ITP | Week 6 | March 3, 2017
Don Coleman
Photo credit: Lars Plougmann https://flic.kr/p/wvUq9U
var Bleacon = require('bleacon')
Bleacon.on('discover', function (beacon) {
console.log(
beacon.uuid + ' | ' +
beacon.major + ' | ' +
beacon.minor
);
});
Bleacon.startScanning();
node-bleacon
var Bleacon = require('bleacon');
var uuid = '12345678-aaaa-bbbb-cccc-123456789abc';
var major = 0; // 0 - 65535
var minor = 0; // 0 - 65535
var measuredPower = -59; // -128 - 127
Bleacon.startAdvertising(uuid, major,
minor, measuredPower);
iBeacon beacon;
void setup() {
char* uuid = "a196c876-de8c-4c47-ab5a-d7afd5ae7127";
unsigned short major = 1;
unsigned short minor = 3;
unsigned short measuredPower = -55;
beacon.begin(uuid, major, minor, measuredPower);
}
void loop() {
beacon.loop();
}
iBeacon.ino
(not Core Bluetooth)
Measured RSSI at 1 meter
Transmit Power -40 dBm to +10 dBm
Measured Power will be lower
Tradeoff between range & battery life
Between 100 ms and 2 seconds
Shorter interval has better visibility
Longer interval can increase battery life
var Scanner =
require('eddystone-beacon-scanner');
Scanner.on('found', function(beacon) {
console.log('found Eddystone Beacon:\n',
JSON.stringify(beacon, null, 2));
});
Scanner.startScanning(true);
node-eddystone-beacon-scanner
var beacon = require('eddystone-beacon');
var url = 'https://tisch.nyu.edu/itp';
beacon.advertiseUrl(url);
node-eddystone-beacon
#include <EddystoneBeacon.h>
EddystoneBeacon eddystoneBeacon;
void setup() {
delay(1000);
int power = -18;
String uri = "https://eff.org";
eddystoneBeacon.begin(power, uri);
}
void loop() {
eddystoneBeacon.loop();
}
EddystoneURL.ino
URI Beacon + Web Page
BLEFloatCharacteristic characteristic =
BLEFloatCharacteristic("BBB1",
BLERead | BLENotify | BLEBroadcast);
Temperature_v2.ino
// iOS
serviceData = device.advertising.kCBAdvDataServiceData;
if (serviceData && serviceData.BBB0) {
celsius = new Float32Array(serviceData.BBB0)[0];
}
thermometer_v2/www/index.js
// Android
var advertisingData = parseAdvertisingData(device.advertising);
serviceData = advertisingData[SERVICE_DATA_KEY];
if (serviceData) {
// first 2 bytes are the 16 bit UUID
var uuidBytes = new Uint16Array(serviceData.slice(0,2));
var uuid = uuidBytes[0].toString(16); // hex string
// remaining bytes are the service data
var data = new Float32Array(serviceData.slice(2));
celsius = data[0];
}
thermometer_v2/www/index.js
Don Coleman
dc159@nyu.edu
NYU ITP Bluetooth Spring 2017 Week 6 by Don Coleman is licensed under a Creative Commons Attribution 4.0 International License.