Skip to content

Commit c52173d

Browse files
authored
Merge pull request #1284 from carp-dk/bardram-movesense-plus-hr-update
movesense_plus v. 1.2.0 published
2 parents 01aab9f + dd9920c commit c52173d

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

packages/movesense_plus/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.2.0
2+
3+
* connect and disconnect method not async
4+
* update to docs
5+
16
## 1.1.1
27

38
Update of docs to highlight that the `address` format is platform dependent:

packages/movesense_plus/example/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,10 @@ class MovesenseHomePageState extends State<MovesenseHomePage> {
8484
void onButtonPressed() {
8585
setState(() {
8686
if (!device.isConnected) {
87-
// if not connected, connect to the device
87+
// if not connected, start connecting to the device
8888
device.connect();
8989
} else {
90-
// when connected, first get device info and battery status
90+
// if connected, first get device info and battery status
9191
device.getDeviceInfo().then(
9292
(info) => debugPrint('>> Product name: ${info?.productName}'),
9393
);

packages/movesense_plus/lib/movesense_device.dart

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,14 @@ class MovesenseDevice {
6363
/// See https://www.movesense.com/docs/esw/api_reference/#info
6464
MovesenseDeviceInfo? get deviceInfo => _deviceInfo;
6565

66-
/// The battery level of the device, if known.
67-
/// Battery level is updated every 10 minutes when connected.
68-
DeviceBatteryLevel? get batteryLevel => _batteryLevel;
66+
/// The latest known battery level of the device.
67+
/// Battery level can be obtained by calling [getBatteryStatus].
68+
DeviceBatteryLevel get batteryLevel => _batteryLevel;
6969

70-
/// Connect to the Movesense device using the [address] specified.
70+
/// Initiate connection to the Movesense device using the [address] specified.
7171
/// If the address is not set, an exception is thrown.
72-
Future<void> connect() async {
72+
/// Connection status updates are emitted on the [statusEvents] stream.
73+
void connect() {
7374
if (!canConnect()) {
7475
throw Exception('Cannot connect to device - address is not set.');
7576
}
@@ -96,10 +97,12 @@ class MovesenseDevice {
9697
);
9798
}
9899

99-
/// Disconnect from the Movesense device.
100-
Future<void> disconnect() async {
100+
/// Initiate disconnect from the Movesense device.
101+
void disconnect() async {
101102
if (!isConnected) return;
103+
serial = null;
102104
Mds.disconnect(address!);
105+
status = DeviceConnectionStatus.disconnected;
103106
}
104107

105108
/// Get the detailed info about this Movesense device.
@@ -151,7 +154,7 @@ class MovesenseDevice {
151154
((data, statusCode) {
152155
final dataContent = json.decode(data);
153156
num batteryState = dataContent["Content"] as num;
154-
// Movesense reports "OK" (0) or "LOW" (1) battery state
157+
// Movesense reports "OK" (0) or "low" (1) battery state
155158
_batteryLevel = batteryState == 0
156159
? DeviceBatteryLevel.ok
157160
: DeviceBatteryLevel.low;
@@ -274,7 +277,8 @@ enum MovesenseDeviceType {
274277
enum DeviceConnectionStatus { disconnected, connecting, connected, error }
275278

276279
/// Enumeration of the battery level of the Movesense device.
277-
enum DeviceBatteryLevel { low, ok, unknown }
280+
/// See https://www.movesense.com/docs/esw/api_reference/#systemstates
281+
enum DeviceBatteryLevel { ok, low, unknown }
278282

279283
/// Enumeration of the type of system state components available on the Movesense device.
280284
/// See https://www.movesense.com/docs/esw/api_reference/#systemstates

packages/movesense_plus/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: movesense_plus
22
description: "A Flutter package for Movesense sensor integration. Wraps the MDS plugin and provides easy access to Movesense device features and data streams."
3-
version: 1.1.1
3+
version: 1.2.0
44
homepage: https://github.com/cph-cachet/flutter-plugins/tree/master/packages/movesense_plus
55

66
environment:

0 commit comments

Comments
 (0)