-
Notifications
You must be signed in to change notification settings - Fork 38
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
ble-scan switch -t not working #30
Comments
Hi @mzdaniel, I will fix this soon and make a new release. |
use -t, rename address-type to -a ref #30
Fantastic. Thank you for looking into this issue. |
Version 2.2.0 with the fix is released now. You can update to it with |
Thank you again @Jakeler for looking into this issue Unfortunately my systems are still experiencing instability. The timeout is not truly respected by bleak, as it just relays a kryptic dbus message: bleak.exc.BleakDBusError: org.bluez.Error.Failed expecting the higher levels to address lower level issues or even worse, the user doing manual retries before an explicit timeout. Temporarely removing the try block from the latest ble-serial release gives this traceback time ble-scan -d 01:02:03:04:05:06 -t 30 Traceback (most recent call last): real 0m5.314s |
Hmm, I can't reproduce this, it works as expected here: $ ble-scan -d 01:02:03:04:05:06 -t 30
Started deep scan of 01:02:03:04:05:06
ERROR: Device with address 01:02:03:04:05:06 was not found.
[ 0 ] [ 30s091 | 21:15:54 ]
$ ble-scan -d 01:02:03:04:05:06 -t 1
Started deep scan of 01:02:03:04:05:06
ERROR: Device with address 01:02:03:04:05:06 was not found.
[ 0 ] [ 1s088 | 21:20:27 ] I have tested it with two adapters (Intel AC 7260, Realtek RTL8761B) on latest Arch Linux, BlueZ 5.58. |
What I'm saying is if 01:02:03:04:05:06 is a valid peripheral, after
some tries you can get something like:
time ble-scan -d FC:69:47:01:75:D0 -t 30
Started deep scan of FC:69:47:01:75:D0
ERROR: org.bluez.Error.Failed
real 0m11.055s
Placing a breakpoint when the exception originates in bleak uncovers
some more cues about the error: 'Software caused connection abort'
which other people had also raised in bleak
hbldh/bleak#239 and most likely other projects
chrvadala/node-ble#13
If the timeout is shorten, it increases the likelihood of reaching it
and failing with Device not found, which is uninteresting for this bug
report.
Unfortunately, at the moment I don't have more hardware available to
try other software configurations beyond python wheels or what is
available on debian repos.
…On Thu, 27 May 2021 12:27:35 -0700 Jake ***@***.***> wrote:
Hmm, I can't reproduce this, it works as expected for here:
```console
$ ble-scan -d 01:02:03:04:05:06 -t 30
Started deep scan of 01:02:03:04:05:06
ERROR: Device with address 01:02:03:04:05:06 was not found.
[ 0 ]
[ 30s091 | 21:15:54 ]
$ ble-scan -d 01:02:03:04:05:06 -t 1
Started deep scan of 01:02:03:04:05:06
ERROR: Device with address 01:02:03:04:05:06 was not found.
[ 0 ]
[ 1s088 | 21:20:27 ] ```
I have tested it with two adapters (Intel AC 7260, Realtek RTL8761B)
on latest Arch Linux, BlueZ 5.58. Maybe you can experiment with other
hardware/software and find out what causes this? Does it fail with
all timeout values (including the default 5s)?
|
based on deep scan, especially for `org.bluez.Error.Failed` #30
Okay I see, sorry that I misunderstood you. So it has not much to do with the timeout (at least not the scan or advertisement timeout), it is a general connection problem with a valid device address. I made a another test script now: https://github.com/Jakeler/ble-serial/blob/master/tests/test_conn_reliability.py Looking at what happens in Wireshark shows that after this request:
It fails exactly 225 ms later:
So the host receives an advertisment, opens a connection, tries to read remote features and never gets a response. The 225 ms (7.5ms*30) could be the connection interval, but I am not sure about that. Side note, one time I got this unusual error message:
A valid attempt would instead follow up with some data:
(+ many other packets) Can you confirm the correlation between RSSI and connection failures? |
Thank you @Jakeler for this great project. For years I was trying to do something very similar like this following a endless rabbit hole I am hopping to streamline.
Describe the bug
If my understanding is correct the semantics of -t should be a timeout of how much time is allowed for a possible advertisement to be listened and logged. That is not the case on a couple of systems I tried.
Log messages
ble-scan -d 01:02:03:04:05:06 -t 30 --help
usage: ble-scan [-h] [-t SEC] [-d ADDR]
time ble-scan -d 01:02:03:04:05:06 -t 30
Started deep scan of 01:02:03:04:05:06
Traceback (most recent call last):
...
bleak.exc.BleakError: Device with address 01:02:03:04:05:06 was not found.
real 0m10.621s
ble-serial -v -d 01:02:03:04:05:06
08:13:28.674 | DEBUG | main.py: Running: Namespace(verbose=True, device='01:02:03:04:05:06', addr_type='public', adapter='hci0', mtu=20, write_uuid=None, filename=None, binlog=False, port='/tmp/ttyBLE', read_uuid=None)
08:13:28.675 | DEBUG | selector_events.py: Using selector: EpollSelector
08:13:28.675 | INFO | linux_pty.py: Slave created on /tmp/ttyBLE -> /dev/pts/3
08:13:28.676 | INFO | ble_interface.py: Receiver set up
08:13:28.679 | INFO | ble_interface.py: Trying to connect with 01:02:03:04:05:06
08:13:39.020 | ERROR | main.py: Bluetooth connection failed: Device with address 01:02:03:04:05:06 was not found.
08:13:39.020 | WARNING | main.py: Shutdown initiated
08:13:39.020 | INFO | linux_pty.py: Serial reader and symlink removed
08:13:39.020 | INFO | main.py: Shutdown complete.
Setup (please complete the following information):
The text was updated successfully, but these errors were encountered: