|
|
@@ -9,6 +9,7 @@ import android.bluetooth.BluetoothGattCharacteristic
|
|
|
import android.bluetooth.BluetoothGattDescriptor
|
|
|
import android.bluetooth.BluetoothManager
|
|
|
import android.bluetooth.BluetoothProfile
|
|
|
+import android.bluetooth.BluetoothStatusCodes
|
|
|
import android.bluetooth.le.ScanCallback
|
|
|
import android.bluetooth.le.ScanFilter
|
|
|
import android.bluetooth.le.ScanResult
|
|
|
@@ -137,6 +138,7 @@ class BleManager(
|
|
|
|
|
|
override fun onCharacteristicWrite(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic, status: Int) {
|
|
|
super.onCharacteristicWrite(gatt, characteristic, status)
|
|
|
+ if (characteristic.value == null) return
|
|
|
LogUtil.w(TAG, "gattCallback ---> ${characteristic.value.byteArrayToHexString(" ")}")
|
|
|
}
|
|
|
|
|
|
@@ -275,7 +277,7 @@ class BleManager(
|
|
|
|
|
|
// 写入desc
|
|
|
val enable = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
|
- gatt?.writeDescriptor(descriptor, BluetoothGattDescriptor.ENABLE_INDICATION_VALUE)
|
|
|
+ gatt?.writeDescriptor(descriptor, BluetoothGattDescriptor.ENABLE_INDICATION_VALUE) == BluetoothStatusCodes.SUCCESS
|
|
|
} else {
|
|
|
descriptor.value = BluetoothGattDescriptor.ENABLE_INDICATION_VALUE
|
|
|
gatt?.writeDescriptor(descriptor)
|