I have developed an Android app. It scans for all devices. In the scanCallback I call bluetoothDevice.getName() and if it returns “BANANA” or “APPLE” or “MANGO”… you get the drift… I add the device to the bluetoothDeviceAdapter so that it gets displayed in a list of possible devices to connect to. A “BANANA” looks like a banana, an “APPLE” looks like an apple, an so forth.
Using an Xbee3 with factory default Digimesh config, I enable BLE, set bluetooth Identifier ‘BI’ to “BANANA” and configure a password (salt and verifier) corresponding to “BANANA”.
The Xbee3 device appears in the adapter as a banana. Great!
I may open a connection with said banana (stopScan() and xbeeDevice.open()), and configure it to now be a mango, i.e. change its ‘BI’ and password to “MANGO”.
The problem is that the Android device caches device information.
After closing my connection with my newly configured mango, and starting a new scan, results delivered to the scanCallback have cached device information. bluetoothDevice.getName() still returns “BANANA” even though the Xbee3 is now advertising as “MANGO”. The adapter incorrectly displays the device as a banana and if I try to open a connection with it using password “BANANA”, the connection fails because the Xbee3 is really a mango!
After may hours of Google searching, It appears there is no way of clearing or removing a device from an Android’s BLE cache programmatically, from inside the app. Apparently, the only way to do this programmatically, is for the Xbee3 to send a “Service Changed” indication…
The BLE “Service Changed” characteristic (0x2A05) is a specialized, mandatory indication within the Generic Attribute Service (0x1801) that notifies a GATT client (e.g., smartphone) when the server’s attribute table has been modified. It enables clients to flush cached service data and re-discover services, ensuring they do not use outdated handle mappings.
So how do I do that using the Xbee3 API ???