• 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-f3­93-e0a9-e50e24dcca9e");
    }).then(function(service) {
      return service.getCharacteristic("6e400003-b5a3­-f393-e0a9-e50e24dcca9e");
    }).then(function(characteristic) {
      characteristic.on('characteristicvaluech­anged', function(event) {
        console.log("RX: "+E.toString(event.target.value.buffer))­;
      });
      return characteristic.startNotifications();
    }).then(function() {
      console.log("Done!");
    });
    

    The code:

    • connects OK to my BLE UART server (An ESP32 with Arduino BLE server code that repeats sending BLE-UART messages)
    • 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?

About

Avatar for gerardwr @gerardwr started