capacitor-community / proposals

Plugin and platform requests ✋
74 stars 2 forks source link

Bluetooth classic #138

Open alexcroox opened 3 years ago

alexcroox commented 3 years ago

Plugin Request

Name: Bluetooth Classic Package: @capacitor-community/bluetooth-classic

Platform(s)

ios, android

Existing Solutions

https://github.com/soltius/BluetoothClassicSerial https://github.com/don/BluetoothSerial

Description

While there are plenty of BLE plugins for Capacitor there isn't any I could find for Bluetooth Classic (Bluetooth Core Spec: 3.0)

Glavotaner commented 1 year ago

I've made a Capacitor version of don's plugin , albeit only for Android, specifically in order to handle the new CONNECT and SCAN runtime bluetooth permissions. At bluetooth-serial.

It differs from the original in that methods are now promise-based, not callback-based. Certain methods were also removed but can be added back if need be, such as the ability to subscribe to a stream of data emitted from the connected device; there is a read method that returns data currently in the buffer instead.

Another distinction is that the original plugin was adapted to work on Android 4 devices (a workaround in the connect method); this was removed.

It is not yet battle tested though, I haven't had many opportunities to test it heavily.