Bluetooth LE

ITP | Week 6 | March 3, 2017

Don Coleman

Beacons

Photo credit: Lars Plougmann https://flic.kr/p/wvUq9U

Connectionless Data Transfer

Advertising

Advertising

  • MAC Address: AA:BB:CC:DD:EE:FF
  • Services: [ 0x180A, 0xFF10, 0XFF20, …]
  • Manufacturer Data: <00007465 6d70>
  • Connectable: True
  • TX Power Level: 4
  • RSSI: -80
  • Name: Smart Lightbulb

Beacon Advertising

iBeacon

  • UUID: b9407f30-f5f8-466e-aff9-25556b57fe6d
  • Major: 0x01
  • Minor: 0x0A

Scan for iBeacons

var Bleacon = require('bleacon')
Bleacon.on('discover', function (beacon) {
  console.log(
	beacon.uuid  + ' | ' +
	beacon.major + ' | ' + 
	beacon.minor
  );
});
Bleacon.startScanning();
                
node-bleacon

Create an iBeacon

  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);
                

Create an iBeacon with Arduino

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

Core Location

(not Core Bluetooth)

Region

  • Inside Region
  • Outside Region

Ranging

  • Immediate
  • Near
  • Far
  • Unknown

Demo

Measured Power

Measured RSSI at 1 meter

Transmit Power -40 dBm to +10 dBm

Measured Power will be lower

Tradeoff between range & battery life

Advertising Interval

Between 100 ms and 2 seconds

Shorter interval has better visibility

Longer interval can increase battery life


Requires a license from Apple

Eddystone Beacons


google.github.io/physical-web/

An Eddystone beacon broadcasts a URL

https://tisch.nyu.edu/itp

Scan for Eddystone Beacons

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

Create an Eddystone Beacon


  var beacon = require('eddystone-beacon');
  var url = 'https://tisch.nyu.edu/itp';
  beacon.advertiseUrl(url);
                
node-eddystone-beacon

Create an Eddystone Beacon with Arduino

#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

g.co/beacons

Eddystone Frame Types

  • URL - compressed URL
  • UID - unique static ID
  • TLM - telemetry
  • EID - ephemeral ID

Eddystone Ephemeral Identifier


youtu.be/3nYyApSiSLQ

Fat Beacons

URI Beacon + Web Page


altbeacon.org

Broadcast Characteristic


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

http://don.github.io/slides/

 

 

Creative Commons License
NYU ITP Bluetooth Spring 2017 Week 6 by Don Coleman is licensed under a Creative Commons Attribution 4.0 International License.