2017-11-29 18 views
0

다음은 신뢰할 수있는 안정적인 쓰기 기능이며 바이트 배열 byte1은 20 바이트를 초과하는 값입니다.Bluetooth BLE 신뢰할 수있는 쓰기가 예상대로 작동하지 않습니다.

private void beginReliableWriteToGattServer(BluetoothDevice device, UUID serviceUUID,UUID charUUID, byte[] byte1){ 

     if(mGatt != null){ 
      BluetoothGattService service = mGatt.getService(serviceUUID); 
      if(service != null){ 
       BluetoothGattCharacteristic gattCharacteristic = service.getCharacteristic(charUUID); 
       if(gattCharacteristic != null){ 
        Logger.d(TAG, "BeginReliable Write="+mGatt.beginReliableWrite()); 
        gattCharacteristic.setValue(byte1); 
        mGatt.writeCharacteristic(gattCharacteristic); 
        Logger.d(TAG, "ExecuteReliable Write="+mGatt.executeReliableWrite()); 

       } 
      } 
     } 
    } 

Below are write Gatt characteristic logs 
BeginReliable Write=true 
ExecuteReliable Write=false 
D/Bluetooth_GATTCallBack: onCharacteristicWrite 17 

답변

0

먼저 여러 개의 GATT 요청을 동시에 처리 할 수 ​​없습니다. writeCharacteristic과 executeReliableWrite는 모두 피어 장치에 대한 요청이므로 (beginReliableWrite는 요청이 아니고 안드로이드의 BLE 스택에 다음 쓰기가 "쓰기가 안정적"이라는 플래그를 설정 함), 먼저 onCharacteristicWrite가 허용 될 때까지 기다려야합니다 executeReliableWrite를 보냅니다.

이제 오류 코드 17에 대해서는 ATL 오류 코드 불충분 리소스 0x11에 해당한다고 가정합니다. 이를 처리하려면 주변 장치가 오류 코드를 보내는 이유를 확인해야합니다.

Android에는 신뢰할 수있는 쓰기가 실제로 신뢰할 수없는 디자인 버그가 있음을 알아야합니다. 프로토콜은 데이터가 처음에 서버로 전송 된 다음 서버가 클라이언트로 동일한 데이터를 다시 보냅니다. GATT 스펙에 따르면 클라이언트는 수신 된 데이터가 전송 된 데이터와 동일한 지 확인해야하며, 그렇지 않으면 중지해야합니다. 불행히도 그 정보는 안드로이드의 블루투스 스택에서 C와 자바 레이어 사이에 놓이게되므로이를 검증 할 방법이 없습니다.