carp_backend 0.6.0+1

  • Readme
  • Changelog
  • Example
  • Installing
  • 74

CARP Data Backend #

This package supports uploading of data from the CARP Mobile Sensing Framework to the CARP web service backend.

pub package

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

Upload of sensing data to the CARP web service can be done in four different ways:

Using the Plugin #

Add carp_backend as a dependency in your pubspec.yaml file and import the library along with the carp_core library.

import 'package:carp_core/carp_core.dart';
import 'package:carp_backend/carp_backend.dart';

Using the library takes three steps.

1. Register the Data Manager #

First you should register the data manager in the DataManagerRegistry.

DataManagerRegistry.register(DataEndPointType.CARP, new CarpDataManager());

2. Create a CARP Data Endpoint #

Create a CarpDataEndPoint that specify which method to use for upload of data, and the details. Upload methods are defined in the CarpUploadMethod class.

For example, a CarpDataEndPoint that upload data points directly looks like this:

CarpDataEndPoint cdep = CarpDataEndPoint(CarpUploadMethod.DATA_POINT,
      name: 'CARP Staging Server',
      uri: uri,
      clientId: clientID,
      clientSecret: clientSecret,
      email: username,
      password: password);

A CarpDataEndPoint that uploads data as zipped files and keeps the file on the phone, looks like this:

  CarpDataEndPoint cdep = CarpDataEndPoint(CarpUploadMethod.FILE,
      name: 'CARP Staging Server',
      uri: uri,
      clientId: clientID,
      clientSecret: clientSecret,
      email: username,
      password: password,
      bufferSize: 500 * 1000,
      zip: true
      deleteWhenUploaded: false);

And a CarpDataEndPoint that batch uploads data points in a json file (which is deleted when uploaded) looks like this:

  CarpDataEndPoint cdep = CarpDataEndPoint(CarpUploadMethod.BATCH_DATA_POINT,
      name: 'CARP Staging Server',
      uri: uri,
      clientId: clientID,
      clientSecret: clientSecret,
      email: username,
      password: password,
      bufferSize: 500 * 1000
      deleteWhenUploaded: true);

3. Assign the CARP Data Endpoint to your Study #

To use the CARP Data Endpoint in you study, assign it to the study. And then start the study.

  Study study = new Study(testStudyId, username, name: "Test study #$testStudyId");
  study.dataEndPoint = cdep;
  
  // create a new executor, initialize it, and start it
  executor = new StudyExecutor(study);
  executor.initialize();
  executor.start();

Features and bugs #

Please file 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.6.0+1 #

  • auto-generate of json serialization files

0.6.0 #

  • CarpUploadMethod is now an enumeration
  • Support for JSON serialization v. 3.0.0
  • update to carp_mobile_sensing version 0.6.0

0.3.4+2 #

  • bug in authentication fixed
  • delete on uploaded support

0.3.4 #

  • upgrade to carp_webservices v.0.2.6

0.3.3 #

  • upgrade to carp_mobile_sensing v.0.5.0

0.3.2 #

  • upgrade to json_serializable v.2

0.3.1 #

  • adjustment to new CARP web service API as implemented in carp_webservices package.
  • small update to pubspec

0.3.0 #

  • Adjustment to refactoring of carp_mobile_sensing library to version 0.3.0

0.1.1 #

  • Fixed errors in documentation.

0.1.0 #

  • Initial version.

example/example.dart

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

void main() {
  final String username = "researcher";
  final String password = "password";
  final String uri = "http://staging.carp.cachet.dk:8080";
  final String clientID = "carp";
  final String clientSecret = "carp";
  final String testStudyId = "8";

  // first register the CARP data manager
  DataManagerRegistry.register(CarpDataManager());

  // create a CARP data endpoint that upload using the DATA_POINT method
  CarpDataEndPoint cdep = CarpDataEndPoint(CarpUploadMethod.DATA_POINT,
      name: 'CARP Staging Server',
      uri: uri,
      clientId: clientID,
      clientSecret: clientSecret,
      email: username,
      password: password);

  // using the file method would also take information on file size whether to zip it
  CarpDataEndPoint cdep_2 = CarpDataEndPoint(CarpUploadMethod.FILE,
      name: 'CARP Staging Server',
      uri: uri,
      clientId: clientID,
      clientSecret: clientSecret,
      email: username,
      password: password,
      bufferSize: 500 * 1000,
      zip: true);

  // using the batch upload method could also take information on file size, but the file must NOT be zipped
  CarpDataEndPoint cdep_3 = CarpDataEndPoint(CarpUploadMethod.BATCH_DATA_POINT,
      name: 'CARP Staging Server',
      uri: uri,
      clientId: clientID,
      clientSecret: clientSecret,
      email: username,
      password: password,
      bufferSize: 500 * 1000);

  // create a study and allocate this data point to it.
  Study study = new Study(testStudyId, username, name: "Test study #$testStudyId");
  study.dataEndPoint = cdep;
}

Use this package as a library

1. Depend on it

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


dependencies:
  carp_backend: ^0.6.0+1

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

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

3. Import it

Now in your Dart code, you can use:


import 'package:carp_backend/carp_backend.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
47
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
74
Learn more about scoring.

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

  • Dart: 2.5.1
  • pana: 0.12.21
  • Flutter: 1.9.1+hotfix.4

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Format lib/carp_backend.dart.

Run flutter format to format lib/carp_backend.dart.

Format lib/carp_data_managers.dart.

Run flutter format to format lib/carp_data_managers.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.3.0 <3.0.0
carp_mobile_sensing ^0.6.0 0.6.0
carp_webservices ^0.3.0 0.3.2
flutter 0.0.0
json_annotation ^3.0.0 3.0.0
Transitive dependencies
app_usage 0.1.0
archive 2.0.10
args 1.5.2
async 2.4.0
battery 0.3.1
charcode 1.1.2
collection 1.14.11 1.14.12
connectivity 0.4.5
convert 2.1.1
crypto 2.1.3
device_apps 1.0.8
device_info 0.4.0+4
file_utils 0.1.3
fixnum 0.10.9
flutter_blue 0.6.3
globbing 0.3.0
http 0.12.0+2
http_parser 3.1.3
light 0.1.1
meta 1.1.7
path 1.6.4
path_provider 1.3.1
pedantic 1.8.0+1
pedometer 0.0.5 1.0.0
platform 2.2.1
protobuf 0.14.4 1.0.0
retry 3.0.0+1
rxdart 0.22.4
screen_state 0.1.1
sensors 0.4.0+1
sky_engine 0.0.99
source_span 1.5.5
stats 0.2.0+3
string_scanner 1.0.5
system_info 0.1.1
term_glyph 1.1.0
typed_data 1.1.6
uuid 2.0.2
vector_math 2.0.8
Dev dependencies
build_runner any
flutter_test
json_serializable ^3.0.0
test any