• On the Puck, maybe try:

    function sendMessage() {
      console.log("Trying to Connect");
      NRF.requestDevice({ filters: [{ id: feather }], active:true }).then(function(device) {
      return require("ble_uart").connect(device);
    }).then(function(_uart) {
      uart = _uart;
      uart.on('data', function(d) {
        console.log("Got:"+JSON.stringify(d));
      });
      return uart.write("1");
    }).then(function() {
      console.log("Message sent successfully.");  
    });
    }
    

    There were a few issues on the Puck side:

    • you weren't returning the promise from uart.write so it'd have returned immediately
    • best to register to receive the data before it's sent, or maybe the data will come back before the .on has executed
    • You were never setting the value of the global uart variable - it would always have been undefined, so the uart.on code would always fail
About

Avatar for Gordon @Gordon started