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.

The CAMS layered architecture: data managers, runtime and sampling packages on top of Flutter plugins and the operating system, connecting to wearable devices and online services
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.

PackageWhat it collectsDocsSourcepub.dev
carp_apps_packageInstalled apps and app usageDocsGitHubpub.dev
carp_connectivity_packageBluetooth, Wi-Fi, and connectivityDocsGitHubpub.dev
carp_communication_packagePhone calls and text messages (SMS)DocsGitHubpub.dev
carp_context_packageLocation, activity, weather, and air qualityDocsGitHubpub.dev
carp_audio_packageAudio (incl. noise), images, and video. The label “audio” in the package name is legacy.DocsGitHubpub.dev
carp_survey_packageSurveys from Research Package and cognitive tests from Cognition PackageDocsGitHubpub.dev
carp_health_packageHealth data from Apple Health and Google Health ConnectDocsGitHubpub.dev
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:

  • Movisens – Move4, EcgMove4, and EdaMove4 for movement, heart rate, ECG, and EDA data.
  • eSense – Earplug sensor for sound and movement data.
  • Polar – H10 and Verity Sense heart rate sensors.
  • Movesense – MD and Active for heart rate, ECG, and movement sensors
  • Dexcom CGM – continuous glucose monitor.
  • Apple Watch – motion, heart rate, location, and ambient noise via the AWARE watchOS framework.
Wearable devices supported by CAMS: eSense earbud, Movesense sensors, Polar heart rate strap, Movisens sensor, Apple Watch running CARP, and a Dexcom CGM sensor

This is supported via these sampling packages.

PackageWhat it collectsDocsSourcepub.dev
carp_movisens_packageMovisens Move and ECG devices (movement, MET level, ECG)DocsGitHubpub.dev
carp_esense_packageeSense earplug (button presses and movement)DocsGitHubpub.dev
carp_polar_packagePolar heart rate monitorsDocsGitHubpub.dev
carp_movesense_packageMovesense heart rate and movement sensorsDocsGitHubpub.dev
carp_aware_packageApple Watch via the AWARE watchOS framework (motion, heart rate, location, noise, and more)DocsGitHubpub.dev
Table 2 – CAMS sampling packages for wearable devices.

Data Managers

CAMS can store or upload data to different databases (e.g., SQLite on the phone) and web-based services (e.g., CAWS). See the data managers documentation for a list of data managers and how to use and 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 CARP pub.dev publisher account contains all these plugins and components.

Documentation

The technical documentation for CAMS is available on docs.carp.dk. It covers the main domain models and how to use and extend CAMS:

  • Quickstart – build your first Flutter app that collects data with CAMS.
  • Installation – how to add CAMS to your app, including Android and iOS setup.
  • Architecture – the overall picture, from study protocol to data upload.
  • Domain model – the detailed picture of the data model(s), including the AppTask model.
  • Using CAMS – how to use the framework in your app.
  • Measure types – all the data types CAMS can collect, and their data format.
  • Data managers – how to store data on the phone or upload it to a server.
  • Extending CAMS – how to extend the framework with new sensing capabilities and external (wearable) devices.
  • Building sampling packages – how to write your own sampling package.
  • Best practices – tips and tricks, especially related to differences between Android and iOS.
  • API reference – links to the Dart API documentation for every CARP package.

Each package also has its own README and Dart API documentation on pub.dev.

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. Sensors, 22(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_survey_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.