You are reading a single comment by @Jean-Philippe_Rey and its replies. Click here to read the full conversation.
  • Hi!
    I am playing with GATT with Puck.js being a central device :

    var serviceUUID="2fc3af42-7a4a-1431-d1f1-fs5­51e3bf022";
    var characteristicUUID="32160fb9-5337-4e71-b­0f8-ff412e3ae078";
    var MessageToSend=[0x00,0x01,0x03];
    
    NRF.requestDevice({ filters: [{ name: Devname }] }).then(function(device) {
          return device.gatt.connect();
        }).then(function(g) {
          gatt = g;
          console.log(gatt);
          console.log(gatt);
          console.log(gatt);
          console.log(gatt);
          return gatt.getPrimaryService(serviceUUID);
        }).then(function(service) {
          return service.getCharacteristic(characteristic­UUID);
        }).then(function(characteristic) {
          return characteristic.writeValue(MessageToSend)­;
        }).then(function() {
          gatt.disconnect();
          console.log("Done!");
        });
    
    

    and in the console I get :

    =undefined
    BluetoothRemoteGATTServer {
      "device": BluetoothDevice {
        "id": "96:05:05:f7:ac:1c random",
        "rssi": -57,
        "data": new Uint8Array([2, 1, 26, 10, 255, 76, 0, 16, 5, 1, 16, 139, 101, 67]).buffer,
        "name": "AABBCCDD",
        "gatt":  ...
       },
      "connected": true }
    BluetoothRemoteGATTServer {
      "device": BluetoothDevice {
        "id": "96:05:05:f7:ac:1c random",
        "rssi": -57,
        "data": new Uint8Array([2, 1, 26, 10, 255, 76, 0, 16, 5, 1, 16, 139, 101, 67]).buffer,
        "name": "AABBCCDD",
        "gatt":  ...
       },
      "connected": true }
    BluetoothRemoteGATTServer {
      "device": BluetoothDevice {
        "id": "96:05:05:f7:ac:1c random",
        "rssi": -57,
        "data": new Uint8Array([2, 1, 26, 10, 255, 76, 0, 16, 5, 1, 16, 139, 101, 67]).buffer,
        "name": "AABBCCDD",
        "gatt":  ...
       },
      "connected": false }
    BluetoothRemoteGATTServer {
      "device": BluetoothDevice {
        "id": "96:05:05:f7:ac:1c random",
        "rssi": -57,
        "data": new Uint8Array([2, 1, 26, 10, 255, 76, 0, 16, 5, 1, 16, 139, 101, 67]).buffer,
        "name": "AABBCCDD",
        "gatt":  ...
       },
      "connected": false }
    Uncaught Error: Unhandled promise rejection: Not connected
    > 
    

    having a look at the BluetoothRemoteGATTServer .connected state, is shows true, true,false,false. Why such a behaviour? is there really a timeout anywhere?

About