패키지, 저장소 및 앱 카테고리 검색

패키지 상세v0.0.4

bluetooth_classic

블루투스 클래식 장치에 연결하기 위한 플러터 플러그인으로, 주로 시리얼 통신과 함께 작동하도록 설계되었습니다.

Android
30일 다운로드
1.1천
좋아요
27
Pub 점수
145

패키지 설치

flutter pub add bluetooth_classic

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

블루투스 클래식 장치에 연결할 수 있는 플러터 플러그인으로, 주로 시리얼 통신을 위해 사용됩니다. 안드로이드에서 블루투스 클래식 주변기기를 탐지하고 페어링하며 데이터를 교환할 수 있는 간단한 인터페이스를 제공합니다. 산업용 센서, 의료 기기 또는 맞춤형 하드웨어와 같은 신뢰성 있고 저수준의 데이터 전송이 필요한 애플리케이션용으로 설계되었습니다. 개발자가 장치 통신에 집중할 수 있도록 안드로이드의 블루투스 API와 원활하게 통합되며 최소한의 추상화 계층을 제공합니다.

사용 사례

  • 레거시 블루투스 장치에 연결
  • 시리얼 데이터 전송
  • 산업 센서 통합
  • 의료 기기 통신
  • 사용자 지정 하드웨어 제어

주요 기능

  • 안드로이드 전용 지원
  • 시리얼 통신 초점
  • 장치 탐지 및 페어링
  • 저수준 데이터 전송
  • 블루투스 클래식용 간단한 API

적합한 대상

  • Android 앱 개발자
  • 하드웨어 통합업체
  • 블루투스 클래식을 사용한 사물인터넷 프로젝트
  • 시리얼 프로토콜 구현

고려 사항

  • Android 플랫폼에 한정
  • iOS 지원 없음
  • 블루투스 권한 필요
  • 기기 호환성에 따라 다릅니다
  • 연결 상태 수동 처리

원본 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

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.