onEnter method

  1. @override
Future<void> onEnter({
  1. required FsmOwner owner,
})
override

Called when transitioning into the state.

Implementation

@override
Future<void> onEnter({required FsmOwner owner}) async {
  BleDeviceOwner deviceOwner = owner as BleDeviceOwner;
  debugPrintSynchronously("OnEnter: BleDeviceDisconnectingState ${deviceOwner.device.getId()}");

  // Attempt reconnect logic.
  deviceOwner._notifyState(state: BleSetupState.disconnecting);
  // Grab configuration step
  List<IBleInitCommand> initCommands = deviceOwner.getInitCommands();
  for (IBleInitCommand command in initCommands) {
    try {
      // Undo configuration step
      await command.undo(device: deviceOwner.device);
    }
    on Exception {
      // Todo handle error
    }
    on Error {
      // Handle error
    }
  }
  await deviceOwner.device
      .disconnect(); /*.then((value) => deviceOwner.handleEvent(
      event: BleDeviceConnectionStateChangedEvent(
          device: deviceOwner.device,
          newState: BleConnectionState.disconnected)));*/
}