2017-12-04 16 views
-1

블루투스 BLE을 구현했으며 성공적으로 읽기/쓰기 명령을 만들었습니다. 그러나 얼마 전 onCharacteristicRead이 호출되지 않습니다. 무엇이 문제 일 수 있습니까? 때로는 완벽하게 작동하므로 읽기/쓰기 코드가 적절합니다. 이러한 작업을 수행하기 위해 장치를 쌍으로 연결해야합니까? 아니면 그냥 connectGatt 충분하니?BLE onCharacteristicRead 콜백이 호출되지 않습니다.

+1

일부 코드없이 답장하기가 어렵습니다. 특정 특성에 대한 알림을 사용하려면 [setCharacteristicNotification] (https://developer.android.com/reference/android/bluetooth/BluetoothGatt.html#setCharacteristicNotification (android.bluetooth.BluetoothGattCharacteristic, % 20boolean))을 사용 하시겠습니까? – ricc

답변

0

필자는 이해할 수 있듯이 BLE 장치에서 사용 가능한 MLDP 서비스를 찾아야합니다.

mBluetoothGatt.discoverServices(); 

서비스가 발견되면, 우리는 MLDP 서비스를 반복해야합니다. 각 서비스에는 BluetoothGattCharacteristic 목록이 있습니다. 제공된 UUID를 사용하여 우리 고유의 특성을 식별하고 특성을 읽으려고 시도하십시오. 또한 하드웨어 구현을 기반으로 아래 속성을 설정해야합니다.

setCharacteristicNotification 
setCharacteristicIndication 
setWriteType