registerDevice method

void registerDevice(
  1. DeviceConfiguration<DeviceRegistration> device,
  2. DeviceRegistration registration
)

Register the specified device for this deployment using the registration options.

Moves the status from StudyDeploymentStatusTypes.Invited to StudyDeploymentStatusTypes.DeployingDevices. A new registration replaces the current one and is added to deviceRegistrationHistory.

Implementation

void registerDevice(DeviceConfiguration device, DeviceRegistration registration) {
  // Mark this deployment as deploying if not already done.
  if (_status.status == StudyDeploymentStatusTypes.Invited) {
    _status.status = StudyDeploymentStatusTypes.DeployingDevices;
  }

  // Add device to currently registered devices and also store it in registration history.
  _registeredDeviceConfigurations[device.roleName] = device;
  _registeredDevices[device.roleName] = registration;

  if (_deviceRegistrationHistory[device] == null) {
    _deviceRegistrationHistory[device] = [];
  }
  _deviceRegistrationHistory[device]!.add(registration);
}