getDescriptors method

Future<List<WebBluetoothRemoteGATTDescriptor>> getDescriptors([
  1. String? descriptorUUID
])

Return a list of WebBluetoothRemoteGATTDescriptor for this characteristic.

descriptorUUID according to the docs this value is optional, but I can't find what would it would do if you set it anyways.

The descriptor describes the values stored on the characteristic.

  • May throw SecurityError if the descriptor's UUID is on a blocklist.

  • May throw NetworkError if the GATT server is not connected.

  • May throw InvalidStateError if characteristic is null.

  • May throw NotFoundError if the descriptor was not found.

See:

Implementation

Future<List<WebBluetoothRemoteGATTDescriptor>> getDescriptors(
    [final String? descriptorUUID]) async {
  final arguments = descriptorUUID == null ? [] : [descriptorUUID];
  final promise = _JSUtil.callMethod(_jsObject, "getDescriptors", arguments);
  final result = await _JSUtil.promiseToFuture(promise);
  if (result is List) {
    final items = <WebBluetoothRemoteGATTDescriptor>[];
    for (final item in result) {
      try {
        items.add(WebBluetoothRemoteGATTDescriptor.fromJSObject(item, this));
      } catch (e, stack) {
        if (e is UnsupportedError) {
          webBluetoothLogger.severe(
              "Could not convert descriptor to BluetoothRemoteGATTDescriptor",
              e,
              stack);
        } else {
          rethrow;
        }
      }
    }
    return items;
  }
  return [];
}