cph-cachet / carp.core-kotlin

Infrastructure-agnostic framework for distributed data collection.
https://carp.cachet.dk/core/
MIT License
21 stars 3 forks source link

Can't find device with role name 'location_service' in snapshot. #434

Closed bardram closed 1 year ago

bardram commented 1 year ago

I'm trying to upload the protocol below to CAWS and get a

Can't find device with role name 'location_service' in snapshot.

exception back.

This is an example of a "real" CAMS protocol and I can't see what is wrong with it..

CAMS Protocol ``` { "applicationData": { "studyDescription": { "__type": "StudyDescription", "title": "CAMS App - Sensing Coverage Study", "description": "The default study testing coverage of most measures. Used in the coverage tests.", "purpose": "To test sensing coverage", "responsible": { "__type": "StudyResponsible", "id": "abc", "name": "Alex B. Christensen", "title": "professor", "email": "abc@dtu.dk", "address": "Ørsteds Plads", "affiliation": "Technical University of Denmark" } }, "dataEndPoint": { "__type": "CarpDataEndPoint", "type": "CAWS", "dataFormat": "dk.cachet.carp", "uploadMethod": "DATA_POINT", "name": "CARP Web Services", "onlyUploadOnWiFi": false, "uploadInterval": 10, "deleteWhenUploaded": true } }, "id": "0522d100-b783-11ed-b520-f96dc195e899", "createdOn": "2023-02-28T16:14:47.312180Z", "version": 0, "description": "The default study testing coverage of most measures. Used in the coverage tests.", "ownerId": "01dc52c4-b33b-4304-b265-8118c69f5935", "name": "CAMS App v 1.1.0", "primaryDevices": [ { "__type": "dk.cachet.carp.common.application.devices.Smartphone", "roleName": "primaryphone", "defaultSamplingConfiguration": {}, "isPrimaryDevice": true } ], "connectedDevices": [ { "__type": "dk.cachet.carp.common.application.devices.LocationService", "roleName": "location_service", "defaultSamplingConfiguration": {}, "accuracy": "balanced", "distance": 0.0, "interval": 60000000 }, { "__type": "dk.cachet.carp.common.application.devices.WeatherService", "roleName": "weather_service", "defaultSamplingConfiguration": {}, "apiKey": "12b6e28582eb9298577c734a31ba9f4f" }, { "__type": "dk.cachet.carp.common.application.devices.AirQualityService", "roleName": "air_quality_service", "defaultSamplingConfiguration": {}, "apiKey": "9e538456b2b85c92647d8b65090e29f957638c77" }, { "__type": "dk.cachet.carp.common.application.devices.PolarDevice", "roleName": "polar-h10-device", "isOptional": true, "supportedDataTypes": [ "dk.cachet.carp.polar.accelerometer", "dk.cachet.carp.polar.gyroscope", "dk.cachet.carp.polar.magnetometer", "dk.cachet.carp.polar.ppg", "dk.cachet.carp.polar.ppi", "dk.cachet.carp.polar.ecg", "dk.cachet.carp.polar.hr" ], "defaultSamplingConfiguration": {}, "identifier": "B5FC172F", "polarDeviceType": "H10", "name": "Polar H10" } ], "connections": [], "tasks": [ { "__type": "dk.cachet.carp.common.application.tasks.BackgroundTask", "name": "Task #6", "measures": [ { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.triggeredtask" }, { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.completedtask" } ] }, { "__type": "dk.cachet.carp.common.application.tasks.BackgroundTask", "name": "Task #7", "measures": [ { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.stepcount" }, { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.ambientlight" }, { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.screenevent" }, { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.freememory" }, { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.batterystate" } ] }, { "__type": "dk.cachet.carp.common.application.tasks.BackgroundTask", "name": "Task #8", "measures": [ { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.deviceinformation" } ] }, { "__type": "dk.cachet.carp.common.application.tasks.BackgroundTask", "name": "Task #9", "measures": [ { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.activity" } ] }, { "__type": "dk.cachet.carp.common.application.tasks.BackgroundTask", "name": "Task #10", "measures": [ { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.currentlocation" } ] }, { "__type": "dk.cachet.carp.common.application.tasks.BackgroundTask", "name": "Task #11", "measures": [ { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.location" }, { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.mobility" } ] }, { "__type": "dk.cachet.carp.common.application.tasks.BackgroundTask", "name": "Task #12", "measures": [ { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.weather" } ] }, { "__type": "dk.cachet.carp.common.application.tasks.BackgroundTask", "name": "Task #13", "measures": [ { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.airquality" } ] }, { "__type": "dk.cachet.carp.common.application.tasks.BackgroundTask", "name": "Task #14", "measures": [ { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.noise" } ] }, { "__type": "dk.cachet.carp.common.application.tasks.BackgroundTask", "name": "Task #15", "measures": [ { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.connectivity" }, { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.wifi" }, { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.bluetooth" } ] }, { "__type": "dk.cachet.carp.common.application.tasks.BackgroundTask", "name": "Task #16", "measures": [ { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.polar.hr" }, { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.polar.ecg" }, { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.polar.ppg" }, { "__type": "dk.cachet.carp.common.application.tasks.Measure.DataStream", "type": "dk.cachet.carp.polar.ppi" } ] } ], "triggers": { "0": { "__type": "dk.cachet.carp.common.application.triggers.ImmediateTrigger", "sourceDeviceRoleName": "primaryphone" }, "1": { "__type": "dk.cachet.carp.common.application.triggers.ImmediateTrigger", "sourceDeviceRoleName": "primaryphone" }, "2": { "__type": "dk.cachet.carp.common.application.triggers.RandomRecurrentTrigger", "sourceDeviceRoleName": "primaryphone", "startTime": { "hour": 8, "minute": 0, "second": 0 }, "endTime": { "hour": 20, "minute": 0, "second": 0 }, "minNumberOfTriggers": 3, "maxNumberOfTriggers": 8 }, "3": { "__type": "dk.cachet.carp.common.application.triggers.ImmediateTrigger", "sourceDeviceRoleName": "primaryphone" }, "4": { "__type": "dk.cachet.carp.common.application.triggers.PeriodicTrigger", "sourceDeviceRoleName": "primaryphone", "period": 300000000 }, "5": { "__type": "dk.cachet.carp.common.application.triggers.ImmediateTrigger", "sourceDeviceRoleName": "primaryphone" }, "6": { "__type": "dk.cachet.carp.common.application.triggers.PeriodicTrigger", "sourceDeviceRoleName": "primaryphone", "period": 1800000000 }, "7": { "__type": "dk.cachet.carp.common.application.triggers.PeriodicTrigger", "sourceDeviceRoleName": "primaryphone", "period": 1800000000 }, "8": { "__type": "dk.cachet.carp.common.application.triggers.ImmediateTrigger", "sourceDeviceRoleName": "primaryphone" }, "9": { "__type": "dk.cachet.carp.common.application.triggers.ImmediateTrigger", "sourceDeviceRoleName": "primaryphone" }, "10": { "__type": "dk.cachet.carp.common.application.triggers.ImmediateTrigger", "sourceDeviceRoleName": "primaryphone" } }, "taskControls": [ { "triggerId": 0, "taskName": "Task #6", "destinationDeviceRoleName": "primaryphone", "control": "Start" }, { "triggerId": 1, "taskName": "Task #7", "destinationDeviceRoleName": "primaryphone", "control": "Start" }, { "triggerId": 2, "taskName": "Task #8", "destinationDeviceRoleName": "primaryphone", "control": "Start" }, { "triggerId": 3, "taskName": "Task #9", "destinationDeviceRoleName": "primaryphone", "control": "Start" }, { "triggerId": 4, "taskName": "Task #10", "destinationDeviceRoleName": "location_service", "control": "Start" }, { "triggerId": 5, "taskName": "Task #11", "destinationDeviceRoleName": "location_service", "control": "Start" }, { "triggerId": 6, "taskName": "Task #12", "destinationDeviceRoleName": "weather_service", "control": "Start" }, { "triggerId": 7, "taskName": "Task #13", "destinationDeviceRoleName": "air_quality_service", "control": "Start" }, { "triggerId": 8, "taskName": "Task #14", "destinationDeviceRoleName": "primaryphone", "control": "Start" }, { "triggerId": 9, "taskName": "Task #15", "destinationDeviceRoleName": "primaryphone", "control": "Start" }, { "triggerId": 10, "taskName": "Task #16", "destinationDeviceRoleName": "polar-h10-device", "control": "Start" } ], "participantRoles": [], "assignedDevices": {}, "expectedParticipantData": [] } ```
bardram commented 1 year ago

The problem seems to arise here:

https://github.com/cph-cachet/carp.core-kotlin/blob/9469ae550eaba920a0ab13464ebbcbfe1263d2ba/carp.protocols.core/src/commonMain/kotlin/dk/cachet/carp/protocols/domain/StudyProtocol.kt#L133

So - even thought the Location Service is listed in the list of connected devices, the protocol.devices don't seems to have it?

bardram commented 1 year ago

I found the problem. I haven't notices that the addConnectedDevice now takes two parameters:

https://github.com/cph-cachet/carp.core-kotlin/blob/9469ae550eaba920a0ab13464ebbcbfe1263d2ba/carp.protocols.core/src/commonMain/kotlin/dk/cachet/carp/protocols/domain/StudyProtocol.kt#L222

I've updated it on the Dart side and it works now - I can upload CAMS protocols to CAWS 🎉