gatt property

Get a reference to the NativeBluetoothRemoteGATTServer to communicate with the WebBluetoothRemoteGATTServices.

Some devices may allow you to find them, but they are on a blocklist restricting the ability to communicate with its GATT service. In this case the returned value will be null.

See:

Implementation

NativeBluetoothRemoteGATTServer? get gatt {
  final gatt = _gatt;
  if (gatt != null) {
    return gatt;
  }
  if (!_JSUtil.hasProperty(_jsObject, "gatt")) {
    return null;
  }
  final newGatt = _JSUtil.getProperty(_jsObject, "gatt");
  if (newGatt != null) {
    try {
      _gatt = NativeBluetoothRemoteGATTServer.fromJSObject(newGatt, this);
    } catch (e, stack) {
      if (e is UnsupportedError) {
        webBluetoothLogger.severe(
            "Could not convert gatt to BluetoothRemoteGattServer", e, stack);
      } else {
        rethrow;
      }
    }
  }
  return _gatt;
}