bluetooth_spp: منفذ Bluetooth Classic التسلسلي في Flutter لأجهزة OBD والطابعات
أغلب إضافات Bluetooth في Flutter تخص Bluetooth Low Energy. لكن عتادًا كثيرًا ما زال يتكلم البروتوكول الأقدم: قطع ELM327 لمنفذ OBD-II في السيارات، والطابعات الحرارية، والموازين، وقارئات الباركود، ووحدات HC-05. هذه الأجهزة تعرض منفذًا تسلسليًّا (serial port) فوق Bluetooth Classic، يُعرف بـ RFCOMM أو SPP، وهو من جهة التطبيق تدفق بايتات بسيط. تكتب بايتات وتقرأ بايتات. bluetooth_spp إضافة (plugin) لـ…
Bluetooth Serial Port Plugin for Flutter, known as bluetooth_spp, enables communication with OBD-II devices, thermal printers, scales, barcode readers, and HC-05 modules via a serial port on Bluetooth Classic (RFCOMM/SPP). The plugin offers a clean-room implementation alternative to flutter_bluetooth_serial, featuring an adapter stream, isEnabled() function, requestEnable() function, bondedDevices() function for paired device details, startDiscovery() for device discovery, bond(address) and removeBond(address) for pairing and unpairing, connect() for establishing connections, SppConnection with input, write(bytes), close(), disconnectReason, and multi-connection support with separate input/output threads.
The plugin provides secure socket options, error handling without main thread blocking, and specific Dart exceptions for different error types. It requires appropriate permissions in the manifest for Android 12 and later (BLUETOOTH_CONNECT, BLUETOOTH_SCAN, and BLUETOOTH_ADMIN with maxSdkVersion="30"), and older versions require BLUETOOTH and BLUETOOTH_ADMIN with maxSdkVersion="30".
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to