NRF51 칩을 사용하고 특성에 대한 글쓰기와 관련하여 몇 가지 문제가있는 Android Nexus 5X 앱을 얻으려고합니다. 정말로 도움이되기를 바랍니다.Android 및 Nordic nRF51의 특성 쓰기 오류를 해결하려면 어떻게해야합니까?
응용 프로그램을 통해 nrf에 실시간 시계 (RTC)를 설정하려고합니다.
속성 : 읽기 - 필수, 쓰기 필수, WriteWithoutResponse - 제외됨, 서명 된 쓰기 - 제외됨, 알림 - 제외됨, 표시됨 - 제외됨, 쓰기 가능 보조자 - 제외됨, 제외 가능, 브로드 캐스트 - 제외됨.
보안 : ENC_NO_MITM
기술자 : 다음과 같이 NRF에 연결 한 후 없음
, 내 구현 'onServiceDiscovered은()이다. readCharacteristic을 수행 할 수 있었기 때문에 'conCharacteristicRead()'가 호출되었지만 writeCharacteristic()이 실패했습니다. 어떤 지침을 주셔서 감사합니다. 많은 감사합니다!
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
// Get the characteristic
BluetoothGattCharacteristic loggingRTCCharacteristic = gatt.getService(loggingServiceUUID).getCharacteristic(loggingRTCControlPointCharacteristicUUID);
// Read characteristic (which succeeded, as onReadCharacteristic is invoked)
boolean successFlag = gatt.readCharacteristic(loggingRTCCharacteristic);
// Check for success.
// Set a plausible timestamp.
int year_lsb = 221; int year_msb = 7;
int month = 3;
int dayOfMonth = 4;
int dayOfWeek = 7;
int hour = 9;
int min = 3;
int sec = 15;
byte[] timeStamp = {(byte)year_lsb, (byte)year_msb, (byte)month, (byte)dayOfMonth, (byte)dayOfWeek, (byte)hour, (byte)min, (byte)sec};
logingRTCCharacteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT);
// This returns a failure. The onCharacteristicWrite() function is not invoked either.
successFlag = gatt.writeCharacteristic(loggingRTCCharacteristic); }
안녕하세요, 지적 해 주셔서 고맙습니다. 나는 원래 코드에서 그렇게했지만 위의 예제 조각에서는 그것을 잊어 버렸다. 문제는 쓰기 특성을 수행하기 전에 읽기 콜백을 기다려야한다는 사실이었습니다. 그러나 쓰기 성공 후 오류가 발생했습니다 - onWriteCharacteristic() 콜백 중에 오류 133. 조언을 주시면 감사하겠습니다. 감사. –
Android Ble 스택이 병렬 요청을 처리 할 수 없습니다. 따라서 우리는 스택에 읽기/쓰기 요청을 직렬화해야합니다. 다음 요청을 보내기 전에 몇 초 또는 응답을 기다려야한다는 요청이 일련 번호로 처리되었는지 확인하십시오. 이를 위해 지연이나 대기열을 사용할 수 있습니다. – 7383
예, readcharacteristic()만을 사용하여 시도했지만 효과적이었습니다. 콜백 onWrite/ReadCharacteristic()이 다른 BLE 메서드를 진행하기 전에 발생할 필요가 있다고 말하는 것이 맞습니까? –