¡Hola a todos!
He investigado sobre el tema y, lamentablemente, no traigo buenas noticias ^^
Desde hace varios años, Gladys utiliza la librería « Noble », una librería que permite usar Bluetooth desde Node.js
Esta librería ha sido progresivamente abandonada por los mantenedores originales (el último commit es de hace 6 años) pero ha sido retomada por un colectivo, « abandonware ».
Nosotros utilizamos la versión « abandonware », que sigue siendo mantenida, pero de manera ligera por algunos miembros.
Al buscar en las issues de esta librería, uno se da cuenta rápidamente de que, desde una cierta versión del Kernel de Linux, la librería ya no funciona.
Hay muchos posts sobre el tema, algunos ejemplos:
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
`)
Para verlos todos, está aquí: Issues · abandonware/noble · GitHub
He visto que ha habido problemas con otras librerías debido a cambios en el Kernel de 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.
¿Qué hacemos?
El error parece relativamente reciente (relativamente a la actividad del proyecto noble), creo que por ahora podemos ver si abandonware publica un parche para las versiones recientes de Linux.
Si esta librería es verdaderamente abandonada en los próximos meses, tendremos que encontrar una alternativa, pero he buscado rápidamente y realmente no hay ninguna otra librería, es complicado
¿Cuál es su uso?
Para aquellos que querían usar Bluetooth en este post, ¿qué querían hacer?
¡Puedo orientarlos hacia soluciones alternativas!
Francamente, la detección de presencia a través de Bluetooth es un método que cada vez más desaconsejo.
Antiguamente, la mayoría de los dispositivos Bluetooth eran « básicos »: difundían constantemente su dirección MAC, lo que los hacía muy fáciles de detectar y seguir.
Pero hoy en día, los dispositivos modernos como los smartphones o los relojes conectados integran mecanismos avanzados para evitar el seguimiento (por preocupación de privacidad) y optimizar el consumo de batería.
Resultado: los escaneos de Bluetooth en estos dispositivos se han vuelto ampliamente ineficaces.