I have an application which connects to an external BLE device.
The BLE device has two modes, regular and extended, which has a different set services and characteristics used.
The BLE device application always starts in regular mode with the regular mode services and characteristics loaded. User action can trigger the extended mode which will load more services and additional functionalities.
For this to work the BLE device has implemented the correct services:
- Generic Attribute Profile Service
- Generic Access Profile Service
and uses the 0x2A05 services changed indicator flag to tell iOS that the services has changed. This signal is sent once after the connection is established, and sent after user action that triggers the extended mode so that iOS loads the new services.
The problem is that this works very unreliably for iOS. There are two major problems that is occuring:
1. When operating in extended mode, disconnecting from the peripheral and then connecting again, ios still shows the extended services.
Adding a delay does not seem to alter this behavior and sometimes the delay breaks the bluetooth connection and no writes/reads on any characteristics works. Toggling bluetooth or connecting a second time makes iOS correctly rediscover the services and the regular mode services are shown.
2. The flag seems to work only once for each connection. I created a script that loads and unloads services on the external BLE device and I send the services changed indicator after to see if didmodifyservices callback gets called. I have only managed to get the didmodifyservices callback once for each connection.
Therefore I am wondering if there are known bugs connected to the services changed indicator process or if there is a limitation for how often or many times per connection this will work. There is very little documentation for this feature both from chip manufactures like Texas Instruments or Apple.
The external device is bonded to the iPhone and bluetooth 5 is used.