This library contains the software architecture for the CARP sensing framework implemented in Flutter. Supports cross-platform (iOS and Android) sensing.
For Flutter plugins for other CARP products, see CARP Mobile Sensing in Flutter.
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:
build.gradle
has a minSdkVersion 19
(instead of 16
).build.gradle
in flutter_blue
and change the JDK parameters to 26
(instead of 27
).Add the following to your app's manifest.xml
file located in android/app/src/main
:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="<your_package_name>"
xmlns:tools="http://schemas.android.com/tools">
...
<!-- The following permissions are used for CARP Mobile Sensing -->
<uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" tools:ignore="ProtectedPermissions"/>
</manifest>
Add this permission in the Info.plist
file located in ios/Runner
:
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
<string>bluetooth-peripheral</string>
<string>external-accessory</string>
<string>fetch</string>
</array>
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).
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
..zip = 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();
controller.start();
// listening on all data events from the study
controller.events.forEach(print);
// listen on only CARP events
controller.events.where((datum) => datum.format.namepace == NameSpace.CARP).forEach(print);
// listening on a specific probe
ProbeRegistry.probes[DataType.LOCATION].events.forEach(print);
}
However, you can se up a study quite simple, by using sampling schemas. Below is an example of this:
StudyController controller = StudyController(
study,
samplingSchema: SamplingSchema.common(),
);
await controller.initialize();
controller.start();
// listening on all data events from the study
controller.events.forEach(print);
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.
Please read about existing issues and file new feature requests and bug reports at the issue tracker.
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.
carp_mobile_sensing
aredevice
(device, screen, memory, battery)sensors
(sensors, light, pedometer)connectivity
(connectivity, bluetooth)apps
(installed apps, app usage)communication
(sms & call log)context
(location, activity, weather)audio
(noise, audio recording)movisens
(Movisens Move/ECG devices)stop
method.core
libraryMeasure
now have a configuration
Stream
API and supports a reactive programming modelSamplingSchema
architectureweater
probe.weather
probe added. light
probe fixed.noise
probe added.carp_core
domain modelreadme
file.phone_log
probe addedaudio
probe addedactivity
probe addedreadme
file on manifest.xml
and Info.plist
.FileDataManager
to avoid race conditionsexample/README.md
Demonstrates how to use the carp_mobile_sensing plugin.
For help getting started with Flutter, view our online documentation.
Add this to your package's pubspec.yaml file:
dependencies:
carp_mobile_sensing: ^0.3.2
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.
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 |
|
|
0.3.1 | Jan 25, 2019 |
|
|
0.3.0 | Jan 21, 2019 |
|
|
0.2.6 | Dec 5, 2018 |
|
|
0.2.5 | Dec 5, 2018 |
|
|
0.2.4 | Nov 15, 2018 |
|
|
0.2.3 | Nov 5, 2018 |
|
|
0.2.2 | Nov 5, 2018 |
|
|
0.2.1 | Oct 21, 2018 |
|
|
0.2.0 | Oct 14, 2018 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
64
|
Health:
Code health derived from static analysis.
[more]
|
74
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100
|
Overall:
Weighted score of the above.
[more]
|
74
|
We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
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 | ||
flutter_test | |||
json_serializable | ^1.0.0 | ||
test | any |