• Thank you very much for this info, I'll give a try to a Cutting Edge build then.

    The exact code where this happen is :

    var global_counter = 0;
    var gatt;
    var busy = false;
    
    
    function write_ble() {
      LED1.write(false);
      
      if (busy) {
        digitalPulse(LED1,1,[10,200,10,200,10]);­
        return;
      }
      busy = true;
      
        NRF.requestDevice({ filters: [{ services: ['4300'] }] }).then(function(device) {
          console.log("Device found !");
          return device.gatt.connect();
        }).then(function(g) {
          console.log("Now gatt.getPrimaryService");
          gatt = g;
          return gatt.getPrimaryService("4300");
        }).then(function(service) {
          return service.getCharacteristic("53415554-4552­-2D2D-4241-53454C2DCAFE");
        }).then(function(characteristic) {
          console.log("Writing !");
          digitalPulse(LED3,1,[10,200,10,200,10]);­
          return characteristic.writeValue([JSON.stringif­y({"chan" : 6, "v" : global_counter++})]);
          //gatt.disconnect();
        }).then(function() {
          console.log("Write finished !");
          digitalPulse(LED2,1,[10,200,10,200,10]);­
          gatt.disconnect();
          console.log("Done!");
          busy=false;
        }).catch(function(e) {
          digitalPulse(LED1,1,10);
          console.log("ERROR",e);
          busy=false;
        });
    
    }
    
    setWatch(write_ble, BTN, { edge:"rising", repeat:true, debounce:50 })
    

    It generates the following output :

    
     ____                 _
    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v00 (c) 2018 G.Williams
    >
    Device found !
    Now gatt.getPrimaryService
    Writing !
    [... After ~15 secs ...]
    ERROR Disconnected
    

    It looks like it takes ~15 seconds to go to the catch and never ends in "Write finished !". I tested to write the property on the other device with the LightBlue Explorer App on iOS 13 with an Iphone SE and it doesn't look like to hang in the same way, but implementation might be totally different.

    The other BLE device is also developed by myself and colleague it's a Linux Embedded with a Laird Bluetooth Module BT830 https://www.lairdconnect.com/wireless-mo­dules/bluetooth-modules/bluetooth-42-and­-40-modules/bt830

    We use a somewhat quirky implementation of BLE for now that seems to work ok with the BLE mobile apps : https://github.com/comarius/bunget but indeed it definitely might be there. I'll debug it further.

About

Avatar for daminetreg @daminetreg started