Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detection glitch? #8

Open
ThePureCC opened this issue Mar 15, 2018 · 7 comments
Open

detection glitch? #8

ThePureCC opened this issue Mar 15, 2018 · 7 comments

Comments

@ThePureCC
Copy link

ThePureCC commented Mar 15, 2018

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?

@ebfio
Copy link

ebfio commented Mar 28, 2018

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

@ewenchou
Copy link
Owner

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

@ThePureCC
Copy link
Author

@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.

@PfefferT
Copy link

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.

@olibo
Copy link

olibo commented Oct 27, 2018

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

@tddeleeuw
Copy link

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!

@l0rddarkf0rce
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants