1

我正在寫一個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。

任何想法都非常感謝!

+0

iOS可能會自動提高安全級別(我對任何一種實現的細節都一無所知,但該錯誤有時與在低於所需的安全級別下發出請求有關) –

回答

0

看來這最終是一個設備問題。作爲最後一招,我重新啓動了Galaxy S5,我正在進行測試,所有工作都完美無缺。

應該先嚐試一下,我想!

+0

嗨Joel Spencer,我是在android中面臨同樣的問題,所以你可以發佈一些與此相關的例子 –

相關問題