registerDevice method
Register the device with the specified deviceRoleName
for the study
deployment with studyDeploymentId
.
registration
is a matching configuration for the device with deviceRoleName
.
Implementation
@override
Future<StudyDeploymentStatus> registerDevice(
String studyDeploymentId,
String deviceRoleName,
DeviceRegistration registration,
) async {
StudyDeploymentStatus? status;
if (isConfigured()) {
try {
status = await CarpDeploymentService()
.registerDevice(studyDeploymentId, deviceRoleName, registration);
} on CarpServiceException catch (cse) {
// a CarpServiceException is typically because the device is already registred
warning('$runtimeType - $cse');
status = await getStudyDeploymentStatus(studyDeploymentId);
} catch (error) {
// other errors can be rethrown
rethrow;
}
}
if (status != null)
return status;
else
throw CarpBackendException(
"Could not register device in $runtimeType - id: '$studyDeploymentId'");
}