How to disable bluetooth caching?

I am planning to use Balena and Raspberry Pi for testing bluetooth devices on production line. Rasperry would provide a user interface, which uses dbus and bluez to scan and connect. Problem is that Bluez caches all devices to /var/lib/bluetooth/[adapter]/cache on Host OS and scan returns them all. One option is to constantly delete these cache files, but I hope there is a better way…

I found promising file from BlueZ source called main.conf, which has following settings:

[GATT]
# GATT attribute cache.
# Possible values:
# always: Always cache attributes even for devices not paired, this is
# recommended as it is best for interoperability, with more consistent
# reconnection times and enables proper tracking of notifications for all
# devices.
# yes: Only cache attributes of paired devices.
# no: Never cache attributes
# Default: always
# Cache = always

If I have understood correctly, it should be placed in Host OS path /etc/bluetooth/, but there is only input.conf and network.conf and the file system is read only so there is nothing I can do.

Does anyone know how to disable the cache?

Hello @emalinen

You could create the file on your system by remounting the root filesystem as read/write using mount -o remount,rw / . However, I have seen a comment on the Internet which suggests that the method you are proposing only disables the caching of attributes. It might be worth trying hcitool scan --flush as some people have reported that this does what you require.