blueZ stack - removed device is found

I have a simple task in using bluetooth technology – reliably identify “nearby bluetooth device” being connected and disconnected. .

This is a fundamental step in using bluetooth technology, well defined, but poorly documented.
I know that bluetooth technology is implemented in Linunx kernel using “ blueZ stack”.
I am using an IDE which lets me (C/C++code) to “scan for nearby (bluetooth) devices” - it also uses “blueZ stack” as library, and the scan works as expected – it identifies remote bluetooth device – no problema.

My next objective is to “remove the remote bluetooth device “ and run the “scan for nearby devices” again - expecting NO such remote bluetooth device to be found.
Not so – executing same “scan for nearby bluetooth devices” FINDS the removed device again.

While analyzing the issue, I found that blueZ “scan for nearby devices “ has a timer - over 1 second for each device scanned and over-all timeout of approximately 30 seconds to “scan completed”.
Modifying my code I can observe both timers.
When the initial , and successful scan is run , these timers are correct and present.
After the device is removed and scan is run again – both timers are practically zero.
My conclusion – the physical scan is no longer performed , and the incorrect data is being retrieved from some unknown source.
I have a limited ability to “trace” the scanning process - my trace practically stops at “blueZ” library call. The “events” are not that easy to trace any further.

I am asking the forum to help me identify the issue – in blueZ source code.
I have been unsuccessful in locating such code in “official blueZ stack “ documentation.
( link deleted - new user cannot post link)

Hi Helen,

Welcome to our forums.

Since the codebase isn’t small, you may get faster answer from the developers themselves in contrast to scanning the source. Did you opened an issue on Github with this strange behavior?