@capacitor-community/bluetooth-le 3.1.1 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
8
|
<p align="center">
|
|
9
|
-
<img src="https://img.shields.io/maintenance/yes/
|
|
9
|
+
<img src="https://img.shields.io/maintenance/yes/2024?style=flat-square" />
|
|
10
10
|
<a href="https://github.com/capacitor-community/bluetooth-le/actions?query=workflow%3A%22CI%22"><img src="https://img.shields.io/github/actions/workflow/status/capacitor-community/bluetooth-le/main.yml?branch=main&style=flat-square" /></a>
|
|
11
11
|
<a href="https://www.npmjs.com/package/@capacitor-community/bluetooth-le"><img src="https://img.shields.io/npm/l/@capacitor-community/bluetooth-le?style=flat-square" /></a>
|
|
12
12
|
<br>
|
|
13
13
|
<a href="https://www.npmjs.com/package/@capacitor-community/bluetooth-le"><img src="https://img.shields.io/npm/dw/@capacitor-community/bluetooth-le?style=flat-square" /></a>
|
|
14
14
|
<a href="https://www.npmjs.com/package/@capacitor-community/bluetooth-le"><img src="https://img.shields.io/npm/v/@capacitor-community/bluetooth-le?style=flat-square" /></a>
|
|
15
15
|
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
|
16
|
-
<a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-
|
|
16
|
+
<a href="#contributors-"><img src="https://img.shields.io/badge/all%20contributors-17-orange?style=flat-square" /></a>
|
|
17
17
|
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
|
18
18
|
</p>
|
|
19
19
|
|
|
@@ -353,8 +353,8 @@ _Note_: web support depends on the browser, see [implementation status](https://
|
|
|
353
353
|
| [`readRssi(...)`](#readrssi) | ✅ | ✅ | ❌ |
|
|
354
354
|
| [`read(...)`](#read) | ✅ | ✅ | ✅ |
|
|
355
355
|
| [`write(...)`](#write) | ✅ | ✅ | ✅ |
|
|
356
|
-
| [`readDescriptor(...)`](#
|
|
357
|
-
| [`writeDescriptor(...)`](#
|
|
356
|
+
| [`readDescriptor(...)`](#readdescriptor) | ✅ | ✅ | ✅ |
|
|
357
|
+
| [`writeDescriptor(...)`](#writedescriptor) | ✅ | ✅ | ✅ |
|
|
358
358
|
| [`writeWithoutResponse(...)`](#writewithoutresponse) | ✅ | ✅ | ✅ |
|
|
359
359
|
| [`startNotifications(...)`](#startnotifications) | ✅ | ✅ | ✅ |
|
|
360
360
|
| [`stopNotifications(...)`](#stopnotifications) | ✅ | ✅ | ✅ |
|
|
@@ -1107,6 +1107,11 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
|
|
1107
1107
|
<td align="center" valign="top" width="14.28%"><a href="https://github.com/td-tomasz-joniec"><img src="https://avatars.githubusercontent.com/u/109506928?v=4?s=100" width="100px;" alt="td-tomasz-joniec"/><br /><sub><b>td-tomasz-joniec</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=td-tomasz-joniec" title="Code">💻</a></td>
|
|
1108
1108
|
<td align="center" valign="top" width="14.28%"><a href="https://fanxj.com"><img src="https://avatars.githubusercontent.com/u/10436013?v=4?s=100" width="100px;" alt="Michele Ferrari"/><br /><sub><b>Michele Ferrari</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=micheleypf" title="Code">💻</a></td>
|
|
1109
1109
|
</tr>
|
|
1110
|
+
<tr>
|
|
1111
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/mchl18"><img src="https://avatars.githubusercontent.com/u/6136970?v=4?s=100" width="100px;" alt="mchl18"/><br /><sub><b>mchl18</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=mchl18" title="Documentation">📖</a></td>
|
|
1112
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/OpenSrcerer"><img src="https://avatars.githubusercontent.com/u/46500918?v=4?s=100" width="100px;" alt="Daniel Stefani"/><br /><sub><b>Daniel Stefani</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=OpenSrcerer" title="Code">💻</a></td>
|
|
1113
|
+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/lhd-biosency"><img src="https://avatars.githubusercontent.com/u/71714070?v=4?s=100" width="100px;" alt="Laurent"/><br /><sub><b>Laurent</b></sub></a><br /><a href="https://github.com/capacitor-community/bluetooth-le/commits?author=lhd-biosency" title="Code">💻</a></td>
|
|
1114
|
+
</tr>
|
|
1110
1115
|
</tbody>
|
|
1111
1116
|
</table>
|
|
1112
1117
|
|
package/android/build.gradle
CHANGED
|
@@ -17,6 +17,7 @@ import android.content.Intent
|
|
|
17
17
|
import android.content.IntentFilter
|
|
18
18
|
import android.os.Build
|
|
19
19
|
import android.os.Handler
|
|
20
|
+
import android.os.HandlerThread
|
|
20
21
|
import android.os.Looper
|
|
21
22
|
import androidx.annotation.RequiresApi
|
|
22
23
|
import com.getcapacitor.Logger
|
|
@@ -71,6 +72,25 @@ class Device(
|
|
|
71
72
|
private var bondStateReceiver: BroadcastReceiver? = null
|
|
72
73
|
private var currentMtu = -1
|
|
73
74
|
|
|
75
|
+
private lateinit var callbacksHandlerThread: HandlerThread
|
|
76
|
+
private lateinit var callbacksHandler: Handler
|
|
77
|
+
|
|
78
|
+
private fun initializeCallbacksHandlerThread() {
|
|
79
|
+
synchronized(this) {
|
|
80
|
+
callbacksHandlerThread = HandlerThread("Callbacks thread")
|
|
81
|
+
callbacksHandlerThread.start()
|
|
82
|
+
callbacksHandler = Handler(callbacksHandlerThread.looper)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private fun cleanupCallbacksHandlerThread() {
|
|
87
|
+
synchronized(this) {
|
|
88
|
+
if (::callbacksHandlerThread.isInitialized) {
|
|
89
|
+
callbacksHandlerThread.quitSafely()
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
74
94
|
private val gattCallback: BluetoothGattCallback = object : BluetoothGattCallback() {
|
|
75
95
|
override fun onConnectionStateChange(
|
|
76
96
|
gatt: BluetoothGatt, status: Int, newState: Int
|
|
@@ -89,6 +109,7 @@ class Device(
|
|
|
89
109
|
bluetoothGatt?.close()
|
|
90
110
|
bluetoothGatt = null
|
|
91
111
|
Logger.debug(TAG, "Disconnected from GATT server.")
|
|
112
|
+
cleanupCallbacksHandlerThread()
|
|
92
113
|
resolve("disconnect", "Disconnected.")
|
|
93
114
|
}
|
|
94
115
|
}
|
|
@@ -288,7 +309,17 @@ class Device(
|
|
|
288
309
|
}
|
|
289
310
|
bluetoothGatt?.close()
|
|
290
311
|
connectionState = STATE_CONNECTING
|
|
291
|
-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.
|
|
312
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
313
|
+
initializeCallbacksHandlerThread()
|
|
314
|
+
bluetoothGatt = device.connectGatt(
|
|
315
|
+
context,
|
|
316
|
+
false,
|
|
317
|
+
gattCallback,
|
|
318
|
+
BluetoothDevice.TRANSPORT_LE,
|
|
319
|
+
BluetoothDevice.PHY_OPTION_NO_PREFERRED,
|
|
320
|
+
callbacksHandler
|
|
321
|
+
)
|
|
322
|
+
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
|
292
323
|
bluetoothGatt = device.connectGatt(
|
|
293
324
|
context, false, gattCallback, BluetoothDevice.TRANSPORT_LE
|
|
294
325
|
)
|
|
@@ -680,6 +711,7 @@ class Device(
|
|
|
680
711
|
connectionState = STATE_DISCONNECTED
|
|
681
712
|
gatt?.disconnect()
|
|
682
713
|
gatt?.close()
|
|
714
|
+
cleanupCallbacksHandlerThread()
|
|
683
715
|
reject(key, message)
|
|
684
716
|
}, timeout)
|
|
685
717
|
}
|