Connectivity Sampling Package
Collect network status, Wi-Fi, nearby Bluetooth devices and iBeacons from the phone in a CARP Mobile Sensing study.
carp_connectivity_package adds four phone measures to a CARP Mobile Sensing (CAMS) study. They record the networks the phone uses, the Wi-Fi network it is connected to, and the Bluetooth Low Energy (BLE) devices and iBeacons around it. Use them when a study needs the network context of a participant's phone, or the devices and places around it.
The package builds on four Flutter plugins: connectivity_plus for the network status, network_info_plus for the Wi-Fi network, flutter_blue_plus for Bluetooth scans and dchs_flutter_beacon for iBeacons.
Bluetooth plugin license
An app resolves flutter_blue_plus 2.x unless another dependency pins 1.x. Version 2.x is under the FlutterBluePlus License, which is free for nonprofits and educational institutions but paid for commercial use. To stay on the BSD-licensed 1.x, see Installation.
Features
Connectivity status
Records the network types the phone uses, such as Wi-Fi or mobile data, every time they change.
Wi-Fi
Reads the name, access point and IP address of the connected Wi-Fi network at a fixed interval. The default privacy schema hashes the network name.
Bluetooth
Scans for nearby BLE devices in short windows and lists each device with its signal strength. The default privacy schema hashes the device names.
Beacons
Detects iBeacons in the regions you configure and estimates their distance from the phone.
Measure types
The package has four event-based measure types, all collected on the phone:
| Measure type | Data | Android | iOS |
|---|---|---|---|
dk.cachet.carp.connectivity | Network types in use, such as wifi or mobile | Yes | Yes |
dk.cachet.carp.wifi | Name, access point and IP address of the connected Wi-Fi network | Yes | Yes |
dk.cachet.carp.bluetooth | BLE devices found in a scan window | Yes | Foreground only |
dk.cachet.carp.beacon | iBeacons in a configured region | Yes | Yes |
For the measure types of the other sampling packages, see Measure types.
Requirements
| Component | Requirement |
|---|---|
| Dart SDK | 3.10 or later |
| Flutter | 3.38.1 or later |
carp_mobile_sensing | 2.3.0 or later |
| Android | API level 24 (Android 7.0) or later, the CAMS minimum |
| iOS | 15.0 or later, the CAMS minimum |
| Android build | Android Gradle Plugin 8.12.1 or later, Gradle 8.13 or later, Java 17 and Kotlin 2.2.0, as connectivity_plus and network_info_plus require |
| Xcode | 26.1.1 or later, as connectivity_plus requires |
| Testing | A physical phone. The iOS simulator returns no Wi-Fi information and has no Bluetooth. |
How it works
Adding the package to a study takes three steps:
Register the package
Registering a
ConnectivitySamplingPackagein theSamplingPackageRegistrymakes the four measure types and their data and configuration classes known to CAMS. It also adds the Wi-Fi and Bluetooth name hashing to the default privacy schema.Add the measures to a protocol
The measures run on the phone. Start them with an
ImmediateTrigger, and they run until the study pauses. Wi-Fi and Bluetooth sample at their own interval, and beacons need the regions to monitor.Deploy the protocol
CAMS asks for the Bluetooth and location permissions that the measures declare, then starts them. Wi-Fi also needs location access, which CAMS does not ask for. To ask for it in the app, see Location permission.
This example registers the package and collects the connectivity status and nearby Bluetooth devices:
Next steps
Installation
Add the package and the permissions that each measure needs.
Quickstart
Build an app that collects all four measures and prints them.
Bluetooth scanning
Nearby Bluetooth Low Energy devices found in periodic scan windows.
Beacons
iBeacons in configured regions, with their estimated distance.