setAdvertisementAndConnectionInterval method

Future<bool> setAdvertisementAndConnectionInterval(
  1. int advMinInterval,
  2. int advMaxInterval,
  3. int connMinInterval,
  4. int connMaxInterval,
)

Requests a change of the advertisement and connection intervals on the connected device.

Condition for advertisement interval:

  • the minimum interval should be greater than or equal to 100
  • the maximum interval should be less than or equal to 2000
  • the maximum interval should be greater than or equal to the minimum interval.

Condition for connection interval:

  • the minimum interval should be greater than or equal to 20
  • the maximum interval should be less than or equal to 2000
  • the difference between the maximum and minimum intervals should be greater than or equal to 20.

Returns true if the request was successfully made, false otherwise.

Implementation

Future<bool> setAdvertisementAndConnectionInterval(int advMinInterval,
    int advMaxInterval, int connMinInterval, int connMaxInterval) async {
  if (!connected) {
    throw ESenseException('Not connected to any eSense device.');
  }
  return await _eSenseManagerMethodChannel.invokeMethod<bool?>(
          'setAdvertisementAndConnectiontInterval', <String, dynamic>{
        'advMinInterval': advMinInterval,
        'advMaxInterval': advMaxInterval,
        'connMinInterval': connMinInterval,
        'connMaxInterval': connMaxInterval,
      }) ??
      false;
}