Hi, thanks for a very relevant question, and sorry for the slow response.
One way is to connect to the closest SensorTag (the one with strongest RSSI value).
Here is some code that you could adopt for this purpose:
https://github.com/divineprog/evo-demos ... index.htmlAnother way is to display a list of the SensorTags found during scanning. Problem is how to identify which is which. On Android you get persistent addresses, but not on iOS which hides the id (the MAC address) and assigns a temporary id.
Perhaps there is some data in the advertisementData record that can be used to identify devices?
The field advertisementData is just a JavaScript dictionary (object) with key/value pairs.
Here is a code-snippet that prints the advertisement data when scanning for devices:
Code: Select all
function init()
{
console.log('Scanning for devices...');
evothings.easyble.reportDeviceOnce(true);
evothings.easyble.startScan(deviceDetected, scanError);
}
function deviceDetected(device)
{
console.log('Device found: ' + device.name + ' RSSI: ' + device.rssi);
evothings.easyble.printObject(device.advertisementData, console.log);
}
It is useful to redirect console.log to hyper.log in the beginning of the program. Like this:
Code: Select all
if (window.hyper && window.hyper.log) { console.log = hyper.log; }
This is done in most example apps in index.html. If you want both hyper.log and console.log you can do something like this:
Code: Select all
;(function() {
var consoleLog = console.log;
function log(message) {
consoleLog(message);
hyper.log(message);
}
if (window.hyper && window.hyper.log) { console.log = log; }
})();
Does some of the above help in your case?
Regards, Mikael