我正在写一个android应用程序来与BLE设备进行通信。该应用程序是一个IOS版本一个娱乐然而任何写请求提高onCharacteristicWriteGATT_REQUEST_NOT_SUPPORTED是否有更多信息可用?
内部的GATT_REQUEST_NOT_SUPPORTED响应工作目标C代码,其临危一个GATT_REQUEST_NOT_SUPPORTED
const uint8_t bytes[] = {0x01,0x02,0x00,0x00};
NSData *data = [NSData dataWithBytes:bytes length:sizeof(bytes)];
[_device writeValue:data forCharacteristic:_dataCommsCharacteristic type:CBCharacteristicWriteWithResponse];
等效的Android/Java代码
byte bytes[] = {0x01,0x02,0x00,0x00}; dataCommsCharacteristic.setValue(bytes); boolean writeStatus = mGatt.writeCharacteristic(dataCommsCharacteristic);
然后
@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic
characteristic, int status) {
if (status == BluetoothGatt.GATT_REQUEST_NOT_SUPPORTED){
Log.d(TAG,"Request not supported");
}
}
我在这里丢失了明显的东西吗?!对我来说,上面的2个片段基本上是相同的东西,但设备不识别Android,但确实承认iOS。
任何想法都非常感谢!
iOS可能会自动提高安全级别(我对任何一种实现的细节都一无所知,但该错误有时与在低于所需的安全级别下发出请求有关) –