used code:
bleSendJS = function(_id, _cmd) { console.log('s'); NRF.requestDevice({timeout: 5E3, filters: [{ id: _id }] }).then(function(device) { console.log('f'); console.log(device); return require("ble_uart").connect(device); }).then(function(uart) { console.log('c'); var data; uart.on('data', function(d) { data += d; }); uart.write(`\x03\x10(${_cmd})\n`).then(function() { setTimeout(function() { uart.disconnect(); console.log('output:',data); console.log("Disconnected"); }, 2000); }); }).catch(function(e) { console.log("ERROR:", e); }); };
output
>bleSendJS(id, nl1); =undefined BluetoothDevice: { "id": "d5:c7:e2:67:ac:f0 random", "rssi": -81, "data": new Uint8Array([2, 1, 6, 12, 9, 73, 79, 50, 52, 52, 55, 32, 97, 99, 102, 48]).buffer } ERROR: Disconnected Uncaught Error: Unhandled promise rejection: Error: Unhandled promise rejection: InternalError: BLE task completed that wasn't scheduled (4/0) >
Is there a way to avoid that?
@MaBe 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.
used code:
output
Is there a way to avoid that?