onEnter method
Called when transitioning into the state.
Implementation
@override
Future<void> onEnter({required FsmOwner owner}) async {
BleDeviceOwner deviceOwner = owner as BleDeviceOwner;
debugPrintSynchronously("OnEnter: BleConfigureState ${deviceOwner.device.getId()}");
deviceOwner._notifyState(state: BleSetupState.configuring);
// Grab configuration step
List<IBleInitCommand> initCommands = deviceOwner.getInitCommands();
for (IBleInitCommand command in initCommands) {
// Execute configuration step
try {
await command.execute(device: deviceOwner.device);
}
on Exception {
// Todo Handle error.
}
on Error {
// Handle error
}
}
// If no more configuration steps available go to ready state.
owner.getFsm()?.handleEvent(
event: BleDeviceConfigurationCompleteEvent(device: deviceOwner.device));
}