如何通过android我可以访问GATT错误电码
而不是这样做:
override fun onConnectionStateChange(gatt: BluetoothGatt?, status: Int, newState: Int) {
super.onConnectionStateChange(gatt, status, newState)
if (status == 133) {
//Do something
}
}我想这样做:
override fun onConnectionStateChange(gatt: BluetoothGatt?, status: Int, newState: Int) {
super.onConnectionStateChange(gatt, status, newState)
if (status == <WhatGoesHere?>.GATT_ERROR) {
//Do something
}
}发布于 2021-05-25 23:33:13
您可以从android.bluetooth.BluetoothGatt获得其中的几个,但并不是很多您想要的有趣的。我建议创建一个只有整数常量的GattStatus类,其中包含链接到的代码,或者至少是您关心的代码。这就是我们最终为我们的项目所做的,而且它在将来很容易重复使用。
https://stackoverflow.com/questions/67493729
复制相似问题