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

flutter_bluetooth_serial 표지
패키지 상세v0.4.0

flutter_bluetooth_serial

기본적인 Flutter 블루투스 시리얼 라이브러리

Android
30일 다운로드
1.1만
좋아요
377
Pub 점수
130

패키지 설치

flutter pub add flutter_bluetooth_serial

패키지 개요

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

안드로이드에서 블루투스 시리얼 장치와 연결하고 통신하기 위한 가벼운 플러터 패키지입니다. 센서, 마이크로컨트롤러 또는 맞춤형 IoT 장치와 같은 호환 가능한 하드웨어와 표준 블루투스 시리얼 프로토콜을 사용하여 양방향 데이터 전송을 가능하게 합니다. 이 라이브러리는 저수준 블루투스 작업을 추상화하여 스캔, 페어링 및 데이터 전송/수신을 위한 사용하기 쉬운 API를 제공합니다. 안드로이드 전용으로 설계되어 복잡한 설정 없이 기본적인 블루투스 기능을 지원합니다.

사용 사례

  • 아두이노 기반 장치에 연결
  • 블루투스 모듈에서 센서 데이터 전송
  • 블루투스를 통한 사물인터넷 장치 제어
  • 사용자 정의 하드웨어 주변 장치와의 통합
  • 모바일 앱에서 실시간 데이터 교환 활성화

주요 기능

  • 블루투스 통신을 위한 간단한 API
  • Android 전용 지원
  • 양방향 데이터 전송
  • 장치 탐지 및 페어링
  • 경량이며 최소한의 종속성

적합한 대상

  • IoT 애플리케이션 개발자
  • 하드웨어 통합 프로젝트
  • 교육 로보틱스
  • 임베디드 시스템 프로토타이핑
  • Android 전용 블루투스 애플리케이션

고려 사항

  • Android 플랫폼에 한정
  • iOS 지원 없음
  • 매니페스트에서 블루투스 권한이 필요합니다
  • 시리얼 프로토콜과 장치 호환성에 따라 다릅니다
  • 고급 블루투스 프로파일이 없는 기본 기능 세트

원본 README

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

flutter_bluetooth_serial

pub package

Flutter basic implementation for Classical Bluetooth (only RFCOMM for now).

Features

The first goal of this project, started by @edufolly was making an interface for Serial Port Protocol (HC-05 Adapter). Now the plugin features:

  • Adapter status monitoring,

  • Turning adapter on and off,

  • Opening settings,

  • Discovering devices (and requesting discoverability),

  • Listing bonded devices and pairing new ones,

  • Connecting to multiple devices at the same time,

  • Sending and receiving data (multiple connections).

The plugin (for now) uses Serial Port profile for moving data over RFCOMM, so make sure there is running Service Discovery Protocol that points to SP/RFCOMM channel of the device. There could be max up to 7 Bluetooth connections.

For now there is only Android support.

Funding

Your contribution will help drive the development of quality tools for the Flutter and Dart developer community. Any amount will be appreciated. Thank you for your continued support!

BuyMeACoffee

PIX

Sua contribuição ajudará a impulsionar o desenvolvimento de ferramentas de qualidade para a comunidade de desenvolvedores Flutter e Dart. Qualquer quantia será apreciada. Obrigado pelo seu apoio contínuo!

PIX

Getting Started

Depending
# Add dependency to `pubspec.yaml` of your project.
dependencies:
  # ...
  flutter_bluetooth_serial: ^0.4.0
Installing
flutter pub get
Importing
import 'package:flutter_bluetooth_serial/flutter_bluetooth_serial.dart';
Usage

You should look to the Dart code of the library (mostly documented functions) or to the examples code.

// Some simplest connection :F
try {
    BluetoothConnection connection = await BluetoothConnection.toAddress(address);
    print('Connected to the device');

    connection.input.listen((Uint8List data) {
        print('Data incoming: ${ascii.decode(data)}');
        connection.output.add(data); // Sending data

        if (ascii.decode(data).contains('!')) {
            connection.finish(); // Closing connection
            print('Disconnecting by local host');
        }
    }).onDone(() {
        print('Disconnected by remote request');
    });
}
catch (exception) {
    print('Cannot connect, exception occured');
}

Note: Work is underway to make the communication easier than operations on byte streams. See #41 for discussion about the topic.

Examples

Check out example application with connections with both Arduino HC-05 and Raspberry Pi (RFCOMM) Bluetooth interfaces.

Main screen and options Discovery and connecting Simple chat with server Background connection

To-do list

  • Add some utils to easier manage BluetoothConnection (see discussion #41),
  • Allow connection method/protocol/UUID specification,
  • Listening/server mode,
  • Recognizing and displaying BluetoothClass of device,
  • Maybe integration with flutter_blue one day ;)

You might also want to check milestones.

Credits

  • [Eduardo Folly](mailto:edufolly@gmail.com)
  • [Martin Mauch](mailto:martin.mauch@gmail.com)
  • [Patryk Ludwikowski](mailto:patryk.ludwikowski.7@gmail.com)

After version 0.3.0 we have a lot of collaborators. If you would like to be credited, please send me an [email](mailto:edufolly@gmail.com).

카테고리

소스 저장소

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