Hallo zusammen!
Ich habe mich mit dem Thema beschäftigt und bringe leider keine guten Nachrichten ^^
Seit mehreren Jahren verwendet Gladys die Bibliothek « Noble », eine Bibliothek, die es ermöglicht, Bluetooth von Node.js aus zu nutzen.
Diese Bibliothek wurde schrittweise von den ursprünglichen Maintainern aufgegeben (der letzte Commit ist 6 Jahre alt), aber von einem Kollektiv, « abandonware », übernommen.
Wir verwenden die « abandonware » Version, die immer noch, aber nur leicht von einigen Mitgliedern gepflegt wird.
Wenn man sich die Issues dieser Bibliothek ansieht, stellt man schnell fest, dass die Bibliothek seit einer bestimmten Version des Linux-Kernels nicht mehr funktioniert.
Es gibt viele Beiträge dazu, einige Beispiele:
ouvert 09:13PM - 03 Aug 23 UTC
Hi and _thank you_ for keeping this library active! I'm using Ubuntu 20.04 (and … have now updated to Ubuntu 22.04 as I thought it might help, but it didn't). It's a System76 laptop with Bluetooth integrated.
There are a few quirks I'm dealing with. The first and most unavoidable is that, I can't seem to get past the `await noble.startScanningAsync();` call unless I open the Bluetooth Settings in Ubuntu at which point the call magically completes. I think I did all the stuff that README.md indicates I need to do for Linux/Ubuntu, so I think this is pretty strange. Is there an explanation / workaround for that?
Second unavoidable problem I'm facing is once I _do_ get past that call, the `noble.on('discover', async (peripheral) => {` callback never fires unless I manually disable/enable the Bluetooth in Ubuntu Preferences, sometimes a couple of times (maybe it's a timing issue, I don't know). Is there an explanation / workaround for that?
Happy to share more details with guidance on how to collect those logs / configuration details.
ouvert 11:23AM - 17 Aug 24 UTC
Hi,
Since a week ago, my small noble application cannot work in my Ubunut, wh… ich can scan and connection BLE devices before. But for unknown reason, without any code change in my application, it can no longer work and I found it's because it did not the the "poweredOn" event. But the Bluetooth functionality from the OS point of view is working fine because Ubuntu's bluetooth menu can list and connect to devices as before.
Ubuntu version: 20.04 LTS
Noble version: 1.9.2-25.
What kind problem could it possible be? Where can I find some debug/log information? Thanks.
Kr,
woody
ouvert 03:52PM - 14 Nov 24 UTC
fermé 07:51AM - 23 Dec 24 UTC
Hello,
I recently updated my debian 12 and after the update I'm not able to u… se my usb bluetooth adapter anymore.
Nothing has changed from code or anything else than the update of some packages.
After some tests I found that the noble.state is returning "unknown" and never changes to "poweredOn".
I checked the bluetooth adapter and it seems ok:
```
root@ws-api:~# hciconfig -a
hci0: Type: Primary Bus: USB
BD Address: 00:15:83:EC:CC:A1 ACL MTU: 310:10 SCO MTU: 64:8
UP RUNNING
RX bytes:1416 acl:0 sco:0 events:97 errors:0
TX bytes:4913 acl:0 sco:0 commands:97 errors:0
Features: 0xff 0xff 0x8f 0xfe 0xdb 0xff 0x5b 0x87
Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3
Link policy: RSWITCH HOLD SNIFF PARK
Link mode: PERIPHERAL ACCEPT
Name: 'ws-api'
Class: 0x000000
Service Classes: Unspecified
Device Class: Miscellaneous,
HCI Version: 4.0 (0x6) Revision: 0x22bb
LMP Version: 4.0 (0x6) Subversion: 0x22bb
Manufacturer: Cambridge Silicon Radio (10)
```
The status of bluetooth in systemctl is also ok (not giving any warning/error):
```
root@ws-api:~# systemctl status bluetooth
● bluetooth.service - Bluetooth service
Loaded: loaded (/lib/systemd/system/bluetooth.service; enabled; preset: enabled)
Drop-In: /etc/systemd/system/bluetooth.service.d
└─experimental.conf
Active: active (running) since Thu 2024-11-14 16:43:02 CET; 22s ago
Docs: man:bluetoothd(8)
Main PID: 1872 (bluetoothd)
Status: "Running"
Tasks: 1 (limit: 2308)
Memory: 892.0K
CPU: 21ms
CGroup: /system.slice/bluetooth.service
└─1872 /usr/libexec/bluetooth/bluetoothd --experimental
Nov 14 16:43:02 ws-api systemd[1]: Starting bluetooth.service - Bluetooth service...
Nov 14 16:43:02 ws-api bluetoothd[1872]: Bluetooth daemon 5.66
Nov 14 16:43:02 ws-api systemd[1]: Started bluetooth.service - Bluetooth service.
Nov 14 16:43:02 ws-api bluetoothd[1872]: Starting SDP server
Nov 14 16:43:02 ws-api bluetoothd[1872]: Bluetooth management interface 1.22 initialized
Nov 14 16:43:02 ws-api bluetoothd[1872]: Battery Provider Manager created
Nov 14 16:43:02 ws-api bluetoothd[1872]: Adv Monitor Manager created with supported features:0x00000000, enabled features:0x00000000, max number of supported monitors:32, max number of supported patterns:16
```
I don't see anything weird in the journal neither:
```
root@ws-api:~# journalctl -xe | grep bluetooth
Nov 14 16:44:42 ws-api systemd[1]: Starting bluetooth.service - Bluetooth service...
░░ Subject: A start job for unit bluetooth.service has begun execution
░░ A start job for unit bluetooth.service has begun execution.
Nov 14 16:44:42 ws-api bluetoothd[389]: Bluetooth daemon 5.66
Nov 14 16:44:42 ws-api bluetoothd[389]: Starting SDP server
Nov 14 16:44:42 ws-api systemd[1]: Started bluetooth.service - Bluetooth service.
░░ Subject: A start job for unit bluetooth.service has finished successfully
░░ A start job for unit bluetooth.service has finished successfully.
Nov 14 16:44:42 ws-api systemd[1]: Reached target bluetooth.target - Bluetooth Support.
░░ Subject: A start job for unit bluetooth.target has finished successfully
░░ A start job for unit bluetooth.target has finished successfully.
Nov 14 16:44:42 ws-api bluetoothd[389]: Bluetooth management interface 1.22 initialized
Nov 14 16:44:42 ws-api bluetoothd[389]: Battery Provider Manager created
Nov 14 16:44:42 ws-api dbus-daemon[390]: [system] Activating via systemd: service name='org.freedesktop.hostname1' unit='dbus-org.freedesktop.hostname1.service' requested by ':1.4' (uid=0 pid=389 comm="/usr/libexec/bluetooth/bluetoothd --experimental")
Nov 14 16:44:42 ws-api bluetoothd[389]: Adv Monitor Manager created with supported features:0x00000000, enabled features:0x00000000, max number of supported monitors:32, max number of supported patterns:16
```
And from bluetoothctl I can connect to device using command line so I don't think the problem is coming from the adapter or the operating system configuration.
I'm running out of idea and I'm don't know what I can do next to investigate further. Any idea ?
I also found this opened issue #341 but I'm not sure if it is related to my problem.
Any help would be reallly appreciated.
UPDATE 1:
If I add the DEBUG env variable I can see an error from HCI:
```
hci onSocketError: EINVAL, Invalid argument +1ms
```
I'm now investigating what this error could be.
UPDATE 2:
After some search with the error from UPDATE 1 I found another issue reported in node-bluetooth-hci-socket: https://github.com/abandonware/node-bluetooth-hci-socket/issues/60
It's apparently fixed in another repository but according to another user it's not stable (https://github.com/nathankellenicki/node-poweredup/issues/189)
UPDATE 3:
On my Debian 12 the kernel "6.1.0-26-amd64" seems to be the latest working one. Starting from "6.1.0-27-amd64" it returns an unknown state and never pass to poweredOn.
Downgrading the kernel from "6.1.0-27-amd64" to "6.1.0-26-amd64" solved the problem for me. It's not a solution but at least I can have my bluetooth adapter working until we find a real solution.
UPDATE 4 (with solution):
As mentionned in 'update 2' the problem was coming from node-bluetooth-hci-socket.
A fix has been merged now (https://github.com/abandonware/node-bluetooth-hci-socket/pull/61).
As "node-bluetooth-hci-socket" is an optional dependency of noble, we can simply update that package without having to change anything in noble.
I just tested and it works fine with the latest kernel (6.1.0-28-amd64).
The only thing is that the latest npm version of node-bluetooth-hci-socket does not contains the fix so I had to install the fixed version manually pointing directly to the github repository (`npm i https://github.com/abandonware/node-bluetooth-hci-socket
`)
Um alle zu sehen, geht es hier lang: Issues · abandonware/noble · GitHub
Ich sehe, dass es auch bei anderen Bibliotheken Probleme gab, aufgrund von Kernel-Änderungen in Linux:
ouvert 12:08AM - 06 Jun 24 UTC
fermé 07:33AM - 12 Dec 24 UTC
Hi i'm using Arch linux and after upgrading to 6.9.3 kernel, my script using @ab… andonware/noble stopped working.
After some investigations I managed to easily reproduce the issue by simply running examples/le-scan-test.js
And here's the result:
```
$ sudo node le-scan-test.js
Error: EINVAL, Invalid argument
at setFilter (/tmp/a/node-bluetooth-hci-socket/examples/le-scan-test.js:83:22)
at Object.<anonymous> (/tmp/a/node-bluetooth-hci-socket/examples/le-scan-test.js:124:1)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47 {
errno: 22,
code: 'EINVAL',
syscall: 'setsockopt'
}
```
Exact kernel :
`Linux 6.9.3-arch1-1 #1 SMP PREEMPT_DYNAMIC Fri, 31 May 2024 15:14:45 +0000 x86_64 GNU/Linux`
I unfortunately have no time to try to rollback to older kernels and find where it broke.
Was tun wir?
Der Bug scheint relativ neu zu sein (relativ zur Aktivität des noble-Projekts), ich denke, dass wir zunächst abwarten können, ob abandonware ein Update für die neueren Linux-Versionen veröffentlicht.
Falls diese Bibliothek in den nächsten Monaten tatsächlich aufgegeben wird, müssen wir eine Alternative finden, aber ich habe schnell gesucht und es gibt wirklich keine andere Bibliothek, das ist kompliziert
Wofür braucht ihr Bluetooth?
Für diejenigen, die in diesem Beitrag Bluetooth nutzen wollten, was wolltet ihr damit machen?
Ich kann euch zu alternativen Lösungen beraten!
Ehrlich gesagt, rate ich immer weniger von der Präsenzerkennung per Bluetooth ab.
Früher waren die meisten Bluetooth-Geräte „einfach“: Sie sendeten ständig ihre MAC-Adresse, was sie sehr einfach zu erkennen und zu verfolgen machte.
Aber heute integrieren moderne Geräte wie Smartphones oder Smartwatches fortschrittliche Mechanismen, um das Tracking zu vermeiden (aus Datenschutzgründen) und den Akkuverbrauch zu optimieren.
Das Ergebnis: Bluetooth-Scans auf diesen Geräten sind weitgehend ineffektiv geworden.