Coder Social home page Coder Social logo

cph-cachet / carp.sensing-flutter Goto Github PK

View Code? Open in Web Editor NEW
78.0 12.0 27.0 28.32 MB

CARP Mobile Sensing for Flutter, including mobile sensing framework, data backend support, and the CARP mobile sensing app.

License: MIT License

Dart 99.45% Java 0.01% Objective-C 0.02% Swift 0.47% Kotlin 0.04%
carp flutter-plugins flutter sensing mobile ubicomp wearable

carp.sensing-flutter's Introduction

CARP-Mobile-Sensing-Vertical

This repo holds the source code for the Copenhagen Research Platform (CARP) Mobile Sensing (CAMS) Flutter software. It contains the source code for CARP first-party (i.e., developed by the core CARP team) CAMS framework, its packages, and example apps.

In addition, the CARP team maintains a set of Flutter plugins (mainly) for sensing purposes. Flutter plugins enable access to platform-specific APIs. For more information about plugins, and how to use them, see the Flutter Packages description.

All the CARP Flutter components including the plugins are also available on pub.dev.

Software Components

These are the available CARP Mobile Sensing Flutter components in this repository.

Component Description pub.dev
Core Basic components
carp_serializable A package for polymorphic serialization to/from JSON build on top of json_serializable pub package
carp_core The CARP core domain model pub package
carp_mobile_sensing The main CARP Mobile Sensing Framework pub package
Packages Data sampling packages
carp_apps_package App sampling package (installed apps, app usage) pub package
carp_connectivity_package Connectivity sampling package (bluetooth, wifi, connectivity) pub package
carp_communication_package Communication sampling package (phone, sms) pub package
carp_context_package Context sampling package (location, activity, weather) pub package
carp_audio_package Audio sampling package (audio, noise) pub package
carp_survey_package Sampling package for collecting survey data from Research Package and running cognitive test using the Cognition Package pub package
carp_health_package Sampling package for collecting health data from Apple Health and Google Fit pub package
Wearables Sampling Packages for Wearable Devices
carp_movisens_package Movisens Move & ECG sampling package (movement, MET-level, ECG) pub package
carp_esense_package Sampling package for the eSense earplug device (button pressed & movement) pub package
carp_polar_package Sampling package for the Polar heart rate monitors pub package
carp_movesense_package Sampling package for the Movesense heart rate monitors pub package
Backends Backend data upload components
carp_webservices Flutter API for CARP Web Services (CAWS) pub package
carp_backend Data manager for uploading data to a CAWS data backend. pub package
carp_firebase_backend Data manager for uploading data to Firebase as both zipped files and JSON data pub package
Utilities Misc. CAMS utilities
carp_study_generator A simple command line interface (CLI) to upload study protocols, informed consent, and localization files to a CAWS backend. pub package
Apps Misc. mobile sensing demo apps
carp_mobile_sensing_app Demonstrates how basic mobile sensing can be implemented in a Flutter app using CAMS. Also demonstrates how to integrate wearable devices over BLE connections.
pulmonary_monitor_app Demonstrates how user tasks (aka. AppTask) are supported in CAMS.

Documentation

The overall documentation of the software architecture of CARP Mobile Sensing, and how to use and extend it is available on this GitHub wiki. Each of the specific packages also contains more specific documentation on how each package is used in the framework (e.g. how the Movesense sampling package is to be used).

Issues

Please check existing issues and file any new issues, bugs, or feature requests in the carp.sensing-flutter repo.

Contributing

Contributing is not entirely in place yet. However, if you wish to contribute a change to any of the existing components in this repo, please review our contribution guide, and send a pull request.

carp.sensing-flutter's People

Contributors

almaxdtu avatar bardram avatar devhci avatar hoffmatteo avatar larsrefsgaard avatar luciamontesinos avatar nightscape avatar sc00n avatar slimshadyiam avatar thomasnilsson avatar xelahalo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

carp.sensing-flutter's Issues

App: Maybe remove google-services.json

google-services.json is usually not included into open source repos.

If this is intended, I would love to know why.
I used firebase and other google services before and would be nice to know why I can safly include it in a open source repo.

minSdkVersion 16 cannot be smaller than version 19 declared in library [:flutter_blue]

When compiling, you may get;

/Users/bardram/dev/carp/carp.sensing/flutter/carp_mobile_sensing/example/android/app/src/main/AndroidManifest.xml Error:
	uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:flutter_blue] /Users/bardram/dev/carp/carp.sensing/flutter/carp_mobile_sensing/example/build/flutter_blue/intermediates/manifests/full/debug/AndroidManifest.xml as the library might be using APIs not available in 16
	Suggestion: use a compatible library with a minSdk of at most 16,
		or increase this project's minSdk version to at least 19,
		or use tools:overrideLibrary="com.pauldemarco.flutterblue" to force usage (may lead to runtime failures)

FAILURE: Build failed with an exception.

screenStateEvent Exception

running carp_mobile_sensing version: 0.3.2
iOS 9.0

In console I get following warning:

EXCEPTION CAUGHT BY SERVICES LIBRARY
The following MissingPluginException was thrown while activating platform stream on channel
screenStateEvents:
MissingPluginException (No implementation found for method listen on channel screenStateEvents)

Look in: platform_channel.dart:300:7

Backend: Carp webservice repo no longer available

Currently I see 3 options of saving Study data:

  1. CARP Webservice
  2. Firebase
  3. Locally

Carp webservice links to a github repo, which is no longer available.

Is CARP webservice something which was/will be open source?

What is the recommended way of setting up a CARP system outside of CACHET?

carp_mobile_sensing_app will not build on Android

Problem

After opening the carp_mobile_sensing app in Android Studio (commit 667fcd9fd89ff36413de18f145f21b17c4837029 on 2019-12-09), and getting packages, this example app fails to build.

Steps to reproduce

  1. Open the carp_mobile_sensing_app in Android Studio
  2. Get any needed packages
  3. Attempt build/run on an Android target

logcat error (x3)

12-10 17:36:22.914  8282  8324 W ErrorReporter: reportError [type: 211, code: 393244, bug: 0]: errorCode: 393244, engine: 0
12-10 17:36:22.915  8282  8324 I MicroDetector: Keeping mic open: false
12-10 17:36:22.915  8282  8324 I MicroDetectionWorker: #onError(false)

Gradle output

Launching lib/main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "/Users/will/code/carp.sensing-flutter/carp_mobile_sensing_app/android/gradlew" exited abnormally:

> Configure project :app
WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variantOutput.getProcessResources()' is obsolete and has been replaced with 'variantOutput.getProcessResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getProcessResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

> Configure project :activity_recognition_alt
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

> Configure project :flutter_blue
The com.google.protobuf plugin was already applied to the project: :flutter_blue and will not be applied again after plugin: android-library
         *********************************************************
WARNING: This version of flutter_blue will break your Android build if it or its dependencies aren't compatible with AndroidX.
         See https://goo.gl/CP92wY for more information on the problem and how to fix it.
         This warning prints for all Android build failures. The real root cause of the error may be unrelated.
         *********************************************************
  Command: /Users/will/code/carp.sensing-flutter/carp_mobile_sensing_app/android/gradlew app:properties

Finished with error: Please review your Gradle project setup in the android/ folder.

Flutter doctor -v

[✓] Flutter (Channel stable, v1.9.1+hotfix.6, on Mac OS X 10.14.6 18G1012, locale en-US)
    • Flutter version 1.9.1+hotfix.6 at /Users/will/flutter
    • Framework revision 68587a0916 (3 months ago), 2019-09-13 19:46:58 -0700
    • Engine revision b863200c37
    • Dart version 2.5.0


[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/will/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 11.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 11.2.1, Build version 11B500
    • CocoaPods version 1.6.2

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 41.1.2
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] Connected device (2 available)
    • Android SDK built for x86 • emulator-5554                        • android-x86 • Android 10 (API 29) (emulator)
    • iPhone 11 Pro Max         • AF5B6408-768A-4C8C-A392-25125F77272C • ios         • com.apple.CoreSimulator.SimRuntime.iOS-13-2 (simulator)

• No issues found!

iOS

iOS will not build either, and XCode throws this error:

    [!] Automatically assigning platform `ios` with version `9.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

Too many location updates

The location probe returns a lot of location events -- up to 10-15 pr. minute. This is too much and should be reduced.

Update Flutter SDK

Currently, we are encountering a compile error due to SDK versioning differences between the SDK of carp_mobile_sensing_app andflutter_sound.

Because carp_audio_package >=0.7.1 depends on flutter_sound ^5.0.0 which depends on provider ^4.1.0, carp_audio_package >=0.7.1 requires provider ^4.1.0.
So, because provider >=4.1.0-dev+1 requires Flutter SDK version >=1.15.17-pre.5 and carp_mobile_sensing_app depends on carp_audio_package ^0.8.1, version solving failed.
pub get failed (1; So, because provider >=4.1.0-dev+1 requires Flutter SDK version >=1.15.17-pre.5 and carp_mobile_sensing_app depends on carp_audio_package ^0.8.1, version solving failed.)

Issues with downloading dependencies

Not sure if this is the right place to be adding this, but can I have more clarity on how to download all the dependencies for the packages? I have downloaded the repo, and navigated to the location of every module and ran flutter pub get . However, when I run this command in the carp_mobile_sensing_app directory, I am getting the following errors:

! carp_audio_package 0.6.1 from path ../carp_audio_package ! carp_backend 0.6.0+1 from path ../carp_backend ! carp_communication_package 0.6.1+1 from path ../carp_communication_package ! carp_context_package 0.6.4 from path ../carp_context_package ! carp_esense_package 0.1.4 from path ../carp_esense_package ! carp_mobile_sensing 0.6.3 from path ../carp_mobile_sensing ! carp_survey_package 0.6.0 from path ../carp_survey_package ! carp_webservices 0.3.3+1 from path ../carp_webservices
I have tried to change the version of the dependencies in the carp_mobile_sensing_app/pubspec.yaml file, but am still getting this error.

Thanks!

Race condition in SamplingSchema

When using addSamplingSchema and getMeasureList there seems to be a race conditions -- measures are overwritten while being added.

Inconsistencies w. rxdart

When using the research_package with carp_mobile_sensing, there is the following inconsistency w. flutter_blue

Because research_package >=0.1.2 depends on rxdart ^0.23.0 and flutter_blue 0.6.2 depends on rxdart ^0.22.0, research_package >=0.1.2 is incompatible with flutter_blue 0.6.2.
And because carp_mobile_sensing >=0.6.2 depends on flutter_blue 0.6.2, research_package >=0.1.2 is incompatible with carp_mobile_sensing >=0.6.2.
So, because carp_survey_package depends on both carp_mobile_sensing ^0.6.2 and research_package ^0.1.2, version solving failed.
pub get failed (1; So, because carp_survey_package depends on both carp_mobile_sensing ^0.6.2 and research_package ^0.1.2, version solving failed.)

Missing support for CARPDataEndPoint with token

CAMS has support for authenticating with a token to CARP. However, CARPDataEndPoint needs a password, so these to methods do not compliment each other.

Proposed solution:
Add a Token variable to CARPDataEndPoint, and not assert password & username != null.

webservices: Authentication token flow issues/enhancements

The following use case is typical in an application:

  1. Authenticate with username and password
CarpUser user = await CARPBackend().authenticate(userID, password);
  1. Save the User's token on the phone
SharedPreferences sp = await SharedPreferences.getInstance();
sp.setString(CARPBackend.SP_OAUTH_TOKEN, jsonEncode(token.toJson()));
  1. Next time (can be hours or days later) check if the user's token has been saved on the device and if it is, then authenticate with that one instead of the username - password combination
OAuthToken tokenFromSP = OAuthToken.fromJson(json.decode(stringToken));
user = await CarpService.instance.authenticateWithToken(
          username: username,
          token: tokenFromSP);

This scenario seems to be a bit fragile, so unit tests needed.

Also, carp_webservices in the future could support the scenario automated:

  1. Only one authentication method which first checks if the token has been saved on the device
  2. If not, authenticate with the username, password parameters
  3. If yes, take the token from the phone and authenticate with that one

Probes not working for iOS devices

There is a file missing in all the probes ending as '-Swift.h', so for example for App Usage the error that comes up is:

/Users/admin/.pub-cache/hosted/pub.dartlang.org/app_usage-0.0.2/ios/Classes/AppUsagePlugin.m:2:9: fatal error: 'app_usage/app_usage-Swift.h' file not found #import <app_usage/app_usage-Swift.h>

Android dependency - different version for compile and runtime classpath

When compiling, we get the error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:preDebugBuild'.
> Android dependency 'com.android.support:support-compat' has different version for the compile (26.1.0) and runtime (27.1.1) classpath. You should manually set the same version via DependencyResolution

[mobile sensing app] ActivityRecognition header file not found

It seems like the ActivityRecognition plugin is not properly linked in XCode since #import <activity_recognition/ActivityRecognitionPlugin.h> results in the following error:

'activity_recognition/ActivityRecognitionPlugin.h' file not found

I've opened an issue on the GIthub page of the plugin (link)

carp_context_package, its dependencies aren't compatible with AndroidX

Hi!

Here is my configuration:

Flutter 1.9.1+hotfix.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 2d2a1ffec9 (2 weeks ago) • 2019-09-06 18:39:49 -0700
Engine • revision b863200c37
Tools • Dart 2.5.0
Android Studio 3.5

And my pubspec:

...
dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2
  carp_context_package: ^0.6.0
  carp_mobile_sensing: ^0.6.0
  carp_communication_package: ^0.6.0
...

And I have the following error when running my main.dart:

Launching lib/main.dart on SM G960F in debug mode...
Initializing gradle...
Resolving dependencies...
* Error running Gradle:
ProcessException: Process "/home/dhassault/projects/annotator/android/gradlew" exited abnormally:

> Configure project :app
WARNING: API 'variant.getMergeAssets()' is obsolete and has been replaced with 'variant.getMergeAssetsProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getMergeAssets(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
WARNING: API 'variantOutput.getProcessResources()' is obsolete and has been replaced with 'variantOutput.getProcessResourcesProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variantOutput.getProcessResources(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.

> Configure project :flutter_blue
The com.google.protobuf plugin was already applied to the project: :flutter_blue and will not be applied again after plugin: android-library
WARNING: API 'variant.getJavaCompile()' is obsolete and has been replaced with 'variant.getJavaCompileProvider()'.
It will be removed at the end of 2019.
For more information, see https://d.android.com/r/tools/task-configuration-avoidance.
To determine what is calling variant.getJavaCompile(), use -Pandroid.debug.obsoleteApi=true on the command line to display more information.
         *********************************************************
WARNING: This version of battery will break your Android build if it or its dependencies aren't compatible with AndroidX.
         See https://goo.gl/CP92wY for more information on the problem and how to fix it.
         This warning prints for all Android build failures. The real root cause of the error may be unrelated.
         *********************************************************
  Command: /home/dhassault/projects/annotator/android/gradlew app:properties

Finished with error: Please review your Gradle project setup in the android/ folder.

Without carp_context_package it runs fine. Any idea?

Upgrade issue with 0.5.0

Because carp_webservices >=0.2.2 depends on carp_mobile_sensing ^0.4.0 and reafel_app depends on carp_mobile_sensing ^0.5.0, carp_webservices >=0.2.2 is forbidden. So, because reafel_app depends on carp_webservices ^0.2.3, version solving failed.

CARP Health Package: Argument type error - updated "Health" package needs to be supported.

Error:

../../flutter/.pub-cache/hosted/pub.dartlang.org/carp_health_package-0.8.0/lib/health_domain.dart:109:23: Error: The argument type 'DateTime' can't be assigned to the parameter type 'int'.
 - 'DateTime' is from 'dart:core'.
      healthDataPoint.dateFrom,
                      ^
../../flutter/.pub-cache/hosted/pub.dartlang.org/carp_health_package-0.8.0/lib/health_domain.dart:110:23: Error: The argument type 'DateTime' can't be assigned to the parameter type 'int'.
 - 'DateTime' is from 'dart:core'.
      healthDataPoint.dateTo,
                      ^

Proposed solution:
Change HealthDatum constructor arguments 'dateFrom' & 'dateTo' to DateTime's. In "Health" these fields are now private and the getter for these returns DateTime's.

  HealthDatum(this.value, this.unit, int dateFrom, int dateTo, this.dataType, this.platform) : super() {
    this.dateFrom = DateTime.fromMillisecondsSinceEpoch(dateFrom);
    this.dateTo = DateTime.fromMillisecondsSinceEpoch(dateTo);
  }

to

  HealthDatum(this.value, this.unit, this.dateFrom, this.dateTo, this.dataType, this.platform) : super();

Code signing issues on iOS v. 13.3.x

When installing apps on a real iPhone (not the simulator) on the iOS v. 13.3.1 the following problem occurs often.

dyld: Library not loaded: @rpath/CSV.framework/CSV
  Referenced from: /private/var/containers/Bundle/Application/42980BC7-DE1E-4D30-8C3D-81A9C20CC7DE/ESense_Example.app/ESense_Example
  Reason: no suitable image found.  Did find:
	/private/var/containers/Bundle/Application/42980BC7-DE1E-4D30-8C3D-81A9C20CC7DE/ESense_Example.app/Frameworks/CSV.framework/CSV: code signature invalid for '/private/var/containers/Bundle/Application/42980BC7-DE1E-4D30-8C3D-81A9C20CC7DE/ESense_Example.app/Frameworks/CSV.framework/CSV'

In this case it is the ESense causing problems, but it can be any library.

_snapshot['createdAt'] returns null

In document_reference.dart

/// The timestamp of creation of this document
String get createdAt => _snapshot['createdAt'];

Returns Null bcz
String get createdAt => _snapshot['createdAt'];
has been changed to
_snapshot['created_at'] on server side

StudyID for the CARP Web Services can only be an integer

[ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: 'package:carp_webservices/carp_service/carp_datapoint.dart': Failed assertion: line 55 pos 12: 'int.tryParse(studyId) != null': Study ID (ea7d63f7-3c42-43e8-ba4f-2c02ae63a272) for the CARP Web Services can only be an integer.

The Study ID can only be integer, although my Study ID is a string ("ea7d63f7-3c42-43e8-ba4f-2c02ae63a272"), therefore I can't upload CARPDataPoint because the CARPDataPoint.fromDatum constructor cannot be called.

Is it by design and my Study ID should be changed to integer or should CAMS support string Study ID's as well?

[carp_mobile-sensing] Unhandled Exception: Converting object to an encodable object failed: Instance of 'DataPoint'

How to re-create

  1. Run the carp_mobile_sensing example app on Android
  2. Tap the refresh button to make a sample
  3. Error will occur in logs

Log output:

I/flutter (15411): AppUsageDatum - format: carp.app_usage, id: 90e7ab60-e4a5-11ea-b171-e315deff13b0, timestamp: 2020-08-22 18:30:34.005660Z, 2020-08-22 18:29:34.958190Z, end: 2020-08-22 18:30:33.959474Z, usage: {packageinstaller: 9.0, nexuslauncher: 1060.0, carp_mobile_sensing_example: 4.0, settings: 27.0, app_usage_example: 2474.0, app_usage_tester: 248.0, calendar: 4.0}
E/flutter (15411): [ERROR:flutter/lib/ui/ui_dart_state.cc(157)] Unhandled Exception: Converting object to an encodable object failed: Instance of 'DataPoint'
E/flutter (15411): #0      _JsonStringifier.writeObject (dart:convert/json.dart:659:7)
E/flutter (15411): #1      _JsonStringStringifier.printOn (dart:convert/json.dart:846:17)
E/flutter (15411): #2      _JsonStringStringifier.stringify (dart:convert/json.dart:831:5)
E/flutter (15411): #3      JsonEncoder.convert (dart:convert/json.dart:260:30)
E/flutter (15411): #4      JsonCodec.encode (dart:convert/json.dart:168:45)
E/flutter (15411): #5      jsonEncode (dart:convert/json.dart:82:10)
E/flutter (15411): #6      FileDataManager.write (package:carp_mobile_sensing/data_managers/local/file_data_manager.dart:118:18)
E/flutter (15411): #7      FileDataManager.onDatum (package:carp_mobile_sensing/data_managers/local/file_data_manager.dart:52:32)
E/flutter (15411): #8      _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (15411): #9      _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (15411): #10     _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (15411): #11     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (15411): #12     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
E/flutter (15411): #13     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:134:11)
E/flutter (15411): #14     _MapStream._handleData (dart:async/stream_pipe.dart:234:10)
E/flutter (15411): #15     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:166:13)
E/flutter (15411): #16     _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (15411): #17     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (15411): #18     _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (15411): #19     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (15411): #20     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
E/flutter (15411): #21     _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:134:11)
E/flutter (15411): #22     _MapStream._handleData (dart:async/stream_pipe.dart:234:10)
E/flutter (15411): #23     _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:166:13)
E/flutter (15411): #24     _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (15411): #25     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (15411): #26     _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (15411): #27     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (15411): #28     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
E/flutter (15411): #29     _SyncBroadcastStreamController._sendData.<anonymous closure> (dart:async/broadcast_stream_controller.dart:386:20)
E/flutter (15411): #30     _BroadcastStreamController._forEachListener (dart:async/broadcast_stream_controller.dart:327:15)
E/flutter (15411): #31     _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:385:5)
E/flutter (15411): #32     _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:252:5)
E/flutter (15411): #33     _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (15411): #34     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (15411): #35     _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (15411): #36     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (15411): #37     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
E/flutter (15411): #38     _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:378:20)
E/flutter (15411): #39     _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:252:5)
E/flutter (15411): #40     _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (15411): #41     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (15411): #42     _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (15411): #43     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (15411): #44     _BufferingStreamSubscription._add (dart:async/stream_impl.dart:266:7)
E/flutter (15411): #45     _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:378:20)
E/flutter (15411): #46     _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:252:5)
E/flutter (15411): #47     _rootRunUnary (dart:async/zone.dart:1192:38)
E/flutter (15411): #48     _CustomZone.runUnary (dart:async/zone.dart:1085:19)
E/flutter (15411): #49     _CustomZone.runUnaryGuarded (dart:async/zone.dart:987:7)
E/flutter (15411): #50     _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
E/flutter (15411): #51     _DelayedData.perform (dart:async/stream_impl.dart:594:14)
E/flutter (15411): #52     _StreamIm

Lack of permissions makes the app crash

In carp_mobile_sensing_app the study will start before the user is prompted for permissions, such as location, microphone and so on, which leads to the app crashing.

We need a way to await the permission before starting any probes - not sure if this should be done on the "app" side or the domain side.

We can probably just use this library for checking permissions https://pub.dartlang.org/packages/simple_permissions

RecurrentScheduledTrigger not triggered if app is not running - New use case

RecurrentScheduledTrigger is used to issue for e.g. weekly questionnaires using the carp_survey_package. When the app is not running the questionnaires are not popping up, even though they should.

A possible new feature enhancement could be a trigger type which uses the phone's storage (Shared Preferences or something...) to store the trigger information so it's not only triggered when the app is actively running but also next time the app is opened (maybe even pushes a system notification to open the app).

ConditionalSamplingEventTrigger not triggering

ConditionalSamplingEventTrigger does not trigger when a datum with the correct conditions are present.
Seemingly, the ConditionalSamplingEventTriggerExecutor doesn't listen on the event datum stream, and therefore the resumeCondition is never checked.

eSense package requests location permission when loaded which makes the app crash

By just adding the eSense package to the pubspec file like

  carp_esense_package: ^0.1.3

(and not even importing or using it) trigges a request for location permission. This is also documented in the Android eSense API from Nokia. But this means that it can be handled gracefully by the CARP Mobile Sensing framework, and hence trigger a Can reqeust only one set of permissions at a time error while waiting for the user.

App: ffmpeg lib needs minSdkVersion 24

C:\Users\nilss\uni\carp.sensing-flutter\carp_mobile_sensing_app\android\app\src\main\AndroidManifest.xml Error:
	uses-sdk:minSdkVersion 23 cannot be smaller than version 24 declared in library [:flutter_ffmpeg] C:\Users\nilss\uni\carp.sensing-flutter\carp_mobile_sensing_app\build\flutter_ffmpeg\intermediates\library_manifest\debug\AndroidManifest.xml as the library might be using APIs not available in 23
	Suggestion: use a compatible library with a minSdk of at most 23,
		or increase this project's minSdk version to at least 24,
		or use tools:overrideLibrary="com.arthenica.flutter.ffmpeg" to force usage (may lead to runtime failures)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 23 cannot be smaller than version 24 declared in library [:flutter_ffmpeg] C:\Users\nilss\uni\carp.sensing-flutter\carp_mobile_sensing_app\build\flutter_ffmpeg\intermediates\library_manifest\debug\AndroidManifest.xml as the library might be using APIs not available in 23
  	Suggestion: use a compatible library with a minSdk of at most 23,
  		or increase this project's minSdk version to at least 24,
  		or use tools:overrideLibrary="com.arthenica.flutter.ffmpeg" to force usage (may lead to runtime failures)

How to pass parameters to a probe?

I am currently trying to extend CARP with a Shimmer sensor that is connected via Bluetooth.
The MAC address of the device will only be known at runtime, after the user has selected the device from a list of all Bluetooth devices.
Now the question is, how do I pass a String macAddress parameter from the UI to the ShimmerProbe where it will be used to connect to the device.
My intuition is that the ShimmerMeasure would be the right place to store the parameter and then read it in ShimmerProbe#onInitialize(Measure measure), but the ShimmerMeasure gets instantiated in getter methods which don't accept any parameters.
The only option I see right now is to give the ShimmerSamplingPackage a macAddress field and initialize that in the constructor. Would that be the way to go?

As a simplified example, how would the WeatherMeasure work if the apiKey was not known at compile time, but rather needed to be specified by the user at runtime?

Context: activity_recognition_alt uses incompatible kotlin version

I see you have your own activity_recognition package:
Would be nice, if you could update context to use it:
https://pub.dev/packages/activity_recognition_flutter

When building the app, I get following error:

FAILURE: Build failed with an exception.

* What went wrong:
The Android Gradle plugin supports only Kotlin Gradle plugin version 1.3.10 and higher.
The following dependencies do not satisfy the required version:
project ':activity_recognition_alt' -> org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.51

CARP webservices: CarpServiceException toString() cannot handle null message throws String error

Error:

E/flutter ( 7795): [ERROR:flutter/shell/common/shell.cc(209)] Dart Error: Unhandled exception:
E/flutter ( 7795): Invalid argument(s)
E/flutter ( 7795): #0      _StringBase.+  (dart:core-patch/string_patch.dart:267:57)
E/flutter ( 7795): #1      CarpServiceException.toString 

Description:
If the response from a HTTP request returns an error and Carp Webservices creates a CarpServiceException, the message can be null (or might not have been added correctly in Carp Webservices). This results in an error when the Exception is later printed using the toString(), as it is not checked/handled.

Error code: - CarpService.dart line 498.

  String toString() => "CarpServiceException: " + ((httpStatus != null) ? "$httpStatus - " : "") + message;

Proposed solution:

String toString() => "CarpServiceException: ${(httpStatus != null) ? httpStatus + " - " : ""} ${message ?? ""}";

Webservices: create consent document is deprecated with new CARP version

I can't create a new consent document in Carp with createConsentDocument anymore.

As far as I can see that is because the call now should be
POST {{PROTOCOL}}://{{SERVER_HOST}}:{{SERVER_PORT}}/api/deployments/{{DEPLOYMENT_ID}}/consent-documents
and instead the version now uses
POST {{PROTOCOL}}://{{SERVER_HOST}}:{{SERVER_PORT}}/api/studies/{{DEPLOYMENT_ID}}/consent-documents
so studies instead of deployments.

CarpWebservices: get all documents in a collection throws list error

Code:
List<DocumentSnapshot> documents = await CarpService.instance.collection('patients').document(userID).collection('chapters').documents;

Error:

E/flutter (16044): [ERROR:flutter/lib/ui/ui_dart_state.cc(166)] Unhandled Exception: RangeError (index): Invalid value: Valid value range is empty: 0
E/flutter (16044): #0      List.[]  (dart:core-patch/growable_array.dart:166:60)
E/flutter (16044): #1      CollectionReference.documents 
package:carp_webservices/carp_service/document_reference.dart:107
E/flutter (16044): <asynchronous suspension>
E/flutter (16044): #2      CARPBackend.getAllChapters 
package:ipdmgo/…/data/backend.dart:195
E/flutter (16044): <asynchronous suspension>

Trying to query all documents in a collection with the getter '.documents', throws an error.

Audio recording fails

When trying to record sound in the CARP Mobile Sensing App, there is an exception from Flutter Sound

D/FlutterSoundPlugin( 1311): startRecorder
I/MediaRecorderJNI( 1311): setOutputFile
E/MediaRecorder( 1311): output file has already been set
E/FlutterSoundPlugin( 1311): Exception: 
E/FlutterSoundPlugin( 1311): java.lang.IllegalStateException
E/FlutterSoundPlugin( 1311): 	at android.media.MediaRecorder._setOutputFile(Native Method)
E/FlutterSoundPlugin( 1311): 	at android.media.MediaRecorder.prepare(MediaRecorder.java:1266)
E/FlutterSoundPlugin( 1311): 	at com.dooboolab.fluttersound.FlutterSoundPlugin.startRecorder(FlutterSoundPlugin.java:161)
E/FlutterSoundPlugin( 1311): 	at com.dooboolab.fluttersound.FlutterSoundPlugin.lambda$onMethodCall$0$FlutterSoundPlugin(FlutterSoundPlugin.java:65)
E/FlutterSoundPlugin( 1311): 	at com.dooboolab.fluttersound.FlutterSoundPlugin$$Lambda$0.run(Unknown Source:8)
E/FlutterSoundPlugin( 1311): 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
E/FlutterSoundPlugin( 1311): 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/FlutterSoundPlugin( 1311): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
E/FlutterSoundPlugin( 1311): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
E/FlutterSoundPlugin( 1311): 	at java.lang.Thread.run(Thread.java:764)
I/flutter ( 1311): >> {"latitude":{"value":55.7943012,"unit":"deg"},"longitude":{"value":12.4461802,"unit":"deg"},"positioning_system":"GPS"}
I/flutter ( 1311): >> {"id":"cefcb500-5970-11e9-ad94-5f62322a1314","timestamp":"2019-04-17T09:54:36.239681Z","mean_lux":106.66566265060241,"std_lux":1.5714782333849235,"min_lux":99,"max_lux":109}
E/flutter ( 1311): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: Exception: Recorder already stopped.
E/flutter ( 1311): null
I/flutter ( 1311): >> {"id":"cf99df60-5970-11e9-862c-79cf2cefd498","timestamp":"2019-04-17T09:54:37.269941Z","message":"AudioProbe Error: Exception: Recorder already stopped."}

_stopAudioRecording tries to return an exception as a future

When _stopAudioRecording catches an exception (in my case Recorder already stopped), it tries to return this exception as a future which itself fails:


One possible solution to this would be to use Future.sync and rethrow the error instead of returning it:
https://www.dartlang.org/guides/libraries/futures-error-handling#solution-using-futuresync-to-wrap-your-code

Non-existing folders in Firebase

It seems like the study_id folder in Firebase is not really created (it is shown in italic). This makes it hard to access data (according to Darius).

Webservices: JSON serialization for OAuthToken class

Right now the OAuthToken class does not support a toJson function making it possible to serialize. The only available function is toString but that has a less clear structure.

JSON serialization would be useful for for e.g. storing the token in shared preferences as a string for later usage.

Noise and Audio probe cannot run at the same time

It seems like the access to the microphone is "taken" by the Noise probe. For example in the example below, first the noise probe collect data (for 2 secs) and work fine and returns a noise recording. Then, when the audio probe wants to record, it get and error in starting the recording -- in the line

E/MediaRecorder( 5788): start failed: -38

Full print from the carp mobile sensing app is:

I/flutter ( 5788): Starting Instance of 'NoiseProbe'
I/MediaRecorderJNI( 5788): setup
I/flutter ( 5788): Sensing started ...
I/MediaRecorderJNI( 5788): setAudioSource(1)
I/MediaRecorderJNI( 5788): setAudioEncoder(0)
I/MediaRecorderJNI( 5788): setOutputFile
I/MediaRecorderJNI( 5788): prepare
I/MediaRecorderJNI( 5788): start
D/NoiseMeterPlugin( 5788): listen()
I/flutter ( 5788): >> {"id":"fece0e90-5970-11e9-f9a7-a331c1237735","timestamp":"2019-04-28T11:30:16.184358Z","mean_decibel":34.23076923076923,"std_decibel":5.984859266008269,"min_decibel":0,"max_decibel":52}
I/flutter ( 5788): Noise - mean: 34.23076923076923, std: 5.984859266008269, min: 0, max: 52
D/FlutterSoundPlugin( 5788): startRecorder
I/MediaRecorderJNI( 5788): setup
I/MediaRecorderJNI( 5788): setAudioSource(1)
I/MediaRecorderJNI( 5788): setAudioEncoder(3)
I/MediaRecorderJNI( 5788): setParameter()
I/MediaRecorderJNI( 5788): setOutputFile
I/MediaRecorderJNI( 5788): prepare
I/MediaRecorderJNI( 5788): start
E/MediaRecorder( 5788): start failed: -38
E/FlutterSoundPlugin( 5788): Exception: 
E/FlutterSoundPlugin( 5788): java.lang.IllegalStateException
E/FlutterSoundPlugin( 5788): 	at android.media.MediaRecorder._start(Native Method)
E/FlutterSoundPlugin( 5788): 	at android.media.MediaRecorder.start(MediaRecorder.java:1310)
E/FlutterSoundPlugin( 5788): 	at com.dooboolab.fluttersound.FlutterSoundPlugin.startRecorder(FlutterSoundPlugin.java:162)
E/FlutterSoundPlugin( 5788): 	at com.dooboolab.fluttersound.FlutterSoundPlugin.lambda$onMethodCall$0$FlutterSoundPlugin(FlutterSoundPlugin.java:65)
E/FlutterSoundPlugin( 5788): 	at com.dooboolab.fluttersound.FlutterSoundPlugin$$Lambda$0.run(Unknown Source:8)
E/FlutterSoundPlugin( 5788): 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
E/FlutterSoundPlugin( 5788): 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/FlutterSoundPlugin( 5788): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
E/FlutterSoundPlugin( 5788): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
E/FlutterSoundPlugin( 5788): 	at java.lang.Thread.run(Thread.java:764)

Error: The getter 'lightSensorStream' isn't defined for the class 'Light'. - 'Light'

file:///Users/deku/Documents/development/carp_sensing/carp.sensing-flutter/carp_mobile_sensing/lib/probes/sensors/light_probe.dart:37:41:

Error: The getter 'lightSensorStream' isn't defined for the class 'Light'.

  • 'Light' is from 'package:light/light.dart' ('file:///Users/deku/Documents/development/flutter/.pub-cache/hosted/pub.dartlang.org/light-0.0.7/lib/light.dart').
    Try correcting the name to the name of an existing getter, or defining a getter or field named 'lightSensorStream'.
    Stream get lightSensorStream =>

Light().lightSensorStream;

Seems light Sensorstream no longer exists in 0.0.7

MissingPluginException getUsage

Carp_mobile_sensing vs 0.3.2
When starting the AppUsageProbe on iOS I get the following error:

flutter: starting Instance of 'AppUsageProbe'
Unhandled Exception: 'file:///Users/a... line 20 pos 15: 'googleAppID !=null is not true

It doesnt seem like it can initiate this probe

CARP survey package: Update SurveyProbe and SurveyPage to support RP's new onCancel function

Currently, CARP_survey_package doesnt support the onCancel that Research Package has implemented.

Suggested solution:

carp_survey_package/lib/survey_ui.dart:

class SurveyPage extends StatelessWidget {
  /// The task to present
  final RPTask task;

  /// The callback function which has to return an [RPTaskResult] object.
  final void Function(RPTaskResult) resultCallback;

  /// The [RPTaskResult] is optional and can be null if no results were created.
  final void Function([RPTaskResult]) onSurveyCancel;

  SurveyPage(this.task, this.resultCallback, {this.onSurveyCancel}) : super();

  Widget build(BuildContext context) {
    return RPUITask(
      task: task,
      onSubmit: (result) {
        resultCallback(result);
      },
      onCancel: onSurveyCancel,
    );
  }
}

And
carp_survey_package/lib/survey_runtime.dart:

  /// The callback function to be called when the survey is canceled by the user.
  /// The optional [RPTaskResult] is provided at it's current state. Can be null.
  void Function([RPTaskResult]) onSurveyCancel;

  SurveyProbe({this.onSurveyTriggered, this.onSurveySubmit, this.onSurveyCancel}) : super();

  Future<void> onResume() async {
    onSurveyTriggered(SurveyPage(
      surveyTask,
      _onSurveySubmit,
      onSurveyCancel: onSurveyCancel,
    ));
  }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.