Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Clear Android Bluetooth cache
JRoorda last edited by
I'm using the Qt Bluetooh Low Energy API to read a BLE sensor. Since the sensor dynamically updates and adds services, the Android Bluetooth cache needs to be cleared or refreshed in order to read the new added services.
For the people that dont know about this: Android caches bluetooth devices. This means that if the cache data is not refreshed the application will read old data from cache instead of new retrieved information.
The Qt documentation says this about the problem:
"Note: Some platforms internally cache the service list of a device which was discovered in the past. This can be problematic if the remote device changed its list of services or their inclusion tree. If this behavior is a problem, the best workaround is to temporarily turn Bluetooth off. This causes a reset of the cache data. Currently Android exhibits such a cache behavior."
At the moment I'm using the workaround to clear the cache data, but this is a very ugly way to do so. Is there any other way to do this without using the AndroidExtras lib that Qt provides?
If there isn't, I'd like to add a ticket or something, but I dont know how to do that.
Thanks in advance,
Maybe you should just do bluetooth turn off/on programmaticaly from your app, before using of an BLE.