carp_mobile_sensing 0.3.2

  • Example
  • Installing
  • Versions
  • 74

CARP Mobile Sensing Framework in Flutter #

This library contains the software architecture for the CARP sensing framework implemented in Flutter. Supports cross-platform (iOS and Android) sensing.

pub package

For Flutter plugins for other CARP products, see CARP Mobile Sensing in Flutter.

Usage #

To use this plugin, add carp_mobile_sensing as a dependency in your pubspec.yaml file.

This plugin relies on json_serialization: ^1.0.0 which again rely on Dart 2.1.

Note that there are two issues with Android to consider:

  • Issue #1 - make sure your app's android build.gradle has a minSdkVersion 19 (instead of 16 ).
  • Issue #2 - update the he file build.gradle in flutter_blue and change the JDK parameters to 26 (instead of 27).

Android Integration #

Add the following to your app's manifest.xml file located in android/app/src/main:

<manifest xmlns:android=""

   <!-- The following permissions are used for CARP Mobile Sensing -->
   <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions"/>


iOS Integration #

Add this permission in the Info.plist file located in ios/Runner:


Documentation #

The Dart API doc describes the different libraries and classes.

The wiki contains detailed documentation on the CARP Mobile Sensing Framework, including the domain model, its built-in probes, and how to extend it.

Below is a few simple / minimum examples (a better description is available on the wiki).

Examples #

In the following example, a study is created "by hand", i.e. you specify each task and measure in the study.

// Import package
import 'package:carp_mobile_sensing/carp_mobile_sensing.dart';

some_method() async {
  // Create a study using a File Backend
  Study study = Study("1234", "bardram", name: "bardram study");
  study.dataEndPoint = FileDataEndPoint()
    ..bufferSize = 500 * 1000 = true
    ..encrypt = false;

  // add sensor collection from accelerometer and gyroscope
  // careful - these sensors generate a lot of data!
  study.addTask(Task('Sensor Task')
    ..addMeasure(PeriodicMeasure(MeasureType(NameSpace.CARP, DataType.ACCELEROMETER),
        frequency: 10 * 1000, // sample every 10 secs)
        duration: 100 // for 100 ms
    ..addMeasure(PeriodicMeasure(MeasureType(NameSpace.CARP, DataType.GYROSCOPE),
        frequency: 20 * 1000, // sample every 20 secs
        duration: 100 // for 100 ms

  study.addTask(Task('Task collecting a list of all installed apps')
    ..addMeasure(Measure(MeasureType(NameSpace.CARP, DataType.APPS))));

  // Create a Study Controller that can manage this study, initialize it, and start it.
  StudyController controller = StudyController(study);
  await controller.initialize();

  // listening on all data events from the study;

  // listen on only CARP events => datum.format.namepace == NameSpace.CARP).forEach(print);

  // listening on a specific probe

However, you can se up a study quite simple, by using sampling schemas. Below is an example of this:

 StudyController controller = StudyController(
    samplingSchema: SamplingSchema.common(),

  await controller.initialize();

  // listening on all data events from the study;

There is a very simple example app app which shows how a study can be created with different tasks and measures. This app just prints the sensing data to a console screen on the phone.

However, the CARP Mobile Sensing App provides a MUCH better example of how to use the package in a Flutter BLoC architecture, including good documentation of how to do this.

Features and bugs #

Please read about existing issues and file new feature requests and bug reports at the issue tracker.

License #

This software is copyright (c) 2018 Copenhagen Center for Health Technology (CACHET) at the Technical University of Denmark (DTU). This software is made available 'as-is' in a MIT license.

0.3.2 #

  • support for dividing probes into separate sampling packages
  • included in carp_mobile_sensing are
    • device (device, screen, memory, battery)
    • sensors (sensors, light, pedometer)
    • connectivity (connectivity, bluetooth)
    • apps (installed apps, app usage)
  • implementation of the following external probe packages:
    • communication (sms & call log)
    • context (location, activity, weather)
    • audio (noise, audio recording)
    • movisens (Movisens Move/ECG devices)

0.3.1 #

  • small updates to the data format incl. documentation on the wiki.
  • fixed error in the stop method.

0.3.0 - no backward compatibility #

  • major updates to the domain model as a core library
    • Measure now have a configuration
  • simplification to probe implementations
  • all probes now uses the Dart Stream API and supports a reactive programming model
  • all probes adjusted to a stream model
  • implementation of SamplingSchema architecture
  • support for power-aware sampling using different sampling schemas

0.2.6 #

  • fixed small bug in weater probe.

0.2.5 #

  • small bug fixes in connectivity datum model (to work w. `carp_firebase_backend).
  • weather probe added.

0.2.4 #

  • error in light probe fixed.
  • noise probe added.
  • using the carp_core domain model

0.2.3 #

  • fixed error in readme file.

0.2.2 #

  • phone_log probe added
  • audio probe added
  • activity probe added
  • improvement to readme file on manifest.xml and Info.plist.

0.2.1 #

  • re-organization of github location and outline
  • improvements to FileDataManager to avoid race conditions
  • improved API documentation

0.2.0 #

  • refactor of organization of classes into libraries
  • complete API documentation

0.1.1 #

  • small improvements incl. documentation

0.1.0 #

  • removal of all remote backend code to separate packages

0.0.1 #

  • Initial version by Jakob E. Bardram
  • Transferring the old implementation to this carp.sensing-flutter framework
  • General refactor and clean-up


CARP Mobile Sensing Example #

Demonstrates how to use the carp_mobile_sensing plugin.

Getting Started #

For help getting started with Flutter, view our online documentation.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  carp_mobile_sensing: ^0.3.2

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter packages get

Alternatively, your editor might support flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:carp_mobile_sensing/carp_mobile_sensing.dart';
Version Uploaded Documentation Archive
0.3.2 Feb 4, 2019 Go to the documentation of carp_mobile_sensing 0.3.2 Download carp_mobile_sensing 0.3.2 archive
0.3.1 Jan 25, 2019 Go to the documentation of carp_mobile_sensing 0.3.1 Download carp_mobile_sensing 0.3.1 archive
0.3.0 Jan 21, 2019 Go to the documentation of carp_mobile_sensing 0.3.0 Download carp_mobile_sensing 0.3.0 archive
0.2.6 Dec 5, 2018 Go to the documentation of carp_mobile_sensing 0.2.6 Download carp_mobile_sensing 0.2.6 archive
0.2.5 Dec 5, 2018 Go to the documentation of carp_mobile_sensing 0.2.5 Download carp_mobile_sensing 0.2.5 archive
0.2.4 Nov 15, 2018 Go to the documentation of carp_mobile_sensing 0.2.4 Download carp_mobile_sensing 0.2.4 archive
0.2.3 Nov 5, 2018 Go to the documentation of carp_mobile_sensing 0.2.3 Download carp_mobile_sensing 0.2.3 archive
0.2.2 Nov 5, 2018 Go to the documentation of carp_mobile_sensing 0.2.2 Download carp_mobile_sensing 0.2.2 archive
0.2.1 Oct 21, 2018 Go to the documentation of carp_mobile_sensing 0.2.1 Download carp_mobile_sensing 0.2.1 archive
0.2.0 Oct 14, 2018 Go to the documentation of carp_mobile_sensing 0.2.0 Download carp_mobile_sensing 0.2.0 archive

All 12 versions...

Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13
  • Flutter: 1.2.0


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health issues and suggestions

Fix lib/probes/sensors/light_probe.dart. (-25 points)

Analysis of lib/probes/sensors/light_probe.dart failed with 1 error:

line 37 col 41: The getter 'lightSensorStream' isn't defined for the class 'Light'.

Fix lib/core/serialization.dart. (-0.50 points)

Analysis of lib/core/serialization.dart reported 1 hint:

line 16 col 10: Name non-constant identifiers using lowerCamelCase.

Fix lib/runtime/sampling_package.dart. (-0.50 points)

Analysis of lib/runtime/sampling_package.dart reported 1 hint:

line 4 col 26: Name non-constant identifiers using lowerCamelCase.

Fix additional 27 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/core/carp_datapoint.dart (Run flutter format to format lib/core/carp_datapoint.dart.)
  • lib/core/datum.dart (Run flutter format to format lib/core/datum.dart.)
  • lib/core/device_info.dart (Run flutter format to format lib/core/device_info.dart.)
  • lib/core/managers.dart (Run flutter format to format lib/core/managers.dart.)
  • lib/core/measures.dart (Run flutter format to format lib/core/measures.dart.)
  • lib/core/privacy_schema.dart (Run flutter format to format lib/core/privacy_schema.dart.)
  • lib/core/sampling_schema.dart (Run flutter format to format lib/core/sampling_schema.dart.)
  • lib/core/study.dart (Run flutter format to format lib/core/study.dart.)
  • lib/core/tasks.dart (Run flutter format to format lib/core/tasks.dart.)
  • lib/datastore/local/file_data_manager.dart (Run flutter format to format lib/datastore/local/file_data_manager.dart.)
  • lib/probes/apps/app_probes.dart (Run flutter format to format lib/probes/apps/app_probes.dart.)
  • lib/probes/apps/apps_datum.dart (Run flutter format to format lib/probes/apps/apps_datum.dart.)
  • lib/probes/apps/apps_package.dart (Run flutter format to format lib/probes/apps/apps_package.dart.)
  • lib/probes/connectivity/connectivity_datum.dart (Run flutter format to format lib/probes/connectivity/connectivity_datum.dart.)
  • lib/probes/connectivity/connectivity_package.dart (Run flutter format to format lib/probes/connectivity/connectivity_package.dart.)
  • lib/probes/connectivity/connectivity_probes.dart (Run flutter format to format lib/probes/connectivity/connectivity_probes.dart.)
  • lib/probes/device/device_datum.dart (Run flutter format to format lib/probes/device/device_datum.dart.)
  • lib/probes/device/device_package.dart (Run flutter format to format lib/probes/device/device_package.dart.)
  • lib/probes/device/device_probes.dart (Run flutter format to format lib/probes/device/device_probes.dart.)
  • lib/probes/sensors/pedometer_datum.dart (Run flutter format to format lib/probes/sensors/pedometer_datum.dart.)
  • lib/probes/sensors/pedometer_probe.dart (Run flutter format to format lib/probes/sensors/pedometer_probe.dart.)
  • lib/probes/sensors/sensor_datum.dart (Run flutter format to format lib/probes/sensors/sensor_datum.dart.)
  • lib/probes/sensors/sensor_package.dart (Run flutter format to format lib/probes/sensors/sensor_package.dart.)
  • lib/probes/sensors/sensor_probes.dart (Run flutter format to format lib/probes/sensors/sensor_probes.dart.)
  • lib/runtime/executors.dart (Run flutter format to format lib/runtime/executors.dart.)
  • lib/runtime/probes.dart (Run flutter format to format lib/runtime/probes.dart.)
  • lib/runtime/study_controller.dart (Run flutter format to format lib/runtime/study_controller.dart.)


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
app_usage ^0.0.2 0.0.3
archive ^2.0.4 2.0.8
async ^2.0.8 2.0.8
battery ^0.2.3 0.2.3 0.3.0+1
connectivity ^0.3.2 0.3.2 0.4.2
device_apps ^1.0.0 1.0.5
device_info ^0.2.1 0.2.1 0.4.0+1
flutter 0.0.0
flutter_blue ^0.4.1 0.4.2 0.5.0
json_annotation ^1.0.0 1.2.0 2.0.0
light ^0.0.3 0.0.6
path_provider ^0.4.1 0.4.1 0.5.0+1
pedometer ^0.0.3 0.0.5
screen_state ^0.0.1 0.0.1
sensors ^0.3.4 0.3.5 0.4.0+1
simple_permissions ^0.1.9 0.1.9
stats ^0.2.0 0.2.0+2
system_info ^0.1.0 0.1.0
uuid ^1.0.0 1.0.3 2.0.0
Transitive dependencies
args 1.5.1
charcode 1.1.2
collection 1.14.11
convert 2.1.1
crypto 2.0.6
file_utils 0.1.1
fixnum 0.10.9
globbing 0.2.0
meta 1.1.6 1.1.7
path 1.6.2
protobuf 0.10.8 0.13.3
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
build_runner any
json_serializable ^1.0.0
test any