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

패키지 상세v0.1.0

bluetooth

Flutter용 블루투스 플러그인

30일 다운로드
70
좋아요
37
Pub 점수
25

패키지 설치

flutter pub add bluetooth

패키지 개요

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

Flutter용 블루투스 패키지는 크로스플랫폼 블루투스 기능을 가능하게 하여 앱이 블루투스 장치를 탐지하고 연결하며 통신할 수 있도록 합니다. 근처 장치를 스캔하고 연결을 설정하며 데이터를 보내고 받는 데 사용할 수 있는 간단한 API를 제공합니다. 센서, 웨어러블 또는 사물인터넷(IoT) 장치와 상호작용하는 애플리케이션을 개발하는 개발자를 위한 것으로, 안드로이드 및 iOS에서 핵심 블루투스 작업을 지원합니다. 이 플러그인은 Flutter 커뮤니티에서 관리되며 pub.dev를 통해 Flutter 프로젝트에 원활하게 통합됩니다.

사용 사례

  • 블루투스 기능이 있는 센서에 연결 중
  • 웨어러블 장치와의 페어링
  • 모바일 기기와 블루투스 하드웨어 간의 데이터 전송
  • IoT 제어 애플리케이션 구축
  • 장치 간 통신 활성화

주요 기능

  • 장치 탐지 및 스캔
  • 블루투스 연결 관리
  • 데이터 전송 및 수신
  • 크로스 플랫폼 지원 (Android 및 iOS)
  • 간단하고 직관적인 API 설계

적합한 대상

  • IoT 애플리케이션 개발자
  • 웨어러블 기술 창작자
  • 하드웨어 통합 전문가
  • 블루투스 주변기기를 사용하는 모바일 앱 개발자
  • 블루투스 기능을 갖춘 프로토타이핑

고려 사항

  • 기기 수준의 블루투스 권한이 필요합니다
  • 기본 블루투스 작업에 제한됨(_BLE_ 전용 기능 없음)
  • 플랫폼별 동작은 다를 수 있습니다
  • 모든 에지 케이스에 대한 내장 오류 처리 없음
  • 외부 라이브러리 유지보수에 의존

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

pub package

Introduction

Type-safe, minimalistic Buetooth plugin for Flutter, a fork from orignal "FlutterBlue" plugin.

Cross-Platform Bluetooth LE

This plugin aims to offer the most from both platforms (iOS and Android).

Using the FlutterBlue instance, you can scan for and connect to nearby devices (BluetoothDevice). Once connected to a device, the BluetoothDevice object can discover services (BluetoothService), characteristics (BluetoothCharacteristic), and descriptors (BluetoothDescriptor). The BluetoothDevice object is then used to directly interact with characteristics and descriptors.

Usage

Obtain an instance
FlutterBlue flutterBlue = FlutterBlue.instance;
Scan for devices
/// Start scanning
var scanSubscription = flutterBlue.scan().listen((scanResult) {
    // do something with scan result
});

/// Stop scanning
scanSubscription.cancel();
Connect to a device
/// Create a connection to the device
var deviceConnection = flutterBlue.connect(device).listen((s) {
    if(s == BluetoothDeviceState.connected) {
        // device is connected, do something
    }
});

/// Disconnect from device
deviceConnection.cancel();
Discover services
List<BluetoothService> services = await device.discoverServices();
services.forEach((service) {
    // do something with service
});
Read and write characteristics
// Reads all characteristics
var characteristics = service.characteristics;
for(BluetoothCharacteristic c in characteristics) {
    List<int> value = await device.readCharacteristic(c);
    print(value);
}

// Writes to a characteristic
await device.writeCharacteristic(c, [0x12, 0x34])
Read and write descriptors
// Reads all descriptors
var descriptors = characteristic.descriptors;
for(BluetoothDescriptor d in descriptors) {
    List<int> value = await device.readDescriptor(d);
    print(value);
}

// Writes to a descriptor
await device.writeDescriptor(d, [0x12, 0x34])
Set notifications
await device.setNotifyValue(characteristic, true);
device.onValueChanged(characteristic).listen((value) {
    // do something with new value
});

Reference

FlutterBlue API
Android iOS Description
scan :white_check_mark: :white_check_mark: Starts a scan for Bluetooth Low Energy devices.
connect :white_check_mark: :white_check_mark: Establishes a connection to the Bluetooth Device.
state :white_check_mark: :white_check_mark: Gets the current state of the Bluetooth Adapter.
onStateChanged :white_check_mark: :white_check_mark: Stream of state changes for the Bluetooth Adapter.
BluetoothDevice API
Android iOS Description
discoverServices :white_check_mark: :white_check_mark: Discovers services offered by the remote device as well as their characteristics and descriptors.
services :white_check_mark: :white_check_mark: Gets a list of services. Requires that discoverServices() has completed.
readCharacteristic :white_check_mark: :white_check_mark: Retrieves the value of a specified characteristic.
readDescriptor :white_check_mark: :white_check_mark: Retrieves the value of a specified descriptor.
writeCharacteristic :white_check_mark: :white_check_mark: Writes the value of a characteristic.
writeDescriptor :white_check_mark: :white_check_mark: Writes the value of a descriptor.
setNotifyValue :white_check_mark: :white_check_mark: Sets notifications or indications on the specified characteristic.
onValueChanged :white_check_mark: :white_check_mark: Notifies when the characteristic's value has changed.
state :white_check_mark: :white_check_mark: Gets the current state of the Bluetooth Device.
onStateChanged :white_check_mark: :white_check_mark: Notifies of state changes for the Bluetooth Device.

Troubleshooting

Scanning for service UUID's doesn't return any results

Make sure the device is advertising which service UUID's it supports. This is found in the advertisement packet as UUID 16 bit complete list or UUID 128 bit complete list.

카테고리

의존성

의존성 목록 5 개

소스 저장소

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