Android BLE // Using custom service UUID

不想你离开。 提交于 2019-12-05 20:12:38
M to the K

I'm still not sure if it's ok to use custom 16 bits UUIDS so we manage to do something else based on this SO question. startLeScan with 128 bit UUIDs doesn't work on native Android BLE implementation

We scan all the devices and search for our service in the byte[] scanRecord returned by the LeScanCallback.

Apparently not all 16 bit UUIDs are reserved. The mentioned UUIDs and UUIDs in range 0x000E – 0x01FF are reserved. I have used the UUIDs FFF0 - FFFA for my custom profile and it is still working fine.

Take a look at simpleGATTProfile in TI's simple peripheral example.

The 16-bit UUID is a shortcut for a longer UUID. For example, blood-pressure UUID (0x1810) is the same as

UUID.fromString("00001810-0000-1000-8000-00805F9B34FB")

With that, you can do:

val ids = arrayOf(UUID.fromString("00001810-0000-1000-8000-00805F9B34FB"))
startLeScan(ids, myCallback)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!