The CARP Mobile Sensing (CAMS) Flutter package carp_mobile_sensing is a programming framework for adding digital phenotyping capabilities to your mobile (health) app. CAMS is designed to collect research-quality sensor data from smartphone on-board sensors and attached off-board wearable devices.

Aim and Purpose

Similar to other platforms, CAMS is a state-of-the-art mobile sensing platform with support for the collection of a wide range of data types (see this table for an overview), and with support for various non-functional features like privacy protection and adaptive sensing. CAMS has a set of unique design goals and novel technological contributions:

  • Reactive application programming interface – The CAMS programming API is designed to be simple yet expressive for the programmer. It supports a modern reactive, stream-based programming model allowing for non-blocking sensing and data processing.
  • Unified sensing – CAMS has a unified sensing concept for both on-board and off-board (e.g., wearable) sensing. This allows for a unified way to set up and use data sampling in the app without the need to consider differences in the underlying operating system (OS) or device.
  • Cross-platform – by using Flutter, CAMS supports a unified programming API and programming language for both Android and iOS programming. Hence, the same code base and programming API are used to develop apps for both Android and iOS.
  • Data Management – CAMS has extensive support for different data sampling, transformation, storage, and upload methods. A uniform approach to data transformation is adopted, which supports both privacy-enabling transformations as well as transforming data to make it comply with official data standards.
  • Extensible – Most notably, CAMS is highly extensible in several ways: it allows for implementing new data sampling methods (including both phone sensing, external wearable devices, and cloud-based services); it supports the creation of new data transformers (both for privacy reasons and data standards), and it allows for creating custom data managers, which can upload data in a specific format to specific servers (or other kinds of data offloading).
  • Maintainable – CAMS and all its sub-components are available at pub.dev, which is the Flutter dependency management system that allows for easy access to CAMS libraries and for sharing custom libraries amongst a CAMS programming community.

The basic scenario CAMS seeks to support is to;

… allow programmers to design and implement a custom cross-platform mHealth app, which focuses primarily on providing functionality to the patient.

To this end, CAMS enables programmers to add mobile sensing capabilities in a flexible and straightforward manner to application-specific code bases. This includes configuring the collection of health and behavioral data like ECG, location, activity, and step count; formatting this data according to different health data formats; using this data in the app (e.g., showing it to the user); and uploading it to a specific server, using a specific API (e.g., REST), in a custom format.

Fig. 1 – The CAMS layered architecture which collects data from onboard sensors, wearable devices, and online web services.

Overall Architecture

Fig. 1 shows the overall layered software architecture of CAMS. The CAMS runtime model consists of three main layers: the core runtime, data managers, and the sampling packages, which again build on top of a set of Flutter plugins that access processes and services in the underlying OS, external wearable devices, and cloud-based services. This runtime architecture is designed to achieve the non-functional software architecture goals of being highly extensible, cross-platform, and maintainable.

Components and Packages

CAMS consists of the main carp_moble_sensing Flutter package plus a list of sampling packages and data backend packages. This modular architecture allows the programmer only to include components that are relevant to his/her application. For example, you would only import the carp_context_package package in your app if you’re interested in collecting contextual information like location and air quality and only include the carp_movisens_package package if you’re integrating with the movisens ECG device.

Below is an overview of the main components. A complete list is provided on the main CAMS GitHub page.

On-board Sensing on the Phone

Data from different onboard phone sensors can be collected using different sampling packages. Please see the complete list of available “measures” which can be collected in CAMS. Below is a list of the packages which support this.

Mobile SensingSampling Packages for Mobile Sensing on the Phone
carp_apps_packageApp sampling package (installed apps, app usage)
carp_connectivity_packageConnectivity sampling package (Bluetooth, wifi, connectivity)
carp_communication_packageCommunication sampling package (phone, sms)
carp_context_packageContext sampling package (location, activity, weather)
carp_audio_packageA media sampling package that can collect audio (incl. noise), image, and video data. The label “audio” in the package name is legacy.
carp_survey_packageSampling package for collecting survey data from Research Package and running cognitive tests using the Cognition Package
carp_health_packageSampling package for collecting health data from Apple Health and Google Health Connect
Table 1 – CAMS Sampling Packages for on-board mobile sensing.

Integration to Wearable Devices

The sampling package architecture of CAMS allows for integration directly with wearable devices. By “directly” we mean directly from the sensor to the phone, typically using Bluetooth communication (and not via a web API – this is supported via the CARP Gardener framework). Currently, we have support for the following devices:

  • MovisensMove4, EcgMove4, and EdaMove4 for movement, heart rate, ECG, and EDA data.
  • eSenseEarplug sensor for sound and movement data.
  • Polar – H10 and Verity Sense heart rate sensors.
  • MovesenseMD and Active for heart rate, ECG, and movement sensors
  • Dexcom G7 – Continous Glucose Sensor (CGM).

This is supported via these sampling packages.

Wearables SensingSampling Packages for Wearable Devices
carp_movisens_packageMovisens Move & ECG sampling package (movement, MET-level, ECG)
carp_esense_packageSampling package for the eSense earplug device (button pressed & movement)
carp_polar_packageSampling package for the Polar heart rate monitors
carp_movesense_packageSampling package for the Movesens heart rate and movement monitors
Table 2 – CAMS Sampling Packages for wearable sensing.

Data Managers

CAMS can store or upload data to different databases (e.g., SQLite on the phone) and web-based services (e.g., CAWS or Firebase). See Appendix C for a list of data managers and how to use/configure them.

Flutter Plugins

In addition, the CARP team maintains a set of Flutter plugins (mainly) for sensing purposes. Flutter plugins enable access to platform-specific APIs. The CACHET pub.dev account contains all these plugins and components.

Documentation

The CAMS wiki pages contain overall documentation of the main domain models and how to use and extend CAMS.

Articles

  1. Software Architecture – the overall picture.
  2. Domain Model – the detailed picture of the data model(s).
  3. Using CARP Mobile Sensing – how to use the framework in your app, including how to use the AppTask model.
  4. Extending CARP Mobile Sensing – how to extend the framework, focusing on new sensing capabilities and external (wearable) devices.
  5. Best Practice – tips and tricks, especially related to differences between Android and iOS.

Appendices

Each component and package contains specific documentation, which is available as part of the Flutter README file and the Dart API documentation.

Academic Documentation

More scientific documentation on CAMS is available in the following papers.

  • Bardram, Jakob E. (2020) The CARP Mobile Sensing Framework–A Cross-platform, Reactive, Programming Framework and Runtime Environment for Digital Phenotyping. arXiv preprint arXiv:2006.11904. [pdf]
  • Bardram, Jakob E. (2022). Software Architecture Patterns for Extending Sensing Capabilities and Data Formatting in Mobile Sensing. Sensors22(7), 2813. [pdf]

Please use these as a reference in any scientific papers using CAMS.

Example Apps

There are two example apps available that illustrate how to use CAMS in the design of a Flutter app. In addition, this tutorial explains how to create your 1st CAMS Flutter app.

CARP Mobile Sensing Demo app – this app demonstrates how to use CAMS in an app according to the BLoC architecture. This app demonstrates how to implement background sensing, handle probes, and upload data.

Pulmonary Monitor app – this app demonstrates how user tasks (aka. AppTask) are supported in CAMS. A user task is a task that is added to a list of tasks that the user can “click” and execute. This is typically used for issuing surveys (using the carp_survery_package). But user tasks can also be used for basic sensing tasks (like the collection of weather and air quality). An example of this is shown as the bottom task.