在尝试阅读
Android API 18中蓝牙低功耗GATT特性的价值时,我遇到了以下困境:检索存储在特性中的值的正确方法是什么?并且堆栈的哪个级别应该发生这种行为?
在进行自己的研究时,我偶然发现我所理解的是两种可能的方法:
> BluetoothGatt.readCharacteristic(BluetoothGattCharacteristic特性)
> BluetoothGattCharacteristic.getValue()
- public void onClick(View v){
- byteValue = mBTValueCharacteristic.getValue();
- if ((byteValue[0] & 0x01) == 1)
- byteValue[0] = 0x00;
- else
- byteValue[0] = 0x01;
- mBTValueCharacteristic.setValue(byteValue);
- mBTGatt.writeCharacteristic(mBTValueCharacteristic);
- }
以上是导致我这个问题的原始代码.在其中,我尝试读取一个特征的值,只需使用按钮切换其状态.