Movesense Plus
A Flutter plugin for Movesense sensors with scanning, connection status, typed sensor streams and raw MDS access.
movesense_plus connects Flutter apps to the Movesense MD, Active HR+ and HR2 sensors over Bluetooth Low Energy (BLE). It bundles the Movesense mobile library (MDS) for Android and iOS, so there is no native SDK to set up.
The plugin provides a typed API for scanning, connection status, device information, battery level and sensor streams. Raw MDS requests and subscriptions reach any other resource of the Movesense API. The Mds and MdsAsync classes accept code written for the mdsflutter plugin.
Changes in version 2.0
Version 2.0.0 is the plugin previously published as carp_movesense_flutter. It has a new API and replaces the 1.x releases of movesense_plus, which were built on mdsflutter. To update an app, see Migrate to 2.0.
Features
Scanning and connection
Scan for sensors that advertise the Movesense services, and connect to one from a scan result or by its address. Each MovesenseDevice reports its connection status as a stream.
Device status
When a sensor connects, the plugin reads its model, firmware version and battery state, which is OK or low. Read system states, such as the connection to a strap, on demand.
Typed sensor streams
Heart rate with R-R intervals, ECG, nine-axis inertial measurement unit (IMU) samples and temperature arrive as typed Dart objects. Each stream subscribes on the sensor when you listen and unsubscribes when you cancel.
State events
Get an event each time a system state changes, for example when the user taps the sensor. The sensor allows only one subscription at a time to the motion states: movement, tap, double tap and free fall.
MDS requests
Send GET, PUT, POST and DELETE requests to any resource of the Movesense API, or subscribe to it. Responses and notifications arrive as raw JSON.
mdsflutter compatibility
The static Mds and MdsAsync classes match the mdsflutter API, so most code written for that plugin needs only a new import.
Supported sensors
The plugin supports three Movesense sensors. After a sensor connects, deviceType gives its model as a MovesenseDeviceType value. The plugin derives it from the hardware type, the hw field of the sensor's /Info resource:
| Sensor | Device type | Hardware type | Temperature sensor |
|---|---|---|---|
| Movesense MD | md | A1 | Yes |
| Movesense Active HR+ | hrPlus | H3 | Yes |
| Movesense HR2 | hr2 | H4 | No |
For any other hardware type, and while the device information is missing, deviceType is unknown. MovesenseDeviceType also has a flash value for the Movesense FLASH sensor, which the plugin does not detect automatically.
The plugin documents its temperature stream for the Movesense MD only.
Requirements
| Component | Requirement |
|---|---|
| Dart SDK | 3.12 or later |
| Flutter | 3.44 or later |
| Android | API level 24 (Android 7.0) or later |
| iOS | 15.0 or later |
| macOS | Not supported. The plugin registers, but startScan() and connect() throw a PlatformException, and requests and subscriptions fail with an MdsError. |
| Sensor | A Movesense MD, Active HR+ or HR2 |
| Testing | A physical phone. The bundled Movesense library has no x86_64 build for Android emulators and no build for the iOS simulator on Apple silicon Macs. |
See Installation for the platform setup.
To collect Movesense data in a CARP Mobile Sensing (CAMS) study, see Movesense Sampling Package.
Conflict with carp_movesense_package
carp_movesense_package 3.1.0 depends on carp_movesense_flutter, which bundles the same Movesense library as movesense_plus. With Swift Package Manager, an iOS app with both plugins does not build, so an app that uses carp_movesense_package 3.1.0 must not depend on movesense_plus.
To find sensors in such an app, see Find the sensor.
How it works
The plugin's Dart classes run in your app, and its native code talks to the sensor through MDS:
flowchart LR
App["<b>Your app</b><br/>Movesense and<br/>MovesenseDevice"] <--> Native["<b>Native plugin code</b><br/>Android and iOS, with<br/>the bundled MDS"]
Native <-->|BLE| Sensor["<b>Movesense sensor</b><br/>MD, Active HR+ or HR2"]
- Your app: uses a
Movesenseclient to start scans and send raw MDS requests. AMovesenseDevicefor each sensor connects to it and gives its status and typed streams. - Native plugin code: runs the BLE scan, filtered to the Movesense services, and passes connections, requests and subscriptions to MDS. The plugin bundles MDS for Android and iOS.
- Movesense sensor: answers requests and sends notifications for the resources that the app subscribes to.
A connected MovesenseDevice has typed streams for common resources and raw access to the rest:
hr turns each /Meas/HR notification into a MovesenseHR, while subscribe() emits each notification as a JSON string.
Next steps
Installation
Add the plugin and configure Android and iOS for Bluetooth.
Quickstart
Build an app that prints the heart rate from a sensor.
Connecting a device
Scan for sensors, connect to one and follow its status.
Sensor data
Stream heart rate, ECG, IMU and temperature data.