• Ahh - ok. Right, well, first off to detect the feather, using MAC address is great if it's just one-off. You can see it reports as:

      BluetoothDevice: {
        "id": "ff:8d:05:ae:17:64 random",
        "rssi": -45,
        "data": new Uint8Array([2, 1, 6, 2, 10, 0, 17, 6, 158, 202, 220, 36, 14, 229, 169, 224, 147, 243, 163, 181, 1, 0, 64, 110]).buffer,
        "services": [
          "6e400001-b5a3-f393-e0a9-e50e24dcca9e"
         ]
       },
    

    So you can do:

    NRF.requestDevice({ filters: [{ services: ['6e400001-b5a3-f393-e0a9-e50e24dcca9e"'] }] }).then(function(device) { ... });
    

    To return any device advertising the Nordic UART service.

    What you're doing with Serial1.* is you're using the physical UART on the Puck on pins D28/29 - that's nothing to do with Bluetooth. What you need is https://www.espruino.com/BLE+UART

    So your code would be more like:

    // Function to send a message
    function sendMessage(message) {
      NRF.connect("ff:8d:05:ae:17:64 random").then(function(d)   {
        device = d;
        console.log("Device ",device);
        require("ble_simple_uart").write(device, message, function() {
          print('Done!');
        });
      });
    }
    // Send a message when the button is pressed
    setWatch(function() {
      sendMessage("Hello, Arduino!");
    }, BTN, { edge: "rising", debounce: 50, repeat: true });
    
About

Avatar for Gordon @Gordon started