Ija*_*d N 3 android bluetooth android-bluetooth android-ble bluetooth-gatt
我有一个Android应用程序连接到BLE设备并写入它.我可以成功连接,读取和写入它.作为测试的一部分,我们正在尝试不同的断开连接.
有时,如果ble设备断开连接,我将连接更改为断开连接,状态值为19.此外,如果存在任何绑定错误,则状态等于22.如果我以编程方式断开连接,则此状态为0.但没有除了0之外的这些状态在android文档中指定.
发布示例BluetoothGattCallback
private BluetoothGattCallback bluetoothGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
Log.i(TAG, "onConnectionStateChange status: "+status+", newState: "+newState);
/*i need to know the posiible values for this status variable*/
if(newState == BluetoothProfile.STATE_CONNECTED) {
gatt.discoverServices();
} else {
gatt.close();
}
}
@Override
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
Log.i(TAG, "onServicesDiscovered service discovered");
}
};
Run Code Online (Sandbox Code Playgroud)
有没有人遇到同样的问题,并整理出状态列表.我需要知道onConnectionStateChange方法中状态变量的可能值
Ija*_*d N 15
这是我的代码列表
我已经在5.0.2,5.1,6.0和6.0.1中测试了断开连接方案.但只在6.0.1安卓版中发现了这个债券发行代码.