4 Tips to Make Android BLE Actually Work (번역)

Junghyun Park·2021년 6월 14일
0

출처: https://punchthrough.com/android-ble-development-tips/

Tip 1: Target a minimum API level of 21

구글은 Android 5.0(Lollipop, API level 21)이후부터 그 이전의 많은 문제들을 해결
개발자 친화적 APIs인 BluetoothLeScannerScanFilter와 전체적으로 안정적 기능을 제공

Tip 2: Don’t perform BLE operations in rapid-fire succession

이전 작동에 대하여 안드로이드 기기로부터 들었을때 오직 단 하나씩 수행시켜야 함
이것은 특별히 큰 payload가 전송되는 read and write 작동을 위해서나, service discovery 및 새로운 MTU를 요청하는 setup tasks를 연결하는 경우에 필요함

Tip 3: Handle error codes in the BluetoothGattCallback interface

status 인자를 가지는 onCharacteristicWrite(...)와 같은 BlueToothGattCallback methods들을 위해, 항상 status value가 BluetoothGatt.GATT_SUCCESS와 동일한 값을 갖도록 해야함

  • 경험상, 133 error code는 보통 connection request가 peer나 connectGatt(..) call이 대략 30초후에 time out 되어 거부되었을 때 발생함 (remote device가 범위 밖으로 움직였기 때문에)

Tip 4: Don’t rely on usages of private APIs shown in old example code

구글은 Android P(2018년)이래로, private APIs의 사용을 제한하기 시작했음

결론 : 안드로이드는 iOS에게 많이 배워야 함

profile
21c Carpenter

0개의 댓글