Configure Polar
To use this package, import it into your app together with the carp_mobile_sensing package:
import 'package:carp_core/carp_core.dart';import 'package:carp_mobile_sensing/carp_mobile_sensing.dart';import 'package:carp_polar_package/carp_polar_package.dart';Collection of Polar measures can be added to a study protocol like this.
// Create a study protocolvar protocol = StudyProtocol( ownerId: 'owner@dtu.dk', name: 'Polar Sensing Example',);
// Define which devices are used for data collection - both phone and polar device// and add them to the protocol.var phone = Smartphone();var polar = PolarDevice(roleName: 'hr-sensor');
protocol ..addPrimaryDevice(phone) ..addConnectedDevice(polar, phone);
// Add a background task that immediately starts collecting HR and ECG data// from the Polar device.protocol.addTaskControl( ImmediateTrigger(), BackgroundTask( measures: [ Measure(type: PolarSamplingPackage.HR), Measure(type: PolarSamplingPackage.ECG), ], ), polar,);Before executing a study with an Polar measure, register this package in the SamplingPackageRegistry.
SamplingPackageRegistry().register(PolarSamplingPackage());Use the PolarDeviceManager to connect to the device using the connect method. The connect method uses the polarIdentifier to identify the Polar device, which is printed on the sensor/device - typically on the form “B34B4B56”. On iOS, a UUID is used. You should set the id before trying to connect.