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:
return
uart.write
.on
uart
uart.on
@Gordon started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
On the Puck, maybe try:
There were a few issues on the Puck side:
return
ing the promise fromuart.write
so it'd have returned immediately.on
has executeduart
variable - it would always have been undefined, so theuart.on
code would always fail