パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v0.0.4

bluetooth_classic

Bluetoothクラシックデバイスに接続するためのFlutterプラグインで、主にシリアル通信を想定して設計されています。

Android
30日間ダウンロード
1140
いいね数
27
Pub ポイント
145

パッケージをインストール

flutter pub add bluetooth_classic

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Bluetoothクラシックデバイスへの接続を可能にするFlutterプラグインで、主にシリアル通信に使用されます。Android上でBluetoothクラシック周辺機器の検出、ペアリング、データ交換を行うためのシンプルなインターフェースを提供します。産業用センサー、医療機器、カスタムハードウェアなど、信頼性の高い低レベルデータ転送が必要なアプリケーション向けに設計されています。AndroidのBluetooth APIとシームレスに統合されており、開発者がデバイス通信に集中できるように最小限の抽象化レイヤーを提供します。

用途

  • レガシーBluetoothデバイスへの接続
  • シリアルデータの送信
  • 産業用センサーの統合
  • 医療機器通信
  • カスタムハードウェア制御

主な機能

  • Android専用のサポート
  • シリアル通信の焦点
  • デバイスの検出とペアリング
  • ローレベルデータ送信
  • Bluetoothクラシック用のシンプルなAPI

適している対象

  • Androidアプリ開発者
  • ハードウェア統合業者
  • Bluetooth Classicを搭載したIoTプロジェクト
  • シリアルプロトコルの実装

注意事項

  • Androidプラットフォームに限定
  • iOS 対応なし
  • Bluetoothの権限が必要です
  • デバイスの互換性に依存します
  • 接続状態の手動処理

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

bluetooth_classic

A Flutter plugin to connect to Bluetooth Classic devices, mainly designed to work with serial communication.

Pub Version (including pre-releases) Pub Popularity

Features

  • check that permissions are granted to use the device
  • get already paired devices
  • scan for devices
  • connect & disconnect to a device
  • read from connected device
  • write to connected device

Installation

To install the package, simply run flutter pub add bluetooth_classic

Api Documentation

For a list of functions and their definitions, you can look at the documentation on pub.dev

Basic example

Getting Paired Devices
import 'package:bluetooth_classic/bluetooth_classic.dart';

final _bluetoothClassicPlugin = BluetoothClassic();
await _bluetoothClassicPlugin.initPermissions();
List<Device> _discoveredDevices = await _bluetoothClassicPlugin.getPairedDevices();
Scanning for Devices
import 'package:bluetooth_classic/bluetooth_classic.dart';
import 'package:bluetooth_classic/models/device.dart';

final _bluetoothClassicPlugin = BluetoothClassic();
List<Device> _discoveredDevices = [];
await _bluetoothClassicPlugin.initPermissions();
_bluetoothClassicPlugin.onDeviceDiscovered().listen(
  (event) {
    _discoveredDevices = [..._discoveredDevices, event];
  },
);
await _bluetoothClassicPlugin.startScan();
// when you want to stop scanning
await _bluetoothClassicPlugin.stopScan();

Connecting to a device, reading and sending data to it
import 'package:bluetooth_classic/bluetooth_classic.dart';

final _bluetoothClassicPlugin = BluetoothClassic();
Uint8List _data = Uint8List(0);

await _bluetoothClassicPlugin.initPermissions();
// connect to a device with its MAC address and the application uuid you want to use (in this example, serial)
await _bluetoothClassicPlugin.connect("AA:AA:AA:AA", "00001101-0000-1000-8000-00805f9b34fb");

// NB: I'm not doing error checking or seeing if the device is still connected in this code, check the [example folder](/example/lib/main.dart) for a more thorough demonstration
// send data to device
await _bluetoothClassicPlugin.write("ping");

//
_bluetoothClassicPlugin.onDeviceDataReceived().listen((event) {
  setState(() {
    _data = Uint8List.fromList([..._data, ...event]);
  });
});

// disconnect when done
await _bluetoothClassicPlugin.disconnect();

Example Code

You can find the latest example code in the example folder

カテゴリー

依存関係

依存関係一覧 1 件

  • plugin_platform_interface^2.0.2

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。