简体   繁体   中英

Confused about Characteristic/Descriptor addressing and UUIDs

I've always assumed that for every characteristic/service/descriptor on a BLE peripheral, there was a unique UUID. I figured the UUID not only described what it provided, but also provided a unique handle for it. Basically, I thought the transport layer used that to identify a specific instance between peripheral and central.

But working with Android, I've discovered that to have a notifiable characteristic, not only do you have to use the setCharacteristicNotification API, you have to ask the characteristic for a specific descriptor at a canonized UUID ( 00002902-0000-1000-8000-00805f9b34fb ), and then set the value of that descriptor to allow notification/indication as appropriate.

What I don't understand, is that this implies that for every notifiable characteristic my device has, it has a descriptor associated with it with that specific UUID. If I have 5 notifiable characteristics, I'll have 5 different descriptors, but all with the same UUID. So when the Android device writes one of those descriptors, what address does it use to specify the otherwise similar looking descriptors? Is that all magically managed below the hood?

The UUID just describes what kind of service / characteristic / descriptor it is.

The (G)ATT db is built on a list of tuples (handle, uuid, value) called attributes. The handle is a 16 bit unique identifier used at the transport layer to identify the attribute.

The GATT standard describes a way of grouping values. First you have characteristic declaration, characteristic value and a set of descriptors grouped to one characteristic. Then you have service definition plus multiple characteristics grouped to one service.

You lookup the client characteristic configuration descriptor by uuid, grouped to the Characteristic you are interested in, and write 0x0001 to it. Internally Android's GATT client lookups the handle for it and sends a write request. Your app has no access to the handles; only the high level characteristic objects.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM