discoverServices method

Future<List<BleService>> discoverServices({
  1. Duration? timeout,
  2. bool withDescriptors = false,
  3. String? queueId,
  4. DiscoverServicesPlatformConfig? platformConfig,
})

Discovers the services offered by the device.

Returns cached services if already discovered after connection. timeout bounds the call, and on Apple the native discovery too (see BleShieldNative.discoverServices). platformConfig: platform-specific options, e.g. Android's clearGattCache.

Implementation

Future<List<BleService>> discoverServices({
  Duration? timeout,
  bool withDescriptors = false,
  String? queueId,
  DiscoverServicesPlatformConfig? platformConfig,
}) async {
  List<BleService> servicesCache = await BleShieldNative.discoverServices(
    deviceId,
    withDescriptors: withDescriptors,
    timeout: timeout,
    queueId: queueId,
    platformConfig: platformConfig,
  );
  CacheHandler.instance.saveServices(
    BleShieldNative.canonicalDeviceId(deviceId),
    servicesCache,
  );
  return servicesCache;
}