Skip to content

Commit 7dcbb0b

Browse files
committed
old ver of flutter_blue_plus with fixed UUID bug
1 parent 2826cfa commit 7dcbb0b

30 files changed

+10134
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
## 1.4.0
2+
* Android: Add clear gatt cache method #142 (thanks to joistaus)
3+
* Android: Opt-out of the `neverForLocation` permission flag for the `BLUETOOTH_SCAN` permission. (thanks to navaronbracke)
4+
5+
If `neverForLocation` is desired,
6+
opt back into the old behavior by adding an explicit entry to your Android Manifest:
7+
```
8+
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
9+
android:usesPermissionFlags="neverForLocation" />
10+
```
11+
* Android: Scan BLE long range -devices #139 (thanks to jonik-dev)
12+
* Android: Prevent deprecation warnings #107 (thanks to sqcsabbey)
13+
* Allow native implementation to handle pairing request #109 (thanks to JRazek)
14+
15+
## 1.3.1
16+
* Reverted: Ios: fixed manufacturer data parsing #104 (thanks to sqcsabbey)
17+
18+
## 1.3.0
19+
* Ios: fixed manufacturer data parsing #104 (thanks to sqcsabbey)
20+
* Ios: Fixed an error when calling the connect method of a connected device #106 (thanks to figureai)
21+
* Android: Scan Filter by Mac Address #57 (thanks to Zyr00)
22+
* Upgrading to linter 2.0.1, excluding generated ProtoBuf files from linting. (thanks to MrCsabaToth)
23+
24+
## 1.2.0
25+
* connect timeout fixed (thanks to crazy-rodney, sophisticode, SkuggaEdward, MousyBusiness and cthurston)
26+
* Add timestamp field to ScanResult class #59 (thanks to simon-iversen)
27+
* Add FlutterBlue.name to get the human readable device name #93 (thanks to mvo5)
28+
* Fix bug where if there were multiple subscribers to FlutterBlue.state and one cancelled it would accidentally cancel all subscribers (thank to MacMalainey and MrCsabaToth)
29+
30+
## 1.1.3
31+
* Read RSSI from a connected BLE device #1 (thanks to sophisticode)
32+
* Fixed a crash on Android OS 12 (added check for BLUETOOTH_CONNECT permission) (fixed by dspells)
33+
* Added BluetoothDevice constructor from id (MAC address) (thanks to tanguypouriel)
34+
* The previous version wasn't disconnecting properly and the device could be still connected under the hood as the cancel() was not called. (fixed by killalad)
35+
* dependencies update (min micro version updating)
36+
37+
## 1.1.2
38+
* Remove connect to BLE device after BLE device has disconnected #11 (fixed by sophisticode)
39+
* fixed Dart Analysis warnings
40+
41+
## 1.1.1
42+
* Copyright reverted to Paul DeMarco
43+
44+
## 1.1.0
45+
46+
* Possible crash fix caused by wrong raw data (fixed by narrit)
47+
* Ios : try reconnect on unexpected disconnection (fixed by EB-Plum)
48+
* Android: Add missing break in switch, which causes exceptions (fixed by russelltg)
49+
* Android: Enforcing maxSdkVersion on the ACCESS_FINE_LOCATION permission will create issues for Android 12 devices that use location for purposes other than Bluetooth (such as using packages that actually need location). (fixed by rickcasson)
50+
51+
## 1.0.0
52+
53+
* First public release
54+
55+
## Versions made while fixing bugs in fork https://github.com/boskokg/flutter_blue:
56+
57+
## 0.12.0
58+
59+
Supporting Android 12 Bluetooth permissions. #940
60+
61+
## 0.12.0
62+
63+
Delay Bluetooth permission & turn-on-Bluetooth system popups on iOS #964
64+
65+
## 0.11.0
66+
67+
The timeout was throwing out of the Future's scope #941
68+
Expose onValueChangedStream #882
69+
Android: removed V1Embedding
70+
Android: removed graddle.properties
71+
Android: enable background usage
72+
Android: cannot handle devices that do not set CCCD_ID (2902) includes BLUNO #185 #797
73+
Android: add method for getting bonded devices #586
74+
Ios: remove support only for x86_64 simulators
75+
Ios: Don't initialize CBCentralManager until needed #599
76+
77+
## 0.10.0
78+
79+
mtuRequest returns the negotiated MTU
80+
Android: functions to turn on/off bluetooth
81+
Android: add null check if channel is already teared down
82+
Android: code small refactoring (fixed AS warnings)
83+
Android: add null check if channel is already teared down
84+
Ios: widen protobuf version allowed
85+
86+
## 0.9.0
87+
88+
Android migrate to mavenCentral.
89+
Android support build on Macs M1
90+
Android protobuf-gradle-plugin:0.8.15 -> 0.8.17
91+
Ios example upgrade to latest flutter 2.5
92+
deprecated/removed widgets fixed in example

plugins/flutter_blue_plus/LICENSE

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Copyright 2021 Bosko Popovic. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without
4+
modification, are permitted provided that the following conditions are
5+
met:
6+
7+
* Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
* Redistributions in binary form must reproduce the above
10+
copyright notice, this list of conditions and the following disclaimer
11+
in the documentation and/or other materials provided with the
12+
distribution.
13+
* Neither the name of Buffalo PC Inc. nor the names of its
14+
contributors may be used to endorse or promote products derived from
15+
this software without specific prior written permission.
16+
17+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
[![pub package](https://img.shields.io/pub/v/flutter_blue_plus.svg)](https://pub.dartlang.org/packages/flutter_blue_plus)
2+
3+
<br>
4+
<p align="center">
5+
<img alt="FlutterBlue" src="https://github.com/boskokg/flutter_blue_plus/blob/master/site/flutterblue.png?raw=true" />
6+
</p>
7+
<br><br>
8+
9+
## Introduction
10+
11+
FlutterBluePlus is a bluetooth plugin for [Flutter](https://flutter.dev), a new app SDK to help developers build modern multi-platform apps. Note: this plugin is continuous work from FlutterBlue since maintaince stoped.
12+
13+
## Alpha version
14+
15+
**This package must be tested on a real device.**
16+
17+
## Cross-Platform Bluetooth LE
18+
FlutterBluePlus aims to offer the most from both platforms (iOS and Android).
19+
20+
Using the FlutterBluePlus instance, you can scan for and connect to nearby devices ([BluetoothDevice](#bluetoothdevice-api)).
21+
Once connected to a device, the BluetoothDevice object can discover services ([BluetoothService](lib/src/bluetooth_service.dart)), characteristics ([BluetoothCharacteristic](lib/src/bluetooth_characteristic.dart)), and descriptors ([BluetoothDescriptor](lib/src/bluetooth_descriptor.dart)).
22+
The BluetoothDevice object is then used to directly interact with characteristics and descriptors.
23+
24+
## Usage
25+
### Obtain an instance
26+
```dart
27+
FlutterBluePlus flutterBlue = FlutterBluePlus.instance;
28+
```
29+
30+
### Scan for devices
31+
```dart
32+
// Start scanning
33+
flutterBlue.startScan(timeout: Duration(seconds: 4));
34+
35+
// Listen to scan results
36+
var subscription = flutterBlue.scanResults.listen((results) {
37+
// do something with scan results
38+
for (ScanResult r in results) {
39+
print('${r.device.name} found! rssi: ${r.rssi}');
40+
}
41+
});
42+
43+
// Stop scanning
44+
flutterBlue.stopScan();
45+
```
46+
47+
### Connect to a device
48+
```dart
49+
// Connect to the device
50+
await device.connect();
51+
52+
// Disconnect from device
53+
device.disconnect();
54+
```
55+
56+
### Discover services
57+
```dart
58+
List<BluetoothService> services = await device.discoverServices();
59+
services.forEach((service) {
60+
// do something with service
61+
});
62+
```
63+
64+
### Read and write characteristics
65+
```dart
66+
// Reads all characteristics
67+
var characteristics = service.characteristics;
68+
for(BluetoothCharacteristic c in characteristics) {
69+
List<int> value = await c.read();
70+
print(value);
71+
}
72+
73+
// Writes to a characteristic
74+
await c.write([0x12, 0x34])
75+
```
76+
77+
### Read and write descriptors
78+
```dart
79+
// Reads all descriptors
80+
var descriptors = characteristic.descriptors;
81+
for(BluetoothDescriptor d in descriptors) {
82+
List<int> value = await d.read();
83+
print(value);
84+
}
85+
86+
// Writes to a descriptor
87+
await d.write([0x12, 0x34])
88+
```
89+
90+
### Set notifications and listen to changes
91+
```dart
92+
await characteristic.setNotifyValue(true);
93+
characteristic.value.listen((value) {
94+
// do something with new value
95+
});
96+
```
97+
98+
### Read the MTU and request larger size
99+
```dart
100+
final mtu = await device.mtu.first;
101+
await device.requestMtu(512);
102+
```
103+
Note that iOS will not allow requests of MTU size, and will always try to negotiate the highest possible MTU (iOS supports up to MTU size 185)
104+
105+
## Getting Started
106+
### Change the minSdkVersion for Android
107+
108+
flutter_blue_plus is compatible only from version 19 of Android SDK so you should change this in **android/app/build.gradle**:
109+
```dart
110+
Android {
111+
defaultConfig {
112+
minSdkVersion: 19
113+
```
114+
### Add permissions for Bluetooth
115+
We need to add the permission to use Bluetooth and access location:
116+
117+
#### **Android**
118+
In the **android/app/src/main/AndroidManifest.xml** let’s add:
119+
120+
```xml
121+
<uses-permission android:name="android.permission.BLUETOOTH" />
122+
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
123+
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
124+
<application
125+
```
126+
#### **IOS**
127+
In the **ios/Runner/Info.plist** let’s add:
128+
129+
```dart
130+
<dict>
131+
<key>NSBluetoothAlwaysUsageDescription</key>
132+
<string>Need BLE permission</string>
133+
<key>NSBluetoothPeripheralUsageDescription</key>
134+
<string>Need BLE permission</string>
135+
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
136+
<string>Need Location permission</string>
137+
<key>NSLocationAlwaysUsageDescription</key>
138+
<string>Need Location permission</string>
139+
<key>NSLocationWhenInUseUsageDescription</key>
140+
<string>Need Location permission</string>
141+
```
142+
143+
For location permissions on iOS see more at: [https://developer.apple.com/documentation/corelocation/requesting_authorization_for_location_services](https://developer.apple.com/documentation/corelocation/requesting_authorization_for_location_services)
144+
145+
146+
## Reference
147+
### FlutterBlue API
148+
| | Android | iOS | Description |
149+
| :--------------- | :----------------: | :------------------: | :-------------------------------- |
150+
| scan | :white_check_mark: | :white_check_mark: | Starts a scan for Bluetooth Low Energy devices. |
151+
| state | :white_check_mark: | :white_check_mark: | Stream of state changes for the Bluetooth Adapter. |
152+
| isAvailable | :white_check_mark: | :white_check_mark: | Checks whether the device supports Bluetooth. |
153+
| isOn | :white_check_mark: | :white_check_mark: | Checks if Bluetooth functionality is turned on. |
154+
155+
### BluetoothDevice API
156+
| | Android | iOS | Description |
157+
| :-------------------------- | :------------------: | :------------------: | :-------------------------------- |
158+
| connect | :white_check_mark: | :white_check_mark: | Establishes a connection to the device. |
159+
| disconnect | :white_check_mark: | :white_check_mark: | Cancels an active or pending connection to the device. |
160+
| discoverServices | :white_check_mark: | :white_check_mark: | Discovers services offered by the remote device as well as their characteristics and descriptors. |
161+
| services | :white_check_mark: | :white_check_mark: | Gets a list of services. Requires that discoverServices() has completed. |
162+
| state | :white_check_mark: | :white_check_mark: | Stream of state changes for the Bluetooth Device. |
163+
| mtu | :white_check_mark: | :white_check_mark: | Stream of mtu size changes. |
164+
| requestMtu | :white_check_mark: | | Request to change the MTU for the device. |
165+
| readRssi | :white_check_mark: | :white_check_mark: | Read RSSI from a connected device. |
166+
167+
### BluetoothCharacteristic API
168+
| | Android | iOS | Description |
169+
| :-------------------------- | :------------------: | :------------------: | :-------------------------------- |
170+
| read | :white_check_mark: | :white_check_mark: | Retrieves the value of the characteristic. |
171+
| write | :white_check_mark: | :white_check_mark: | Writes the value of the characteristic. |
172+
| setNotifyValue | :white_check_mark: | :white_check_mark: | Sets notifications or indications on the characteristic. |
173+
| value | :white_check_mark: | :white_check_mark: | Stream of characteristic's value when changed. |
174+
175+
### BluetoothDescriptor API
176+
| | Android | iOS | Description |
177+
| :-------------------------- | :------------------: | :------------------: | :-------------------------------- |
178+
| read | :white_check_mark: | :white_check_mark: | Retrieves the value of the descriptor. |
179+
| write | :white_check_mark: | :white_check_mark: | Writes the value of the descriptor. |
180+
181+
## Troubleshooting
182+
### When I scan using a service UUID filter, it doesn't find any devices.
183+
Make sure the device is advertising which service UUID's it supports. This is found in the advertisement
184+
packet as **UUID 16 bit complete list** or **UUID 128 bit complete list**.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
include: package:flutter_lints/flutter.yaml
2+
3+
# Additional information about this file can be found at
4+
# https://dart.dev/guides/language/analysis-options
5+
6+
analyzer:
7+
exclude:
8+
- /**.pbjson.dart
9+
- /**.pb.dart
10+
- /**.pbenum.dart
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
group 'com.boskokg.flutter_blue_plus'
2+
version '1.0'
3+
4+
buildscript {
5+
repositories {
6+
google()
7+
mavenCentral()
8+
}
9+
10+
dependencies {
11+
classpath 'com.android.tools.build:gradle:7.1.0'
12+
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.17'
13+
}
14+
}
15+
16+
rootProject.allprojects {
17+
repositories {
18+
google()
19+
mavenCentral()
20+
}
21+
}
22+
23+
apply plugin: 'com.android.library'
24+
apply plugin: 'com.google.protobuf'
25+
26+
android {
27+
compileSdkVersion 31
28+
29+
compileOptions {
30+
sourceCompatibility JavaVersion.VERSION_1_8
31+
targetCompatibility JavaVersion.VERSION_1_8
32+
}
33+
34+
defaultConfig {
35+
minSdkVersion 19
36+
}
37+
sourceSets {
38+
main {
39+
proto {
40+
srcDir '../protos'
41+
}
42+
}
43+
}
44+
}
45+
46+
protobuf {
47+
protoc {
48+
if (project.hasProperty('protoc_platform')) {
49+
artifact = "com.google.protobuf:protoc:3.18.0:${protoc_platform}"
50+
} else {
51+
artifact = "com.google.protobuf:protoc:3.18.0"
52+
}
53+
}
54+
generateProtoTasks {
55+
all().each { task ->
56+
task.builtins {
57+
java {
58+
option "lite"
59+
}
60+
}
61+
}
62+
}
63+
}
64+
65+
dependencies {
66+
implementation 'com.google.protobuf:protobuf-javalite:3.18.0'
67+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rootProject.name = 'flutter_blue_plus'

0 commit comments

Comments
 (0)