UniversalBLE is a versatile Flutter plugin that enables seamless Bluetooth Low Energy (BLE) connectivity across all major platforms, including Android, iOS, macOS, Windows, Linux, and Web. Its robust features like scanning, connecting, and service discovery make it easy to integrate BLE functionalities into your applications.
UniversalBLE is a versatile cross-platform Bluetooth Low Energy (BLE) plugin specifically designed for Flutter, enabling seamless integration across Android, iOS, macOS, Windows, Linux, and Web. Whether you're developing mobile apps or web applications, UniversalBLE simplifies the process of Bluetooth connectivity with robust features and a user-friendly API.
Key Features
- Scanning: Effortlessly discover nearby BLE devices with the ability to filter using specific services and manufacturer data.
- Connecting: Establish secure connections to BLE devices and manage connection states with ease.
- Discovering Services: Automatically explore available services and their characteristics once connected.
- Reading & Writing Data: Interact with devices by reading from or writing data to specific characteristics.
- Pairing: Simplify the pairing process with support for pairing state changes and durable device connections.
- Bluetooth Availability: Check the Bluetooth state of the device and respond to availability changes dynamically.
- Command Queue: Manage command execution with a queue system, allowing for either sequential or parallel command processing based on your application needs.
- Timeout Management: Customize command timeout settings to suit your application's requirements.
- UUID Format Agnostic: Utilize any UUID format for services and characteristics; UniversalBLE handles conversions seamlessly.
Usage Example
To get started with UniversalBLE, integrate it into your Flutter project:
dependencies:
universal_ble:
Once integrated, import the library:
import 'package:universal_ble/universal_ble.dart';
Scanning for Devices
UniversalBle.onScanResult = (bleDevice) {
// Utilize the device ID from scan results
};
UniversalBle.startScan(); // Start scanning for BLE devices
Connecting to a Device
String deviceId = bleDevice.deviceId;
UniversalBle.connect(deviceId);
// Monitor connection state changes
UniversalBle.onConnectionChange = (String deviceId, bool isConnected, String? error) {
debugPrint('Connection State Changed: $deviceId, $isConnected\nError: $error');
};
Reading Data
UniversalBle.readValue(deviceId, serviceId, characteristicId);
With UniversalBLE, developers can build rich applications that leverage Bluetooth connectivity without the hassle of platform-specific intricacies. Whether you're building IoT applications, health monitoring tools, or a range of other innovative solutions, UniversalBLE is your go-to plugin for Flutter.