addPrimaryDevice method
Add a primary device (e.g., a phone) which is responsible for aggregating and synchronizing incoming data. Its role name should be unique in the protocol.
Returns true if the primaryDevice
has been added; false if it is already
set as a primary device.
Implementation
@override
bool addPrimaryDevice(PrimaryDeviceConfiguration primaryDevice) {
super.addPrimaryDevice(primaryDevice);
// add the trigger, task, error, and heartbeat measures to the protocol since
// CAMS always collects and upload this data from the primary device (the phone)
addTaskControl(
NoOpTrigger(),
BackgroundTask(measures: [
Measure(type: Heartbeat.dataType),
Measure(type: Error.dataType),
Measure(type: CarpDataTypes.TRIGGERED_TASK_TYPE_NAME),
Measure(type: CarpDataTypes.COMPLETED_TASK_TYPE_NAME)
]),
primaryDevice,
Control.Start,
);
return true;
}