You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • The code would look something like this. Just tested and it works fine - you'd just want to choose how you filter out the beacon you're interested in (name, manufacturer data, etc):

    function updateAdvertising(device) {
      var data = new Uint8Array(7);
      // our data - all 0 for nothing, 
      // or RSSI + 6 bytes address
      if (device) {
        data[0] = device.rssi;
        var addrAsBytes = device.id.substr(0,17).split(":").map(x=>parseInt(x,16));
        data.set(addrAsBytes, 1);
      }
      
      NRF.setAdvertising({},{ 
        showName:false, 
        manufacturer: 0x0590,
        manufacturerData: data
      });
    }
    
    function scanForDevice() {
      NRF.requestDevice({ 
        filters: [{ name: 'Puck.js 5a47' }], 
        timeout: 2000}).then(function(device) {
        updateAdvertising(device); // found
      }).catch(function(err) {
        updateAdvertising(undefined); // not found
      });
    }
    
    setInterval(scanForDevice, 60*1000); // scan once a minute
    

    In terms of gateways, I'd suggest just using something like a Raspberry Pi 3 as a start, and then you're totally flexible (you could move to any Linux-based gateway later on if you wanted). What did you want to bridge it to? WiFi, Ethernet, GSM?

    I believe Rigado do some good professional Gateway hardware if you wanted something that 'just worked' though: https://www.rigado.com/cascade-gateway/

    It's also possible to use a Pixl.js (http://www.espruino.com/Pixl.js) with a shield for ethernet/wifi/gsm if you want to stick with Espruino for everything.

    To buy Pucks I'd just order them direct from me at https://shop.espruino.com/puckjs - you should usually get them in Germany in 3-5 days.

About

Avatar for Gordon @Gordon started