1. Define Protocol
Model what to collect using triggers, tasks, devices, and measures.
2. Deploy Protocol
Deploy through a
DeploymentService (local or remote).3. Start Runtime
Configure
SmartPhoneClientManager and initialize a deployment controller.4. Consume Data
Listen to the
measurements stream and process or upload data.CAMS can run fully local on-device (including protocol creation and deployment), which is useful for many app scenarios.
End-to-end flow
1
Define a study protocol
Configure a
StudyProtocol with devices and measures to collect.2
Deploy protocol to a deployment service
Use a
DeploymentService (for example SmartphoneDeploymentService) to create a study deployment.3
Initialize client runtime
Configure a
SmartPhoneClientManager, add the study, and deploy it.4
Resume or pause data sampling
Resume or pause data sampling in all studies or control each study.
5
Consume or save collected measurements
Listen on the
measurements stream of one or more studies and use it in the app.1) Define a study protocol
In CAMS, sensing is configured in aSmartphoneStudyProtocol.
You can use the Dart API to create a protocol directly in your app like this:
For deeper model details, see Domain Model and Measure Types.
For transformation formats and privacy schemas, see Data Transformation and Privacy.
2) Deploy the protocol (optional)
A study protocol is deployed via aDeploymentService.
3) Create a client runtime, and add and deploy studies
Runtime management of studies is handed by the client managerSmartPhoneClientManager.
The most simple configuration of the client manager is:
registration: unique device registration for this phone.deploymentService: deployment backend (default is localSmartphoneDeploymentService).dataCollectorFactory: custom collector factory (default uses the standardDeviceController).enableNotifications: show task notifications (trueby default).enableBackgroundMode: run sampling in background (trueby default, Android only).backgroundNotificationTitle/backgroundNotificationText: text for Android background notification.askForPermissions: request package permissions automatically (trueby default).
- Default
- Customized
SmartphoneDeploymentService, deploying and adding a study based on a protocol can be written more compact like this:
4) Control data sampling
Data sampling can be controlled by theresume and pause methods:
resume() or pause() on the client manager will resume or pause all studies added to the client. If you want more fine-grained control over each study, you can control each study using its SmartphoneStudyController:
stop which will permanently stop the study - once stopped, and study cannot be (re)started. Call dispose to dispose of the client - typically in the Flutter dispose method.
5) Consume or listening to measurements
All sampling data is available in the measurements stream. This stream is available on both controller and client:
Stream, you can subscribe, filter, map, etc. as needed.
- Subscription example
- Filter example
- Map example