sandeepmistry / node-sensortag

Node.js lib for the TI SensorTag
MIT License
218 stars 111 forks source link

Stop SensorTag.discoverById? #78

Closed stozk closed 8 years ago

stozk commented 8 years ago

Hi, is it possible to stop SensorTag.discoverById looking for a Tag or do I have to use my own implementation of discoverAll() respectively stopDiscoverAll() and add a timeout there?

This is how I do it currently:

function checkConnect(){
 if(!sensorConnected){
            console.log('Sensor connection timeout!');
            SensorTag.stopDiscoverAll(onDiscover);
            startScan();
        }
    }
    setTimeout(checkConnect, 10000);
    SensorTag.discoverAll(onDiscover);
    function onDiscover(sensorTag) {
        if(sensorTag.id === deviceId){...

Thanks & BR Daniel

sandeepmistry commented 8 years ago

@stozk there are no stopDiscoverById API's at this time, you can follow this for further related info on this topic: https://github.com/sandeepmistry/noble-device/issues/10

do I have to use my own implementation of discoverAll() respectively stopDiscoverAll() and add a timeout there?

Yes, this is what I would recommend for now.