• You can use NRF.findDevices to check for the beacons advertising around you can can then do things based on that: http://www.espruino.com/Reference#l_NRF_­findDevices

    Eg.

    function checkPresence() {
      NRF.findDevices(function(devices) {
        var found = false;
        for (var dev in devices) {
          if (dev.name == "whatever") found = true;
        }
        if (found) start advertising
        else stop advertising;
      }, 1000); // scan for 1 second
    }
    setInterval(checkPresence, 5*60000); // check once every 5 minutes
    

    However actually checking for surrounding beacons takes a lot of power, so you don't want to do it often, or for long. The example above does 1 second every 5 minutes, which is still quite a lot. If you were doing this to save power you're probably best off not bothering and just advertising regardless.

  • Thanks for your responce, but this is

    Uncaught Error: Field or method "name" does not already exist, and can't create it on Number
     at line 5 col 14
          if (dev.name == "DiamondBeacon") found = true;
    

    and when I use the simple example no name is displayed.. I want to scan with id(Mac address).

    NRF.findDevices(print)
    
About

Avatar for Pzr0 @Pzr0 started