-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Can't successfully connect BLE devices on Linux #12
Comments
@MrShinyAndNew It's very little details to work with. I can try something but I only have duplo ble train that is anything close to this. One thing I can tell you is that I took over noble because I'm using it in production environments at work and it has been super stable for us. We are using it all over the place. What is the BLE hci you are using? Do you have any other BLE dongle you can use and see if its the same? Im making thousands request everyday in CI/CD and I do get connection issues but I would say it's like 1 per 10k |
So I did a little digging and I think it could be related to BLE you have either built in or dongle. I have 2 dongles one is BLE 5.3 and the other one is 4.1. With the 5.3 one I do have some inconsistency but 4.1 is like this: IMG_0033.MOVBy this I mean its connecting every single time. No issues |
I'm using a Dell XPS notebook from 2017. I'm not sure how to determine what kind of bluetooth it has. I didn't mean to imply that the noble library doesn't work at all :) but before the kernel changes, everything worked perfectly on this notebook. I don't mind diving in to debug or otherwise dig in to this problem but I don't know where to look - I'm not really an expert in bluetooth. I can try with a different notebook, but it will take some time to get back to you. |
I've tested on my other notebook with the same results. I realize this bug report doesn't have much actionable detail - if there's any test I can run I'd love to help get to the bottom of this. |
If you can |
Okay, here are 4 tests I ran, listed here in the order I ran them. The first two use the node-poweredup library with an override (I've verified it's pulling in the expected noble version). The second two just use plain noble. The address for the remote is "a4:34:f1:99:d0:07". This one, the Lego remote appeared to connect (solid indicator light) right away, but the test program didn't emit the "discovered" event. This one emitted the "discovered" event but then never connected This one instantly failed with "already connected" This one didn't connect. |
I tried on my other notebook computer, a Lenovo with an intel chipset. The behaviour here is different. I get the poweredOn event but nothing appears to arrive when I active the BLE device. |
Hi, I’ve gone through your logs and have some ideas. Apologies for the delayed response—I’ve been busy with other tasks at work and haven’t been focusing on native HCI as my primary target. I’m currently using HCI over UART converters instead. With Christmas coming up, I’ll finally have some time off and plan to look into the issues posted here. There’s also one more issue on Windows that I promised to address. Stay tuned! |
Quick update as I’m currently looking into this issue. Could you try the following?
This week, I tested a few different BLE dongles I bought on eBay, and I noticed that BLE 5.3 dongles don’t work too well unless the extended option is explicitly set to true. I’m planning to dive deeper into the HCI commands to determine the dongle profile automatically, so this adjustment might eventually be integrated into Please test this setup when you get a chance and let me know how it goes. Thanks! |
Great news! There's a command to read the supported features, which allows me to identify the capabilities of the dongle. If you could test it and let me know whether it helps, that would be fantastic. Your feedback would be invaluable! |
Hi, I tried using the latest release (1.15.2) with and without extended bindings and there's no improvement that I can see. I don't know what you mean with identifying the capabilities of the dongle. noble_1.15.2_extended_params.txt I've attached two logs showing different tests. The noble test uses extended bindings, the pu uses whatever node-poweredup uses. From what I can see, the noble test case doesn't even notice the PU Remote attempt to connect. The poweredup test case does notice it, but can't connect. Both test cases are from the dell notebook. |
I found another issue that I think could be related. Can you add one line to the code after power On event:
|
Looking at your log I'm not sure that you are using my fork and not @abandonware one. On you log when you
|
Hi,
|
Yes sorry another you have to change one thing in package.json change: |
as a last thing can you change: |
noble_peripheral_scan_test_extended-false.txt |
Ok last one did work. It picked up all scans. Lets do final test and it will be good I think to release: |
Last log you sent me shows scanning working correctly |
It scans correctly but still doesn't seem to connect. |
OK one last chance :) Because I think I know the issue now :)
|
This script (if I understood the assignment) didn't do much - it seems to try to connect instantly even before the remote is ready. But anyway I tried starting the remote first and it doesn't seem to help. |
I’ve identified the cause of the issue. While I don’t have a fix yet, it’s related to the type of address these devices are using. There are two types of addresses: public and random. I tested one of my dongles by advertising the same public address type as your LEGO device, and I encountered the same connection issue. I’ll need to dive deeper into the connect HCI command to see if there’s something I might have missed. Rest assured, I’m confident this will get fixed. |
Can you try the latest release and run the following example:
and
Please note that this script was modified and the first argument |
So, there is some improvement! Attached are the tests you requested. The transcript shows that it's pulling in the latest stoprocent noble. The connection can be established, however there are two issues:
|
It seems like you might be misinterpreting the logs. In the second log you posted, the connection was successful and completed quickly. Similarly, in the first log, the connection was also successful, but it took significantly longer. I’ve observed this behavior myself with certain BLE adapters—occasionally, the connection process slows down significantly. However, after unplugging and reconnecting the USB BLE adapter, the process returns to normal speed. From the logs, it’s clear that this issue isn’t related to I’m not sure what causes this issue, but as mentioned, unplugging and reconnecting the BLE adapter seems to resolve it. |
After further investigation, I found (as explained in this article: [Bluetooth Address Privacy in BLE](https://novelbits.io/bluetooth-address-privacy-ble/)) that when establishing a direct connection, you need to specify the address type as either To address this, I’ve updated the That said, based on the logs you provided, the attempt to scan and then connect took about 4 seconds, and everything appears to have worked correctly. The connection was successful, and reading the GATT attributes completed without issues. |
Yes, the timeout I'm referring to is in the asyc 0 log file, on this line: |
2024_12_28_with_noble_1.17.3_asyc_0.txt
|
Okay I did another test and I noticed something odd: If I am testing a single PoweredUp device, the behaviour is thus:
Log attached |
@stoprocent The 40s thing is also mainly happening in the cases I get ... where then this auto-reconnect comes in and such (at least sounds like it ... ) |
@MrShinyAndNew I'm a bit lost tbh. I found a PowerUp Train Remote in my son's Lego and tried it and it worked like a charm. There is one issue in Here is the Video ... https://marek-serafin.s3.amazonaws.com/test.mov |
Sorry, I’ve discovered another issue, specifically with older dongles, which also affects the PoweredUp npm package. The problem is that the stopScan command isn’t sent when establishing a connection, and I believe this might be what you’re encountering. While recording a video on a different dongle, I noticed some odd behavior. After adding a stopScan during the connection process, the issue was resolved. Please test it and let me know. |
Ok, I have no more ideas on how to test it further. I have forked |
With the latest noble I'm still getting a 40s hangup when making the connection the first time. |
I tested the newest noble on my lenovo laptop (it's much newer than the Dell I normally use) - it doesn't seem to connect at all. Logs attached. 2024-12-30-peripheral-scanner-asyc-0-random.txt |
There are couple of things here:.
This one is a bit weird and I think you need to rerun it and post some more logs: In your log it says:
|
The I re-did some tests and found that with the arguments 1 and How do I make node-poweredup use these arguments? 2024_12_31_dell_async-0-public.txt |
In both cases/logs you have connected successfully. You don't need these params in
|
No, it doesn't connect properly. It still has the 40s timeout on the first
connection attempt.
…On Tue, Dec 31, 2024, 14:28 Marek Serafin ***@***.***> wrote:
In both cases/logs you have connected successfully. You don't need these
params in PoweredUp just replace @abandonware/noble to @stoprocent/noble
in PoweredUp and then try it will work. Logs are looking good just give
it a go.
The scanStop time appears to be however long it's been since the start of
the program.
I re-did some tests and found that with the arguments 1 and public it
*appears* to connect to the remote on the first try; with 0 it does not.
How do I make node-poweredup use these arguments?
2024_12_31_dell_async-0-public.txt
<https://github.com/user-attachments/files/18283330/2024_12_31_dell_async-0-public.txt>
2024_12_31_dell_async-1-public.txt
<https://github.com/user-attachments/files/18283331/2024_12_31_dell_async-1-public.txt>
—
Reply to this email directly, view it on GitHub
<#12 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB7S5IALJCKOO7G4JCZ4S4L2ILV7RAVCNFSM6AAAAABQESLY72VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRWGY3TGNZVGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
I think you are not using
|
It's definitely the stoprocent noble, you can see it in some of the older log files where I grepped the version number from the package-lock. The last log file was generated with DEBUG_COLORS=no in order to get timestamps on the log file, but is otherwise the same program. |
For your device this looks like how I'd expect it to be: connecting to the BLE device should take a few ms
on my system the first attempt to |
maybe see also my other issue ... I also have such 40s issues still ... but in the meantime it works afterwards mostly ... so it is "just" delays |
@MrShinyAndNew Can you try one thing please ...
can you add following code
|
Hi, 2025_01_09_dell_async_0_public.txt It seems like whatever is different in mode 1 is doing something right. I'm not sure why mode 1 is creating a connection before I start the remote though. |
I'm trying to connect a Lego Powered Up remote using node-poweredup. I've overridden its dependency to use @stoprocent/noble, but the behaviour is very poor and inconsistent. I think there are still unresolved issues, but I'm not sure how to debug this any further.
The sample program on the noble screen, or the basic sample node-poweredup program both show the same symptoms - they fail to successfully connect to the BLE device 19 times out of 20. Most of the time the program does nothing; sometimes it gives an error "already connected".
I have tried using strace to inspect the system calls and one thing I noticed is that the connect() system call sometimes takes 40s and failes with "Connection refused" - of course my BLE device has given up attempting to connect long before 40s is up.
Example:
connect(24, {sa_family=AF_BLUETOOTH, l2_psm=htobs(0 /* L2CAP_PSM_??? */), l2_bdaddr=07:d0:99:f1:34:a4, l2_cid=htobs(L2CAP_CID_ATT), l2_bdaddr_type=BDADDR_LE_PUBLIC}, 14) = -1 ECONNREFUSED (Connection refused)
The text was updated successfully, but these errors were encountered: