Select one of multiple active sensor tags

Discuss mobile apps for Texas Instruments products.
rpeteranderl
Posts: 1
Joined: 18:40, 09 Mar 2015

Select one of multiple active sensor tags

Postby rpeteranderl » 18:46, 09 Mar 2015

I hope this is not too stupid a question, but I am trying to use SensorTags in my classroom, and it would be important for me if I could have students select a specific sensor tag during an experiment. I have seen the selection page in the TI SensorTag app for iOS, so it must be possible, but so far I haven't been able to find any documentation on how to do that. Any hints? I think the SensorTags would be a terrific tool for the K12 science classroom, but the students need a way to deal just with one sensor.

Any help would be appreciated!

User avatar
micke
Posts: 256
Joined: 20:49, 18 Nov 2013

Re: Select one of multiple active sensor tags

Postby micke » 15:20, 15 Mar 2015

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.html

Another 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


Return to “Texas Instruments”

Who is online

Users browsing this forum: No registered users and 1 guest