iOS Apps that access the same BLE peripheral: How

2020-04-22 02:17发布

问题:

I have to following scenario: My app requests and receives data from an BLE peripheral (a glucometer). It it possible that the user has another app (from another developer) installed, that also communicates with the peripheral. I noticed that my app receives characteristic notifications for requests that where initiated by the other app. This causes my app to receive some data twice.

Is there any way to distinguish between responses to my request and responses that are caused by another app? Or how can I handle it?

回答1:

While the stack obviously knows which app a certain (read, write) response belongs to (because there may only be one pending request, and it knows who sent the request), there is no logical or sound reason why it should dispatch a notification to a single app (among those who have enabled notifications).

Note that the GATT specification does not define "multiple gatt clients per link", there is only one client, so the peripheral doesn't even know there might be two apps talking to it. Hence when it sends a notification, it doesn't include a "target app" field.

The feature of multiplexing multiple apps to the same GATT connection is something iOS and Android teams etc. came up with.