brilliant_ble

Creator: coderz1093

Last updated:

0 purchases

brilliant_ble Image
brilliant_ble Images

Languages

Categories

Add to Cart

Description:

brilliant ble

BrilliantBle #
A Flutter package to connect to BLE devices by brilliant Labs
It Uses FlutterBluePlus as a dependency to connect to BLE devices.
Provide an abstraction layer over the FlutterBluePlus package to make it easier to connect to BLE devices and to read write files and data to devices.
Features #

Connect to BLE devices (Brilliant Labs devices only for now)
a. Monocle (Supported)
b. Frame (TODO)
Read and write data to BLE devices
Read and write files to BLE devices

Getting started #
Install the package by adding the following to your pubspec.yaml file:
dependencies:
brilliant_ble: ^0.0.3
copied to clipboard
or with flutter pub
flutter pub add brilliant_ble
copied to clipboard
Then run flutter pub get to install the package.
For Android #
flutter_blue_plus is compatible only from version 21 of Android SDK so you should change this in your android/app/build.gradle file
android/app/build.gradle:
android {
defaultConfig {
minSdkVersion: 21
copied to clipboard
Add the following permissions to your AndroidManifest.xml file
android/app/src/main/AndroidManifest.xml:
<!-- Tell Google Play Store that your app uses Bluetooth LE
Set android:required="true" if bluetooth is necessary -->
<uses-feature android:name="android.hardware.bluetooth_le" android:required="false" />

<!-- New Bluetooth permissions in Android 12
https://developer.android.com/about/versions/12/features/bluetooth-permissions -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />

<!-- legacy for Android 11 or lower -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" android:maxSdkVersion="30"/>

<!-- legacy for Android 9 or lower -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" android:maxSdkVersion="28" />
copied to clipboard
For iOS #
Add the following permissions to your Info.plist file
<dict>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>This app always needs Bluetooth to function</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>This app needs Bluetooth Peripheral to function</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app always needs location and when in use to function</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app always needs location to function</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs location when in use to function</string>
<key>UIBackgroundModes</key>
<array>
<string>bluetooth-central</string>
</array>
copied to clipboard
Usage #
ble = await BrilliantBle.create();
ble.onConnected = () {
print("connected");
};
ble.onDisconnected = () {
print("Disconnected");

};
ble.onData = (data) {
// Data Recieved from the device
print(String.fromCharCodes(data));
};
await ble.setup();

copied to clipboard
Then after connecting to the device you can send and receive data using the following methods
//send data to the device with waiting for response
var response = await ble.sendData("print('hello world')\n\r");
print(response); // output: hello world
//send data to the device without waiting for response
await ble.sendData("print('hello world')\n\r", wait: false);

//send upload file to the device
await ble.uploadFile("file.txt", "file content");
copied to clipboard
Check connection status
var status = await ble.isConnected();
print(status); // output: true or false
copied to clipboard
Disconnect from the device
await ble.disconnect();
copied to clipboard
Check name of the connected device
var name = await ble.device.advName();
print(name); // output: monocle/frame
copied to clipboard
If want to manually scan and connect to the device
await ble.scan();
var devices = ble.devices;
for (var d in devices) {
print(d.advName);
}

// connect to first device
var device = await ble.connect(device[0]);
copied to clipboard
TODO #

✅ Add support for Monocle REPL (Done)
❌ Add support for Monocle File System
❌ Add support for Monocle Data service
❌ Add support for Monocle Device Firmware Update
✅ Add support for Frame (Done)
❌ Add support for Frame File System (WIP)
❌ Add support for Frame Device Firmware Update

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.