ble_reader

Creator: coderz1093

Last updated:

0 purchases

ble_reader Image
ble_reader Images

Languages

Categories

Add to Cart

Description:

ble reader

Bluetooth Low Energy Received Data Reader #
Install #
This project is a flutter plugin,so you use it by add dependencies in your pubspec.yaml.
dependencies:
flutter:
sdk: flutter
ble_reader: ^0.1.0
copied to clipboard
$ flutter pub get
copied to clipboard
How to use #
Please check the example app to see how to broadcast received data.
Getting Started #
Android #
You need to add the following permissions to your AndroidManifest.xml file:
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="30" />
copied to clipboard
If you use BLUETOOTH_SCAN to determine location, modify your AndroidManfiest.xml file to include the following entry:
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
tools:remove="android:usesPermissionFlags"
tools:targetApi="s" />
copied to clipboard
If you use location services in your app, remove android:maxSdkVersion="30" from the location permission tags
Android ProGuard rules #
In case you are using ProGuard add the following snippet to your proguard-rules.pro file:
-keep class com.signify.hue.** { *; }
copied to clipboard
This will prevent issues like #131.
iOS #
For iOS it is required you add the following entries to the Info.plist file of your app. It is not allowed to access Core BLuetooth without this. See our example app on how to implement this. For more indepth details: Blog post on iOS bluetooth permissions
iOS13 and higher

NSBluetoothAlwaysUsageDescription

iOS12 and lower

NSBluetoothPeripheralUsageDescription

Usage #
Import #
Import plugin module where you need use.
import 'package:ble_reader/ble_reader.dart';
copied to clipboard
Initialization #
Initializing the library should be done the following:
final bleReader = BleReader();
copied to clipboard
Setup connectivity and configure GATT server. #
final result = await BleReader.setupConnection;
if (!result) throw Exception('error bitches!!');
// do something
copied to clipboard
#
StreamBuilder(
stream: BleReader.receivedDataStream,
initialData: 'None',
builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
return Text('Data received: ${snapshot.data}');
},
);
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.