Salut à tous !
J’ai investigué sur le sujet, et je n’apporte malheureusement pas de bonnes nouvelles ^^
Depuis plusieurs années, Gladys utilise la librairie « Noble », une librairie qui permet d’utiliser le Bluetooth depuis Node.js
Cette librairie a progressivement été abandonnée par les mainteneurs originels (le dernier commit date d’il y a 6 ans) mais a été repris par un collectif, « abandonware ».
Nous utilisons la version « abandonware », qui est toujours maintenue, mais de manière légère par quelques membres.
En cherchant dans les issues de cette librairie, on se rend vite compte que depuis une certaine version du Kernel Linux, la librairie ne fonctionne plus.
Il y a de nombreux posts sur le sujet, quelques exemples :
opened 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.
opened 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
opened 03:52PM - 14 Nov 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.
Pour les voir tous, ça se passe ici : Issues · abandonware/noble · GitHub
Je vois qu’il y a eu des soucis sur d’autres librairies suite à des changements de Kernel sur Linux :
opened 12:08AM - 06 Jun 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.
Qu’est-ce qu’on fait ?
Le bug a l’air relativement récent (relativement à l’activité du projet noble), je pense que pour l’instant on peut voir si abandonware publie un correctif pour les versions récentes de Linux.
Si cette librairie est véritablement abandonné dans les prochains mois, il faudra trouver une alternative, mais j’ai cherché rapidement et il n’y a vraiment aucune autre librairie, c’est compliqué
Quel est votre usage ?
Pour ceux qui voulaient utiliser le Bluetooth dans ce post, que vouliez-vous faire ?
Je peux vous orienter vers des solutions alternatives !
Franchement, la détection de présence via Bluetooth est une méthode que je déconseille de plus en plus.
Autrefois, la majorité des appareils Bluetooth étaient “basiques” : ils diffusaient constamment leur adresse MAC, ce qui les rendait très simples à détecter et à suivre.
Mais aujourd’hui, les appareils modernes comme les smartphones ou les montres connectées intègrent des mécanismes avancés pour éviter le tracking (par souci de confidentialité) et optimiser la consommation de batterie.
Résultat : les scans Bluetooth sur ces dispositifs sont devenus largement inefficaces.