getIncludedServices method
- @Deprecated("Not really deprecated, just not implemented in any browser (yet).")
- String? serviceUUID
Get all included services from this service.
Currently no browser supports this function yet.
This function doesn't exist if the current service has no included services. Check hasGetIncludedServicesFunction to make sure.
serviceUUID
according to the docs this value is optional, but I
can't find what would it would do if you set it anyways.
-
May throw NativeAPINotImplementedError if the function does not exist.
-
May throw SecurityError if the service's UUID is on a blocklist.
-
May throw NetworkError if the GATT server is not connected.
-
May throw InvalidStateError if service is
null
. -
May throw NotFoundError if the service was not found.
See:
ignore: deprecated_member_use_from_same_package
Implementation
@Deprecated(
"Not really deprecated, just not implemented in any browser (yet).")
Future<List<WebBluetoothRemoteGATTService>> getIncludedServices(
final String? serviceUUID) async {
if (!hasGetIncludedServicesFunction()) {
throw NativeAPINotImplementedError("getIncludedServices");
}
final arguments = serviceUUID == null ? [] : [serviceUUID.toLowerCase()];
final promise =
_JSUtil.callMethod(_jsObject, "getIncludedServices", arguments);
final result = await _JSUtil.promiseToFuture(promise);
if (result is List) {
final items = <WebBluetoothRemoteGATTService>[];
for (final item in result) {
try {
items.add(WebBluetoothRemoteGATTService.fromJSObject(item, device));
} catch (e, stack) {
if (e is UnsupportedError) {
webBluetoothLogger.severe(
"Could not convert included service to BluetoothRemoteGATTService",
e,
stack);
} else {
rethrow;
}
}
}
return items;
}
return [];
}