Improve Apple, Android and Windows (#40)
* Cleanup connection * Reverse search list * Bump version * Fix Android serviceUuids in scanResults * Fix typo * Improve cleanup on apple * Improve Apple reconnection and service discovery * Persist long scan result name on Windows Co-authored-by: navidecklabs <navidecklabs@users.noreply.github.com> * Update changelog --------- Co-authored-by: Rohit Sangwan <rohitsangwan647@gmail.com> Co-authored-by: navidecklabs <navidecklabs@users.noreply.github.com>
This commit is contained in:
@@ -238,7 +238,7 @@ fun BluetoothDevice.removeBond() {
|
||||
try {
|
||||
javaClass.getMethod("removeBond").invoke(this)
|
||||
} catch (e: Exception) {
|
||||
Log.e(TAG, "Removing bond has been failed. ${e.message}")
|
||||
Log.e(TAG, "Removing bond failed. ${e.message}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -665,6 +665,15 @@ class UniversalBlePlugin : UniversalBlePlatformChannel, BluetoothGattCallback(),
|
||||
|
||||
override fun onScanResult(callbackType: Int, result: ScanResult) {
|
||||
// Log.v(TAG, "onScanResult: $result")
|
||||
var serviceUuids: Array<String> = arrayOf<String>()
|
||||
result.device.uuids?.forEach {
|
||||
serviceUuids += it.uuid.toString()
|
||||
}
|
||||
result.scanRecord?.serviceUuids?.forEach {
|
||||
if (!serviceUuids.contains(it.uuid.toString())) {
|
||||
serviceUuids += it.uuid.toString()
|
||||
}
|
||||
}
|
||||
mainThreadHandler?.post {
|
||||
callbackChannel?.onScanResult(
|
||||
UniversalBleScanResult(
|
||||
@@ -673,13 +682,12 @@ class UniversalBlePlugin : UniversalBlePlatformChannel, BluetoothGattCallback(),
|
||||
isPaired = result.device.bondState == BOND_BONDED,
|
||||
manufacturerDataHead = result.manufacturerDataHead,
|
||||
rssi = result.rssi.toLong(),
|
||||
services = result.device.uuids?.map { it.uuid?.toString() ?: "" }
|
||||
?: emptyList()
|
||||
services = serviceUuids.toList()
|
||||
)
|
||||
) {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onBatchScanResults(results: MutableList<ScanResult>?) {
|
||||
Log.v(TAG, "onBatchScanResults: $results")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user