搜尋套件、儲存庫與 APP 分類

套件詳情v0.2.8

flutter_serial_communication

用於串列通訊的函式庫。目前支援透過 Android USB(OTG)與 Android 上的 Arduino 及其他 USB 串列硬體通訊,且無需使用 root 權限。

Android
近 30 天下載
2090
喜歡數
32
Pub 分數
160

安裝套件

flutter pub add flutter_serial_communication

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 套件,透過 USB OTG 在 Android 裝置上啟用序列通訊,允許與 Arduino 及其他 USB 序列硬體互動,無需取得 root 權限。它利用 Android 的 USB 主機 API 建立可靠的連接以進行資料交換。此函式庫專為需要透過序列協定與外部硬體(例如感測器或微控制器)互動的開發者設計。它簡化了在 Android 上的 Flutter 應用中設定和處理序列埠的過程。

適用情境

  • 透過 USB OTG 連接到 Arduino
  • 從外部硬體讀取傳感器數據
  • 透過串列協定控制物聯網裝置
  • 開發工業或實驗室自動化應用程式
  • 為嵌入式系統建構移動介面

主要特色

  • Android上的USB OTG支援
  • 無需根存取權限
  • 串口管理的簡單API
  • 即時資料流
  • 跨平台相容(僅限 Android)
  • 內建錯誤處理

適合對象

  • 物聯網應用開發者
  • 硬體介接專案
  • 教育機器人
  • 嵌入式系統控制應用
  • 僅限 Android 的串列通訊需求

使用建議

  • 僅限Android平台
  • 需要 USB OTG 硬體
  • 可能需要權限處理
  • 設備特定的USB相容性
  • 不適用於iOS或桌面端

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

About Flutter Serial Communication

This library aims to ease Flutter Developers to do serial communcation with their peripherals without too much hassle.

Currently supports Android USB (OTG) to communicate with Arduinos and other USB serial hardware on Android WITHOUT using root access.

Installing

1. Install it to your flutter project

flutter pub add flutter_serial_communication

or by adding dependencies to your package's pubspec.yaml then run dart pub get

dependencies:
  flutter_serial_communication: 0.2.8

2. Import it in your .dart file

import 'package:flutter_serial_communication/flutter_serial_communication.dart';

Features

  • Doesn't require root in Android
  • Easy to use
  • Using listener for reading message & device connection status

Functions

  • Get All Available Devices:
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();

List<DeviceInfo> availableDevices = await _flutterSerialCommunicationPlugin.getAvailableDevices();
  • Connect:
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();

DeviceInfo device = DeviceInfo(); // DeviceInfo from getAvailableDevices()
int baudRate = 0; // Your device's baud rate
bool isConnectionSuccess = await _flutterSerialCommunicationPlugin.connect(device, baudRate);
  • Disconnect:
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();

await _flutterSerialCommunicationPlugin.disconnect();
  • Write:
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();

bool isMessageSent = await _flutterSerialCommunicationPlugin.write(Uint8List.fromList([0xBB, 0x00, 0x22, 0x00, 0x00, 0x22, 0x7E]));
debugPrint("Is Message Sent:  $isMessageSent");
  • Read (Listener):
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();

EventChannel eventChannel = _flutterSerialCommunicationPlugin.getSerialMessageListener();
eventChannel.receiveBroadcastStream().listen((event) {
  debugPrint("Received From Native:  $event");
});
  • Device Connection Status (Listener):
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();

EventChannel eventChannel = _flutterSerialCommunicationPlugin.getDeviceConnectionListener();
eventChannel.receiveBroadcastStream().listen((event) {
  debugPrint("Received From Native:  $event");
});

Implementation

所屬分類

依賴

依賴清單 1 項

  • plugin_platform_interface^2.0.2

原始碼儲存庫

使用此套件的專案

暫無相關資料。