• I feel like maybe you're getting code mixed up somewhere? On the BLE UART page it gives you some examples, but you're doing something a bit different: https://www.espruino.com/BLE+UART#receiving-evaluating

    For example you're doing uart.write(device, "true"); but the code in the link above requires you to do require("ble_uart").connect(device) to get a promise that returns a uart instance, and then you do uart.write("true"); on that.

    So your code should look something like:

    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.write("true"); // .then(...)
      setTimeout(function() {
        uart.disconnect();
        console.log("Disconnected");
      }, 2000);
    });
    }
    

    If you want to stay connected you could hang onto the uart variable rather than only using it in sendMessage though

About

Avatar for Gordon @Gordon started