refreshCache

suspend fun refreshCache()

Refreshes the cached GATT database associated with the peripheral and starts new service discovery automatically.

All observers subscribed to invalidated attributes will be cancelled. The flows returned by services will emit an empty list of services following by updated list of services when the new service discovery is complete.

It is safe to call this method when the peripheral is connected, connecting, or disconnecting. It may be called when the device is disconnected but only when the connection was made using AutoConnect option in which case the system is trying to reconnect.

A connection made using Direct option closes automatically immediately after disconnection.

When invoked on a closed connection the method throws PeripheralClosedException.

Throws

If the peripheral is closed.

If cache could not be refreshed.

If BLUETOOTH_CONNECT permission is denied.