-
-
Save sandeepmistry/d423c8c3b3e7a6947517 to your computer and use it in GitHub Desktop.
Reconfigure any Estimote 3.1+ beacon in range to broadcast a specified Eddystone-URL
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 async = require('async'); | |
var encodeEddystoneUrl = require('eddystone-url-encoding').encode; | |
var Estimote = require('bleacon').Estimote; | |
var URL = 'http://example.com'; | |
var ENCODED_URL_DATA = encodeEddystoneUrl(URL); | |
var discovered = {}; | |
console.log('discovering all Estimote beacons in range'); | |
console.log('-----------------------------------------') | |
Estimote.discoverAll(function(estimote) { | |
var address = estimote.address; | |
if (discovered[address]) { | |
// already discovered ... ignore | |
return; | |
} | |
discovered[address] = true; | |
console.log('discovered beacon: ' + address); | |
async.series([ | |
function(callback) { | |
console.log('connecting and setting up ...'); | |
estimote.connectAndSetUp(function() { | |
console.log('\tdone'); | |
callback(); | |
}); | |
}, | |
function(callback) { | |
console.log('pairing ...'); | |
estimote.pair(function(error) { | |
console.log('\tdone'); | |
callback(); | |
}); | |
}, | |
function(callback) { | |
console.log('writing encoded Eddystone URL ' + ENCODED_URL_DATA.toString('hex') + ' ...'); | |
estimote.writeEddystoneUrl(ENCODED_URL_DATA, function() { | |
console.log('\tdone'); | |
callback(); | |
}); | |
}, | |
function(callback) { | |
console.log('writing service configuration for Eddystone-URL mode ...'); | |
estimote.writeServiceConfiguration('eddystone-url', function() { | |
console.log('\tdone'); | |
callback(); | |
}); | |
}, | |
function(callback) { | |
console.log('disconnecting ...'); | |
estimote.disconnect(function() { | |
console.log('\tdone'); | |
callback(); | |
}); | |
} | |
]); | |
}); |
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
mkdir EstimoteEddystoneURL | |
cd EstimoteEddystoneURL | |
npm install async eddystone-url-encoding bleacon |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment