I am developing a first app with Bluetooth low energy. I'm in control of both ends - the server is running on an Arduino Nano 33 BLE - which has an nRF chipset.
The server is a bit odd - it actually runs one of two sets of code depending on how it is started (largely because I've only got one Nano BLE). So it can be one of two servers (same MAC address), but server A supports one service and its set of characteristics, server B another service with its characteristics. Both services obviously have unique UUIDs.
The problem is, when the app has been connected to - say - A, and the server is turned off and back on again in guise B, on connection and discovering services, the app still 'discovers' the A service UUID, and not B.
Repeatedly power cycling the server makes no difference, nor does disabling and re-enabling Bluetooth on the Android device, or restarting the app. The only thing that works is a complete reboot of the Android device.
Seems to me the BLE stack is caching what it thinks the capabilities of a specific server MAC address are.
Cannot find a way round this (don't think I can change the Nano BLE MAC address), BUT when I run the nRF diagnostic Android app, it does find the right service, so it must be possible. What that does though is always go through a BLE scan process first so maybe that flushes any cache.
However, I really do not want to enforce a scan, and therefore would be grateful for any comments, or details on how to clear any cache.