Thanks for your response Gordon.
Code changed to:
var gatt; NRF.connect("30:ae:a4:5d:b3:f2 public").then(function(g) { gatt = g; return gatt.getPrimaryService("6e400001-b5a3-f393-e0a9-e50e24dcca9e"); }).then(function(service) { return service.getCharacteristic("6e400003-b5a3-f393-e0a9-e50e24dcca9e"); }).then(function(characteristic) { characteristic.on('characteristicvaluechanged', function(event) { buf =E.toString(event.target.value.buffer); console.log("RX: "+buf); if(buf.includes("Quit")){ gatt.disconnect(); } }); return characteristic.startNotifications(); }).then(function() { console.log("Done!"); });
The response after uploading the code varies with changing the code, here 3 examples:
____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v06 (c) 2019 G.Williams > Done! RX: D07-06-2020 12.23 RX: SAAPL,311.01,+11.5% RX: SASML,299.45,-4.5% RX: Hottentottententente RX: Quit RX: D07-06-2020 12.23 RX: SAAPL,311.01,+11.5% RX: SASML,299.45,-4.5% RX: Hottentottententente RX: Quit Uncaught Error: BLE task 3 is already in progress at line 1 col 107 ...s("Quit")){gatt.disconnect();} ^ in function called from system RX: D07-06-2020 12.23 RX: SAAPL,311.01,+11.5% >
____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v06 (c) 2019 G.Williams > Done! RX: D07-06-2020 12.23 RX: SAAPL,311.01,+11.5% RX: SASML,299.45,-4.5% RX: Hottentottententente RX: Quit RX: D07-06-2020 12.23 RX: SAAPL,311.01,+11.5% RX: SASML,299.45,-4.5% RX: Hottentottententente RX: Quit Uncaught Error: Not connected at line 1 col 107 ...s("Quit")){gatt.disconnect();} ^ in function called from system >
____ _ | __|___ ___ ___ _ _|_|___ ___ | __|_ -| . | _| | | | | . | |____|___| _|_| |___|_|_|_|___| |_| espruino.com 2v06 (c) 2019 G.Williams > Uncaught Error: Unhandled promise rejection: Disconnected >
Not sure what is happening in the background.
@gerardwr 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.
Thanks for your response Gordon.
Code changed to:
The response after uploading the code varies with changing the code, here 3 examples:
Not sure what is happening in the background.