bluetooth-proximity icon indicating copy to clipboard operation
bluetooth-proximity copied to clipboard

detection glitch?

Open ThePureCC opened this issue 6 years ago • 7 comments

I'm running the test_address.py code with 999 cycles to detect my iPhone X.

It all runs fine until I turn off bluetooth on my phone, in which case the RSSI value becomes 0(I've seen other issues where it's supposed to be "None"?).

And even after I turn bluetooth back on, the value still stuck at 0 until I restart the script.

I also tried to turn off my phone and ran the script again, and i got "None", which is normal. But after I turn on my phone, it still repeats itself as "None" without giving the correct value. I'd assume something, like cache, stuck in there without being refreshed or something? Can this be fixed?

ThePureCC avatar Mar 15 '18 10:03 ThePureCC

Interesting, I'm having the same issue as @pureche. Only restarting the script fixes it. Thoughts, @ewenchou?

ebfio avatar Mar 28 '18 22:03 ebfio

I have not run into this case before. But I usually keep my phone's bluetooth always on.

ewenchou avatar Jun 15 '18 18:06 ewenchou

@ewenchou I keep my bluetooth on too, but when you simulate the phone leaving the detectable range, AKA turning it off, and back on again, that's when the script stops working.

ThePureCC avatar Jun 17 '18 12:06 ThePureCC

As far as I have figured out the script does some kind of value caching. The problem with powering off is not the only way the results can be wrong. In my case the rssi is always 0 doesn't matter how far away I am away. After restart then the next first value e.G. none gets cached and so on.

PfefferT avatar Jul 22 '18 00:07 PfefferT

I believe I've found a solution to disable the caching You've to edit the script: The line btrssi = BluetoothRSSI(addr=addr) has to move into the for-loop as first line looks like this after:

for i in range(0, num):
	btrssi = BluetoothRSSI(addr=addr)
        print btrssi.get_rssi()
        time.sleep(1)

The same problem will occur in bluetooth_scanner.py - it doesn't recognize when a device disappears. Here I've edited the script too: The line b = BluetoothRSSI(addr=addr) has to move into the while-loop as first line looks like this after:

while True:
        b = BluetoothRSSI(addr=addr)
        rssi = b.get_rssi()
        
        if debug

olibo avatar Oct 27 '18 08:10 olibo

I believe I've found a solution to disable the caching You've to edit the script: The line btrssi = BluetoothRSSI(addr=addr) has to move into the for-loop as first line looks like this after:

for i in range(0, num):
	btrssi = BluetoothRSSI(addr=addr)
        print btrssi.get_rssi()
        time.sleep(1)

The same problem will occur in bluetooth_scanner.py - it doesn't recognize when a device disappears. Here I've edited the script too: The line b = BluetoothRSSI(addr=addr) has to move into the while-loop as first line looks like this after:

while True:
        b = BluetoothRSSI(addr=addr)
        rssi = b.get_rssi()
        
        if debug

I had the same problem and tried this for bluetooth_scanner.py. The solution does seem to work when there is only one bluetooth address in the list. If I add a second address, it will once trigger the call back function when the script is started for the second address only. Af that, the script runs fine. However, if I add more than 2 bluetooth addresses to the list, the script will crash (the wifi connection to) my Pi and the function will keep being triggered in a loop even though no devices are in range (switched on). (I have a relay hooked up to the Pi and it keeps clicking every one or two seconds).

So "walking" in/out of range or switching on/off bluetooth still is a problem for the script!

tddeleeuw avatar Nov 28 '18 11:11 tddeleeuw

I am having the same problem that tddeleeuw mentions above with more than 1 address the callback function is triggered once for everyone at script start and then works fine. I did not have problems with the script going into a loop or anything with more than 2 addresses.

l0rddarkf0rce avatar Apr 12 '19 04:04 l0rddarkf0rce