disconnect method
Ask this DeviceManager to disconnect from the device.
All sampling on this device will be stopped before disconnection is initiate.
Returns true if successful, false if not.
Implementation
@nonVirtual
Future<bool> disconnect() async {
if (!isConnecting) {
warning(
'$runtimeType is not connected, so nothing to disconnect from....',
);
return true;
}
bool success = false;
info('$runtimeType - Trying to disconnect from device of type: $typeName.');
stop();
try {
success = await onDisconnect();
} catch (error) {
warning(
'$runtimeType - Error disconnecting from device of type: $typeName. $error',
);
}
status = (success) ? DeviceStatus.disconnected : status;
// TODO - we should also try to unregister the device from the deployment
// service when it is disconnected by the user/app.
// Need to implement a "tryUnregisterDisconnectedDevice(configuration)"
// method somewhere, like in the ClientManager or DeviceController.
return success;
}