Skip to content
CARP Docs
Ask AISystemLightDark
On this page

Configuration

Configure sensors, sampling, background runtime and data transfer on AppleWatchDevice.

Copy MarkdownOpen inOpen in GitHubView as MarkdownOpen in Scira AIOpen in ChatGPTOpen in ClaudeOpen in Cursor

AppleWatchDevice is a device configuration in the study protocol. Its settings are handed to the watch app over WatchConnectivity.

final watch = AppleWatchDevice(
  motionSamplingRate: 10,
  heartRateEnabled: true,
  locationEnabled: false,
  fileTransferInterval: const Duration(minutes: 15),
);

protocol.addConnectedDevice(watch, phone);

Sensors

PropertyDefaultWhat it collects
motionEnabledtrueSwitch for the motion sensor
accelerometerEnabledtrueRaw acceleration, including gravity
deviceMotionEnabledtrueAttitude, gravity, rotation rate, user acceleration
heartRateEnabledtrueHeart rate via HealthKit
batteryEnabledtrueBattery level and charging state of the watch
deviceInfoEnabledtrueWatch model, watchOS version, paired phone
locationEnabledfalseLocation, altitude, speed, course
headingEnabledfalseCompass heading and geomagnetic field
bluetoothEnabledfalseNearby Bluetooth devices
audioEnabledfalseSwitch for the microphone

Motion

AppleWatchDevice(
  motionEnabled: true,
  motionSamplingRate: 10,       // Hz
  accelerometerEnabled: true,
  deviceMotionEnabled: true,
)
PropertyDefaultNotes
motionSamplingRate10Sampling rate in Hz

motionSamplingRate is the setting with the largest effect on both battery life and data volume, and the two scale together.

Sound

Sound sensing is off by default and needs two switches: the microphone itself, and what to do with it.

AppleWatchDevice(
  audioEnabled: true,                 // switch
  ambientNoiseEnabled: true,          // decibel level
  audioClassificationEnabled: true,   // sound labels
  audioDutyCycleEnabled: true,
  audioActiveDuration: const Duration(minutes: 1),
  audioRestDuration: const Duration(minutes: 3),
)
PropertyDefaultNotes
audioEnabledfalseSwitch — the two below do nothing without it
ambientNoiseEnabledtrueSound pressure level in decibel
audioClassificationEnabledtrueSound labels via Apple's SoundAnalysis
audioDutyCycleEnabledtrueAlternate between analyzing and resting
audioActiveDuration1 minuteLength of the active phase
audioRestDuration3 minutesLength of the resting phase

Background runtime

backgroundSessionType lets the watch app keep running in the background when the wrist is lowered.

AppleWatchDevice(
  backgroundSessionType: WatchBackgroundSessionType.microphone,
)
ValueBackground runtimeTrade-off
microphone (default)GoodA silent capture session. Needs microphone permission and the audio background mode. No audio is stored.
workoutBestAn HKWorkoutSession. The longest and most reliable runtime, but it appears as a workout in the participant's fitness apps and affects their activity rings.
noneNoneCollects only in the foreground. For short, supervised sessions.

Using workout can also result in App Store rejection.

Warning

The watch target needs the background mode that matches this value: microphone needs audio, and workout needs workout-processing. See Background modes.

Transferring data to the phone

AppleWatchDevice(
  fileTransferInterval: const Duration(minutes: 15),
  transferMode: WatchTransferMode.incremental,
  deleteAfterTransfer: true,
)
PropertyDefaultNotes
fileTransferInterval15 minutesHow often the watch hands data over
transferModeincrementalWhich records are included
deleteAfterTransfertrueDelete transferred records from the watch

fileTransferInterval

Sets how fresh the data is. A shorter interval means less delay but more radio wake-ups on both devices.

transferMode

ValueBehaviorWhen to use it
incremental (default)Only records collected since the last successful transferLong-running studies. Bounded radio time and storage.
allEvery record in the database, every timeRecovery and debugging. Safe (duplicates are discarded by record id) but grows more expensive as the database grows.

deleteAfterTransfer

Keeps storage on the watch bounded. Setting it to false keeps a local backup on the watch, at the cost of ever-growing disk use.

Warning

With deleteAfterTransfer: false combined with transferMode: all, transfer cost grows without limit.

Phone-side and advanced settings

PropertyDefaultNotes
saveToLocalAwareDatabasefalseAlso write received records to the AWARE database on the phone
enableNativeLoggingfalseVerbose logging from the native AWARE framework
awareServerUrlnullLet the watch upload directly to an AWARE server
  • saveToLocalAwareDatabase is a phone-side setting and is not forwarded to the watch.
  • awareServerUrl points the watch at an AWARE server of your own, bypassing the phone and CARP entirely. Leave it null in a normal CARP study.
  • enableNativeLogging is useful while bringing a study up: it makes the native AWARE framework print what it is doing to the Xcode console.

All properties

PropertyDefault
labelnull
awareServerUrlnull
motionSamplingRate10
accelerometerEnabledtrue
deviceMotionEnabledtrue
motionEnabledtrue
batteryEnabledtrue
deviceInfoEnabledtrue
heartRateEnabledtrue
locationEnabledfalse
headingEnabledfalse
bluetoothEnabledfalse
audioEnabledfalse
ambientNoiseEnabledtrue
audioClassificationEnabledtrue
audioDutyCycleEnabledtrue
audioActiveDurationDuration(minutes: 1)
audioRestDurationDuration(minutes: 3)
fileTransferIntervalDuration(minutes: 15)
transferModeWatchTransferMode.incremental
deleteAfterTransfertrue
backgroundSessionTypeWatchBackgroundSessionType.microphone
saveToLocalAwareDatabasefalse
enableNativeLoggingfalse

Watch settings maps each property to the key the phone sends to the watch.

Quick links

Page · DocumentationCARP DocumentationPage · DocumentationIntroductionPage · DocumentationQuickstartPage · DocumentationTerminologyPage · DocumentationArchitecture