getPrimaryService method
Get a the primary services on the current device.
Only services defined in RequestOptions and BluetoothScanFilter from when Bluetooth.requestDevice was called are available.
serviceUUID
is the UUID (lower case) of the service to get.
-
May throw SecurityError if a service's UUID is on a blocklist.
-
May throw NetworkError if the GATT server is not connected.
-
May throw InvalidStateError if GATT is
null
. -
May throw NotFoundError if the services was found.
NOTE: Some services are on a block list, and are thus not available. The complete blocklist can be found here: https://github.com/WebBluetoothCG/registries/blob/master/gatt_blocklist.txt
See:
Implementation
Future<WebBluetoothRemoteGATTService> getPrimaryService(
final String serviceUUID) async {
final promise = _JSUtil.callMethod(
_jsObject, "getPrimaryService", [serviceUUID.toLowerCase()]);
final result = await _JSUtil.promiseToFuture(promise);
return WebBluetoothRemoteGATTService.fromJSObject(result, device);
}