v0.2.8
flutter_serial_communication
시리얼 통신을 위한 라이브러리입니다. 현재 Android USB(OTG)를 사용하여 Android에서 아두이노 및 기타 USB 시리얼 하드웨어와 통신할 수 있으며, root 권한 없이도 사용 가능합니다.
32좋아요 2.3천30일 다운로드160Pub 점수
Android
farellsujanto/flutter_serial_communication open-source repository details.
{"sdk":"flutter"}^2.0.2{"sdk":"flutter"}^2.0.0아래는 영문 원문 스냅샷입니다. 최신 내용은 GitHub에서 확인하세요.
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.
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';
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();
List<DeviceInfo> availableDevices = await _flutterSerialCommunicationPlugin.getAvailableDevices();
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();
DeviceInfo device = DeviceInfo(); // DeviceInfo from getAvailableDevices()
int baudRate = 0; // Your device's baud rate
bool isConnectionSuccess = await _flutterSerialCommunicationPlugin.connect(device, baudRate);
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();
await _flutterSerialCommunicationPlugin.disconnect();
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();
bool isMessageSent = await _flutterSerialCommunicationPlugin.write(Uint8List.fromList([0xBB, 0x00, 0x22, 0x00, 0x00, 0x22, 0x7E]));
debugPrint("Is Message Sent: $isMessageSent");
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();
EventChannel eventChannel = _flutterSerialCommunicationPlugin.getSerialMessageListener();
eventChannel.receiveBroadcastStream().listen((event) {
debugPrint("Received From Native: $event");
});
final _flutterSerialCommunicationPlugin = FlutterSerialCommunication();
EventChannel eventChannel = _flutterSerialCommunicationPlugin.getDeviceConnectionListener();
eventChannel.receiveBroadcastStream().listen((event) {
debugPrint("Received From Native: $event");
});