Created
August 7, 2014 23:34
-
-
Save EvanSimpson/38f03e0b201ef0115e23 to your computer and use it in GitHub Desktop.
Turn your Tessel BLE module into an iBeacon
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tessel = require('tessel'); | |
var bleLib = require('ble-ble113a'); | |
var bleadvertise = require('bleadvertise'); | |
var uuid = 'D9B9EC1F392543D080A91E39D4CEA95C'; // Apple's example UUID | |
var major = '01'; | |
var minor = '10'; | |
var iBeaconData = new Buffer(uuid+major+minor, 'hex'); // Create data Buffer | |
var packet = { | |
flags: [0x04], // BLE only | |
mfrData : iBeaconData | |
} | |
var ad = bleadvertise.serialize(packet); | |
var beacon = bleLib.use(tessel.port['A'], function(){ | |
beacon.setAdvertisingData(ad, function(){ | |
beacon.startAdvertising(); | |
console.log('Beaconing'); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment