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.
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.
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 dorequire("ble_uart").connect(device)
to get a promise that returns auart
instance, and then you douart.write("true");
on that.So your code should look something like:
If you want to stay connected you could hang onto the
uart
variable rather than only using it in sendMessage though