You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
which runs on [RxAndroidBle](https://github.com/Polidea/RxAndroidBle)
12
-
and [RxBluetoothKit](https://github.com/Polidea/RxBluetoothKit).
12
+
and [RxBluetoothKit](https://github.com/Polidea/RxBluetoothKit).
13
13
14
14
## BLE Simulator
15
-
This library supports [BLEmulator](https://github.com/Polidea/blemulator_flutter), the BLE simulator.
15
+
16
+
This library supports [BLEmulator](https://github.com/Polidea/blemulator_flutter), the BLE simulator.
16
17
The simulation allows one to develop without physical smartphone or BLE peripheral and use one's production BLE–related code in automated testing.
17
18
19
+
## Installation
20
+
21
+
To use this plugin, add `flutter_ble_lib` as a [dependency in your pubspec.yaml file](https://flutter.dev/docs/development/packages-and-plugins/using-packages).
22
+
23
+
### Android
24
+
25
+
Set `minSDKVersion` in `[project]/android/app/build.gradle` file to 18.
26
+
27
+
```gradle
28
+
defaultConfig {
29
+
...
30
+
minSdkVersion 18
31
+
...
32
+
}
33
+
```
34
+
35
+
Support for Bluetooth Low Energy has been added in API 18, hence the library requires `minSDKVersion` to be set to 18. If BLE is not core to your application, [you can override it](https://stackoverflow.com/questions/27335889/how-do-i-ignore-minsdkversion-of-library-in-android-studio) and handle support detection in your code.
36
+
37
+
**Notice:** You don't need to add any permissions related to BLE to the `AndroidManifest.xml`, because they are already declared in the library's native module. However, you still need to request `ACCESS_FINE_LOCATION` permission at runtime to be able to scan for peripheral. See [example's code](https://github.com/Polidea/FlutterBleLib/blob/202c6fe48300be207f80567ca4bee5b6fbc83eb5/example/lib/devices_list/devices_bloc.dart#L80) and [example's pubspec](https://github.com/Polidea/FlutterBleLib/blob/202c6fe48300be207f80567ca4bee5b6fbc83eb5/example/pubspec.yaml#L20).
38
+
39
+
### iOS
40
+
41
+
Go to `[project]/ios` directory and run `pod install`.
42
+
43
+
Add [Privacy - Bluetooth Always Usage Description](https://developer.apple.com/documentation/bundleresources/information_property_list/nsbluetoothalwaysusagedescription) key to `[project]/ios/Runner/Info.plist` file.
44
+
45
+
```xml
46
+
...
47
+
<key>NSBluetoothAlwaysUsageDescription</key>
48
+
<string>Your own description of the purpose.</string>
49
+
...
50
+
```
51
+
18
52
## Usage
19
-
To use this plugin, add `flutter_ble_lib` as a [dependency in your pubspec.yaml file](https://pub.dev/packages/flutter_ble_lib/versions/2.0.0-dev.4).
20
53
21
-
## Overview
22
54
The library is organised around a few base entities, which are:
23
-
***BleManager**
24
-
***Peripheral**
25
-
***Service**
26
-
***Characteristic**
27
55
28
-
You have to create an instance _BleManager_ and initialise underlying native resources.
56
+
-**BleManager**
57
+
-**Peripheral**
58
+
-**Service**
59
+
-**Characteristic**
60
+
***Descriptor**
61
+
62
+
You have to create an instance _BleManager_ and initialise underlying native resources.
29
63
Using that instance you then obtain an instance of _Peripheral_,
30
-
which can be used to run operations on the corresponding peripheral.
31
-
32
-
All operations passing the Dart-native bridge are asynchronous,
33
-
hence all operations in the plugin return either Future or Stream.
64
+
which can be used to run operations on the corresponding peripheral.
65
+
66
+
All operations passing the Dart-native bridge are asynchronous,
67
+
hence all operations in the plugin return either Future or Stream.
34
68
35
69
For more informations, see [REFERENCE](https://github.com/Polidea/FlutterBleLib/blob/master/REFERENCE.md).
36
70
37
-
**Notice:** this library will not handle any permissions for you. To be able to scan for peripherals on Android you need `ACCESS_FINE_LOCATION`[according to Android Developer Guide](https://developer.android.com/guide/topics/connectivity/bluetooth-le#permissions).
71
+
**Notice:** this library will not handle any permissions for you. To be able to scan for peripherals on Android you need `ACCESS_FINE_LOCATION`[according to Android Developer Guide](https://developer.android.com/guide/topics/connectivity/bluetooth-le#permissions).
38
72
39
73
### Initialising
74
+
40
75
```dart
41
76
BleManager bleManager = BleManager();
42
77
await bleManager.createClient(); //ready to go!
43
78
// your peripheral logic
44
79
bleManager.destroyClient(); //remember to release native resources when you're done!
45
80
```
81
+
46
82
Following snippets assume the library has been initialised.
Monitoring or reading a characteristic from _Peripheral_/_Service_ level
159
-
return _CharacteristicWithValue_ object, which is _Characteristic_ with additional `Uint8List value` property.
204
+
return _CharacteristicWithValue_ object, which is _Characteristic_ with additional `Uint8List value` property.
205
+
206
+
### Descriptor operations
207
+
208
+
List of descriptors from a single characteristic can be obtained in a similar fashion to a list of characteristics from a single service, either from Peripheral, Service or Characteristic object.
209
+
Descriptors can be read/written from Peripheral, Service or Characteristic by supplying necessary UUIDs, or from Descriptor object.
210
+
211
+
**Note:** to enable monitoring of characteristic you should use `characteristic.monitor()` or `(peripheral/service).monitorCharacteristic()` instead of changing the value of the underlying descriptor yourself.
160
212
161
213
## Facilitated by Frontside
162
214
[Frontside](https://github.com/thefrontside) provided architectural advice and financial support for this library on behalf of [Resideo](https://github.com/resideo).
163
215
164
216
## Maintained by
217
+
165
218
This library is maintained by [Polidea](https://www.polidea.com/?utm_source=Github&utm_medium=Npaid&utm_campaign=Main&utm_term=Code&utm_content=GH_NOP_MPG_COD_FBLE001)
[Learn more about Polidea's BLE services](https://www.polidea.com/services/ble/?utm_source=Github&utm_medium=Npaid&utm_campaign=Tech_BLE&utm_term=Code&utm_content=GH_NOP_BLE_COD_FBLE001).
170
223
171
224
#### Maintainers
225
+
172
226
TBD
173
227
174
228
## License
229
+
175
230
Copyright 2019 Polidea Sp. z o.o
176
231
177
232
Licensed under the Apache License, Version 2.0 (the "License");
@@ -187,7 +242,9 @@ See the License for the specific language governing permissions and
0 commit comments