Hi,
Espruino beginner here, in need for some help.
I am running code from here: https://www.espruino.com/BLE+UART
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) { console.log("RX: "+E.toString(event.target.value.buffer)); }); return characteristic.startNotifications(); }).then(function() { console.log("Done!"); });
The code:
displays the data sent by the BLE server in the Espruino IDE.  Data is like:
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 RX: D07-06-2020 12.23
But I would like to disconnect from the server when data “Quit” is received.
Something like:
if(buffer.includes("Quit"){ gatt.disconnect(); }
Have read many things, search the forum, and tried many examples, to no avail.
Who can help along?
@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.
Hi,
Espruino beginner here, in need for some help.
I am running code from here:
https://www.espruino.com/BLE+UART
The code:
displays the data sent by the BLE server in the Espruino IDE.

Data is like:
But I would like to disconnect from the server when data “Quit” is received.
Something like:
Have read many things, search the forum, and tried many examples, to no avail.
Who can help along?