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

패키지 상세v1.1.1

win_ble

WinBle 플러그인을 사용하여 Flutter Windows 및 순수 Dart 프로젝트에서 블루투스 저전력 기능 활성화(Windows 전용)

Windows
30일 다운로드
13.7만
좋아요
39
Pub 점수
150

패키지 설치

flutter pub add win_ble

패키지 개요

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

win_ble 패키지는 Windows 및 순수 Dart 프로젝트를 대상으로 한 Flutter 애플리케이션에서 블루투스 저전력(BLE) 기능을 활성화합니다. Windows 전용으로 설계되어 원격 BLE 기능에 대한 다리 역할을 하며, 개발자가 장치를 탐지하고 주변기기와 연결하며 특성 값을 읽고 쓰고 BLE 작업을 관리할 수 있도록 합니다. 이 플러그인은 Windows 플랫폼에서 BLE 장치와의 저전력 무선 통신이 필요한 애플리케이션에 적합합니다. 플랫폼 채널을 통해 Windows 블루투스 API를 활용하여 Flutter 생태계 내에서 신뢰할 수 있는 성능을 보장합니다.

사용 사례

  • BLE 센서에 연결 중
  • BLE 비콘에서 데이터 읽기
  • BLE 기반 IoT 장치 제어
  • 윈도우 전용 건강 모니터링 앱 개발
  • 근접 기반 기능 구현

주요 기능

  • 윈도우 전용 BLE 지원
  • 네이티브 윈도우 블루투스 API 통합
  • 장치 탐지 및 연결 관리
  • 특성 읽기/쓰기 작업
  • 순수 Dart 호환성

적합한 대상

  • Windows 데스크톱 앱 개발자
  • 사물인터넷 장치 통합업체
  • 헬스 및 피트니스 앱 개발자
  • 블루투스 중심의 유틸리티 도구
  • Windows 고유의 BLE 요구 사항을 가진 크로스 플랫폼 앱

고려 사항

  • Windows 플랫폼에 제한됨
  • Windows 10 이상이 필요합니다
  • Android/iOS 지원 없음
  • 시스템 수준의 블루투스 권한에 의존함
  • 특정 하드웨어에 대해 추가 구성이 필요할 수 있습니다

원본 README

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

WinBle

win_ble version

Use the WinBle plugin to enable Bluetooth Low Energy in Flutter Windows and pure Dart projects (Windows only)

Usage

First initialize WinBle, to initialize on Flutter Windows, get server path using await WinServer.path, and for pure dart projects ( Windows only ) Download BleServer.exe file and place in the same folder, checkout example_dart for more details

  // To initialize on Flutter Windows
  await WinBle.initialize(serverPath: await WinServer.path());

  // For pure dart projects
  await WinBle.initialize(serverPath: "Path of BLEServer.exe file");

Dispose WinBle after using

 WinBle.dispose();

To Start Scan

 WinBle.startScanning();

 StreamSubscription? scanStream = WinBle.scanStream.listen((event) {
  // Get Devices Here
 });

To Stop Scan

  WinBle.stopScanning();

  scanStream?.cancel();

To Connect

 // To Connect
 await WinBle.connect(address);

 // Get Connection Updates Here
 StreamSubscription  _connectionStream =
    WinBle.connectionStreamOf(device.address).listen((event) {
    // event will be a boolean , in which
    // true => Connected
    // false => Disconnected
 });

To Disconnect

  await WinBle.disconnect(address);

To get MaxMtuSize

  await WinBle.getMaxMtuSize(address);

Handle Bluetooth radio

  // To get rdaio status
  WinBle.getBluetoothState();

  // To get updates of radio state
  WinBle.bleState.listen((BleState state) {
    // Get BleState (On, Off, Unknown, Disabled, Unsupported)
  });

  // To turn on radio
  WinBle.updateBluetoothState(true);

  // To turn off radio
  WinBle.updateBluetoothState(false);

Pairing Options

  // To Pair
  await WinBle.pair(address);

  // To UnPair
  await WinBle.unPair(address);

  // To Check if Device can be Paired
  bool canPair = await WinBle.canPair(address);

  // To Check if Device is Already Paired
  bool isPaired = await WinBle.isPaired(address);

Rest All Methods are

  // To Get Services
  var services = await WinBle.discoverServices(address);

  // To Get Characteristic
  List<BleCharacteristic> bleCharacteristics = await WinBle.discoverCharacteristics(address: address, serviceId: serviceID);

  // To Read Characteristic
  List<int> data = await WinBle.read(address: address, serviceId: serviceID, characteristicId: charID);

  // To Write Characteristic
  await WinBle.write( address: address, service: serviceID,  characteristic: charID,  data: data, writeWithResponse: writeWithResponse);

  // To Start Subscription
  await WinBle.subscribeToCharacteristic(address: address, serviceId: serviceID, characteristicId: charID);

  // To Stop Subscription
  await WinBle.unSubscribeFromCharacteristic(address: address, serviceId: serviceID, characteristicId: charID);

  // Get Characteristic Value Updates Here
   StreamSubscription _characteristicValueStream = WinBle.characteristicValueStream.listen((event) {
     // Here We will Receive All Characteristic Events
   });

Note

Requires Windows version >= 10.0.15014

If windows release build opens cmd while running app, try this

Edit your /windows/runner/main.cpp file, this is a known flutter issue

if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()){
CreateAndAttachConsole();
}
// Add this Code
// <------- From Here --------- >
else{
    STARTUPINFO si = {0};
    si.cb = sizeof(si);
    si.dwFlags = STARTF_USESHOWWINDOW;
    si.wShowWindow = SW_HIDE;

    PROCESS_INFORMATION pi = {0};
    WCHAR lpszCmd[MAX_PATH] = L"cmd.exe";
    if (::CreateProcess(NULL, lpszCmd, NULL, NULL, FALSE, CREATE_NEW_CONSOLE | CREATE_NO_WINDOW, NULL, NULL, &si, &pi))
    {
      do
      {
        if (::AttachConsole(pi.dwProcessId))
        {
          ::TerminateProcess(pi.hProcess, 0);
          break;
        }
      } while (ERROR_INVALID_HANDLE == GetLastError());
      ::CloseHandle(pi.hProcess);
      ::CloseHandle(pi.hThread);
    }
}
// <------- UpTo Here --------- >

Additional information

Thanks to noble-winrt for initial BleServer Code

This is Just The Initial Version feel free to Contribute or Report any Bug!

카테고리

의존성

의존성 목록 1 개

소스 저장소

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

순위