iosadscore-bluetoothidentifiergatt

About how to continue acquiring information of a specific BLE device with CoreBluetooth on iOS


We have confirmed that there are no duplicate questions, but if there are, we apologize for the inconvenience, but please let us know if there is a page that has solved a similar question. I have several questions, so please give me some advice.

First, iOS does not allow you to check the device address like Android. I think it is a well-known fact for all developers that iOS generates a UUID type Peripheral Identifier (ID) from the advertisement data received from a BLE device.

When I contacted Apple's developer support, I was told that iOS does not allow persistent monitoring of specific device information through scanned advertising data. I believe this means that iOS cannot use advertised data to monitor sensor values ​​(blood pressure or temperature) on a particular BLE device.

The reason for this is that iOS is designed so that cached advertisement data cannot permanently identify a specific device. This means that a cache is only unique while it is held in temporary memory, and a new ID is generated each time it leaves the cache.

If so, in order to permanently monitor sensor values ​​of a specific BLE device in an iOS app, is it necessary to read them using GATT communication?

If that's true, I don't know how iOS can recognize a specific device and make a continuous connection.

This is because, as mentioned earlier, advertising data changes and there is no way to recognize a specific device. If you use Android, you can save the device address of the BLE device in the application and connect it whenever you want. (Only if the device address is not a random address.) However, in the case of iOS, it is not possible for the application to obtain the device address, so there is no way to know whether the ID that changes every time is the BLE device you want to monitor.

Therefore, the following questions.

① Is it not possible for iOS to monitor information from a specific device using BLE using only advertisement data?

②If GATT communication is required, is pairing required to connect to a specific device?

Ideally, if possible, I would like to be able to continuously connect to a specific device on iOS without pairing or bonding. The second question is: What kind of design approach is needed to achieve this?

One of the last-ditch measures I came up with is to include the unchanging BLE device-specific data in the advertisement data in ManufacturingData and have it sent from the BLE device. The app continues to monitor data from specific devices by frequently checking for unique data and ID changes. However, the advertisement data already includes a packet that stores the device address, so it seems wrong to have to go to the trouble of utilizing ManufactureData without using it. We apologize for the inconvenience, but please tell us how to perform smooth BLE communication with a specific BLE device on iOS.


Solution

  • First, the normal way to do what you're describing is to connect to the device and subscribe to the GATT characteristic. That's exactly how BLE is designed to work. Bluetooth devices generally use random and changing addresses. This is a significant privacy feature of BLE. It sounds like you're building your own devices and aren't doing that, which is ok, but most of BLE is built around the assumption that the advertising address changes regularly. There is a system called "resolvable addresses" that allows you to determine that a device's random address is actually a device you've paired with before. But this only generally applies once you pair.

    So to your questions:

    Is it not possible for iOS to monitor information from a specific device using BLE using only advertisement data?

    As you noted, it is certainly possible using manufacturer data, and I've built systems that do that. If you like, you can even advertise your private address there. It's not a problem. However, it also requires that you scan using the CBCentralManagerScanOptionAllowDuplicatesKey option, or you'll only ever get one advertisement. This isn't a great design though. It's not great for battery life and it's kind of fighting the system.

    If GATT communication is required, is pairing required to connect to a specific device?

    Yes. But also it doesn't really matter if your device implements Just Works security, which is really common. Just Works is extremely transparent to the user. The resulting peripheralID is pretty stable, though not promised to be completely stable (and I've seen them change). If it's important to know which is which, I generally like to read the serial number via Device Information Service just to be sure.

    The advantage of connecting and using GATT is that you can subscribe to the characteristic to be notified every time it changes. This works even in the background, unlike reading from advertising. It can even automatically re-launch the app if a device comes in range. Subscriptions to characteristics are very power efficient and powerful. If the device supports it, that's how you want to send information around.

    The main reason IMO to use advertising to send information is if you need multiple clients (phones) to all be able to see the data at the same time and your device can't support multiple connections. Then using manufacturer data is a reasonable option. But it's pretty limited and not ideal for battery life.