addConnectedDevice method

  1. @override
bool addConnectedDevice(
  1. DeviceConfiguration<DeviceRegistration> device,
  2. PrimaryDeviceConfiguration<DeviceRegistration> primaryDevice
)
override

Add a device which is connected to the primaryDevice. Its role name should be unique in the protocol.

Returns true if the device has been added; false if it is already connected to the specified primaryDevice.

Implementation

@override
bool addConnectedDevice(
  DeviceConfiguration device,
  PrimaryDeviceConfiguration primaryDevice,
) {
  super.addConnectedDevice(device, primaryDevice);

  // add the trigger, task, and heartbeat measures to the protocol since CAMS
  // always collects and upload this data from any device
  addTaskControl(
    NoOpTrigger(),
    BackgroundTask(measures: [
      Measure(type: Heartbeat.dataType),
      Measure(type: CarpDataTypes.TRIGGERED_TASK_TYPE_NAME),
      Measure(type: CarpDataTypes.COMPLETED_TASK_TYPE_NAME)
    ]),
    device,
    Control.Start,
  );

  return true;
}