refreshGattCache method
Clears the Android GATT cache for the connected device.
Android caches the GATT attribute table between connections. When that cache is stale (for example, after a firmware update changes the device's service layout), discoverServices returns the old layout instead of fresh data from the device. Calling this method before discoverServices discards the stale cache and forces a full re-read from the peripheral.
The recommended sequence when reliable service discovery is required after bonding is:
- Connect to the device.
- Wait for the bond to be established.
- Call
refreshGattCache. - Call
discoverServices.
This is an Android-only operation. On iOS, Core Bluetooth manages caching internally and does not expose a mechanism to clear it, so this call returns without taking any action on that platform.
Throws a GattCacheException if the native call fails on Android.
Implementation
Future<void> refreshGattCache({required String deviceAddress}) {
return _platform.refreshGattCache(deviceAddress: deviceAddress);
}