tryUnregisterDisconnectedDevice method
Tries to unregister the device with the deployment service.
Failures are logged, not thrown.
Implementation
Future<void> tryUnregisterDisconnectedDevice(DeviceConfiguration device) async {
final deviceRoleName = device.roleName;
info(
"$runtimeType - Trying to unregister device with role name "
"'$deviceRoleName' for study deployment '${study.studyDeploymentId}'.",
);
try {
final deploymentStatus = await _deploymentService.unregisterDevice(study.studyDeploymentId, deviceRoleName);
// Also update local deployment information about the connected device registrations,
// so that it is in sync with the deployment service.
if (device is! PrimaryDeviceConfiguration) {
deployment?.connectedDeviceRegistrations.remove(deviceRoleName);
}
study.deploymentStatusReceived(deploymentStatus);
} catch (error) {
warning(
"$runtimeType - Failed to unregister device with role name "
"'$deviceRoleName' for study deployment '${study.studyDeploymentId}' "
"at deployment service '$_deploymentService'.\n"
"Error: $error\n"
"Continuing without un-registration.",
);
}
}