getIncludedService method
Get an included service (secondary) service form this service.
uuid
the uuid of the included Service.
Not all browsers support this feature yet, so check hasIncludedService first.
-
May throw NotFoundError if the service could not be found.
-
May throw SecurityError if the uuid is on a blocklist.
-
May throw NetworkError if the device is not connected or if there is an error with the communication.
-
May throw StateError if the service is null.
-
May throw NativeAPINotImplementedError if the method is not implemented for this browser. Check hasIncludedService to make sure you don't get this error.
Implementation
Future<BluetoothService> getIncludedService(final String uuid) async {
try {
final service = await _bluetoothService.getIncludedService(uuid);
return BluetoothService(service);
} catch (e) {
final error = e.toString().trim();
if (error.startsWith("NotFoundError")) {
throw NotFoundError.forService(uuid, this.uuid);
} else if (error.startsWith("SecurityError")) {
throw SecurityError(uuid, error);
} else if (error.startsWith("NetworkError")) {
throw NetworkError.withUUid(uuid);
} else if (error.startsWith("InvalidStateError")) {
throw StateError("Service is null");
}
rethrow;
}
}