Skip to content

Commit 7270a94

Browse files
committed
add docs for basic usage
1 parent 003db9a commit 7270a94

File tree

1 file changed

+39
-1
lines changed

1 file changed

+39
-1
lines changed

README.md

+39-1
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,46 @@ For the most bleeding-edge experience - or if you plan to make and test changes
3737
c2bluetooth:
3838
path: ../c2bluetooth
3939
```
40+
4041
## Usage
41-
TBD
42+
Similar to how the underlying bluetooth library works, pretty much everything begins with an instance of `ErgBleManager()`. For a complete example, see the [example app](example/)
43+
44+
### Creating a manager
45+
46+
```dart
47+
ErgBleManager bleManager = ErgBleManager();
48+
bleManager.init(); //ready to go!
49+
```
50+
### Scanning for devices
51+
Next, you need to start scanning for available devices. This uses a Stream that returns instances of the `Ergometer` class that represent
52+
```dart
53+
bleManager.startErgScan().listen((erg) {
54+
//your code for detecting an erg here
55+
// maybe show it to the user and let them pick which one to connect to?
56+
});
57+
```
58+
59+
### Connecting to an erg
60+
Once you have the `Ergometer` instance for the erg you want to connect to, you can call `connectAndDiscover()` on it to connect.
61+
62+
```dart
63+
await myErg.connectAndDiscover();
64+
```
65+
66+
### Getting workout summaries
67+
To get data from the erg, use one of the methods available in the `Ergometer` class. Currently this is only `monitorForWorkoutSummary()`. This is a stream that returns a `WorkoutSummary` object that allows you to access the data from a completed programmed workout (i.e. not "Just Row").
68+
69+
```dart
70+
myErg.monitorForWorkoutSummary().listen((workoutSummary) {
71+
//do whatever here
72+
});
73+
```
74+
75+
### Disconnecting
76+
When you are done, make sure to disconnect from your erg:
77+
```dart
78+
await myErg.disconnectOrCancel();
79+
```
4280

4381
## Unit Testing
4482
Tests can be run with `flutter test` or `flutter test --coverage` for coverage information.

0 commit comments

Comments
 (0)