• Hi Gordon,

    as you suggest, for the 'repeater' we can do this:

    NRF.requestDevice({ timeout:1000, filters: [{ name: 'Puck.js abcd' }] }).then(function(device) {
      // found
      NRF.setAdvertising({},{manufacturer:0x59­0,manufacturerData:[1]});
    }).catch(function(e) {
      // not found
      NRF.setAdvertising({},{manufacturer:0x59­0,manufacturerData:[0]});
    });
    

    And for the endpoint (to check the repeater):

    NRF.requestDevice({ timeout:1000,  filters: [{ name: 'Puck.js repeater' }] }).then(function(device) {
      // repeater found
      var originalDeviceFound = device.manufacturerData[0];
    }).catch(function(e) {
      // repeater not found 
    });
    

    Can we can extend this with several repeaters ? is MDBT42Q with Espruino JavaScript interpreter pre-installed, able to be a repeater or an endpoint ?

  • Yes, absolutely - all you have to do is mash the two together for a 'middle' repeater:

    function setFound(found) {
      NRF.setAdvertising({},{manufacturer:0x59­0,manufacturerData:[found ? 1 : 0]});
    }
    
    NRF.requestDevice({ timeout:1000,  filters: [{ name: 'Puck.js repeater' }] }).then(function(device) {
      // repeater found
      setFound(device.manufacturerData[0]);
    }).catch(function(e) {
      // repeater not found 
      setFound(false);
    });
    

    It's worth noting that you could modify this pretty easily to send the status of more than one device (or even some data from another Espruino) by just putting multiple elements in the manufacturerData array.

    is MDBT42Q with Espruino JavaScript interpreter pre-installed, able to be a repeater or an endpoint ?

    It can do anything the Puck does, so yes - it can be either.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

puck as repeater in order to scan a remote puck (out of range from the master)

Posted by Avatar for softysoft @softysoft

Actions