l2cap_ble 0.0.1 copy "l2cap_ble: ^0.0.1" to clipboard
l2cap_ble: ^0.0.1 copied to clipboard

A flutter plugin to communicate with Bluetooth Low Energy devices using the L2CAP protocol.

L2CAP Flutter Package #

Pub Version GitHub License

Effortlessly integrate L2CAP communication into your Flutter apps with the L2CAP Flutter package. Streamline Bluetooth device communication with a simplified and intuitive interface.

Table of Contents #

Installation #

To use this package, add l2cap_ble as a dependency in your pubspec.yaml file:

dependencies:
  l2cap_ble: ^latest_version

Usage #

Scan for Bluetooth Devices: Use your preferred Bluetooth scanning package to find and obtain the deviceId of the target device.

Initialize L2CAP Communication: #

final ble = L2capBle();

Monitor Connection State: #

Subscribe to the connection state stream to track L2CAP connection progress.

final connectionStream = ble.getConnectionState();

Connect to Device: #

Establish a connection to the device using connectToDevice, and await the 'connected' state.

await ble.connectToDevice(deviceId);

Create L2CAP Channel: #

Use createL2capChannel to establish the L2CAP channel, providing the required psm.

final channelCreated = await ble.createL2capChannel(psm);

Exchange Messages: #

Send and receive messages seamlessly via the L2CAP channel with sendMessage.

final response = await ble.sendMessage(myMessage);

Disconnect Gracefully: #

Disconnect using disconnectFromDevice. The L2CAP channel closes automatically.

ble.disconnectFromDevice(deviceId);

Example #

Explore the example directory for a complete usage scenario, demonstrating L2CAP communication.

Contributing #

Contributions are welcome! If you encounter issues, have feature suggestions, or want to improve the package, feel free to open an issue or submit a pull request. Please read our Contribution Guidelines for more information.

License #

This project is licensed under the MIT License.

3
likes
110
pub points
52%
popularity

Publisher

verified publisherappsfactory.de

A flutter plugin to communicate with Bluetooth Low Energy devices using the L2CAP protocol.

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#bluetooth

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on l2cap_ble