connect method

Future<void> connect({
  1. bool isAutoConnect = false,
  2. int requestMtu = NO_MTU_NEGOTIATION,
  3. bool refreshGatt = false,
  4. Duration? timeout,
})

Connects to the peripheral.

Optional isAutoConnect controls whether to directly connect to the remote peripheral (false) or to automatically connect as soon as the remote peripheral becomes available (true). (Android only)

Optional requestMtu size will be negotiated to this value. It is not guaranteed to get it after connection is successful. (Android only) iOS by default requests about 186 MTU size and there's nothing anyone can do about it. NOTE: if MTU has been requested on this step, then there's no way to retrieve its value later on.

Passing true as refreshGatt will reset services cache. This option may be useful when a peripheral's firmware was updated and it's services/characteristics were added/removed/altered. (Android only)

Optional timeout is used to define delay after which the connection is automatically cancelled. In case of race condition were connection is established right after timeout event, peripheral will be disconnected immediately. Timeout may happen earlier than specified due to OS specific behavior.

Implementation

Future<void> connect(
        {bool isAutoConnect = false,
        int requestMtu = NO_MTU_NEGOTIATION,
        bool refreshGatt = false,
        Duration? timeout}) =>
    _manager.connectToPeripheral(identifier,
        isAutoConnect: isAutoConnect,
        requestMtu: requestMtu,
        refreshGatt: refreshGatt,
        timeout: timeout);