carp_connectivity_package 1.7.1 copy "carp_connectivity_package: ^1.7.1" to clipboard
carp_connectivity_package: ^1.7.1 copied to clipboard

CARP connectivity sampling package. Samples connectivity status, bluetooth devices, and wifi access points.

example/lib/example.dart

import 'package:carp_core/carp_core.dart';
import 'package:carp_mobile_sensing/carp_mobile_sensing.dart';
import 'package:carp_connectivity_package/connectivity.dart';

/// This is a very simple example of how this sampling package is used with
/// CARP Mobile Sensing (CAMS).
/// NOTE, however, that the code below will not run.
/// See the documentation on how to use CAMS: https://github.com/cph-cachet/carp.sensing-flutter/wiki
void main() async {
  // Register this sampling package before using its measures
  SamplingPackageRegistry().register(ConnectivitySamplingPackage());

  // Create a study protocol
  StudyProtocol protocol = StudyProtocol(
    ownerId: 'owner@dtu.dk',
    name: 'Connectivity Sensing Example',
  );

  // Define which devices are used for data collection
  // In this case, its only this smartphone
  Smartphone phone = Smartphone();
  protocol.addPrimaryDevice(phone);

  // Add an automatic task that immediately starts collecting connectivity,
  // nearby bluetooth devices, and wifi information.
  protocol.addTaskControl(
      ImmediateTrigger(),
      BackgroundTask(measures: [
        Measure(type: ConnectivitySamplingPackage.CONNECTIVITY),
        Measure(type: ConnectivitySamplingPackage.BLUETOOTH),
        Measure(type: ConnectivitySamplingPackage.WIFI),
      ]),
      phone);
}