abandonware / noble

A Node.js BLE (Bluetooth Low Energy) central module : Community maintained
https://libraries.io/npm/@abandonware%2Fnoble
MIT License
548 stars 161 forks source link

noble not returning correct data #329

Open mteichtahl opened 9 months ago

mteichtahl commented 9 months ago

Hi all

I have found an interesting issue. When I grab the manufacturerData from a peripheral, noble is giving me what appears to be incorrect data. Looking at the three samples, you will see the data from noble and bluetoothcli is different from the data returned from test_exec. I believe the data from test_exec to be correct. However, even if i hard code the key from test_exec into noble, the hearbeat fails to keep the session alive.

my environment is Linux jura 5.15.0-1046-raspi #49-Ubuntu SMP PREEMPT Thu Jan 18 12:45:41 UTC 2024 aarch64 aarch64 aarch64 GNU/Linux on Ubuntu 22.04.4 LTS

any guidance would be greatly appreciated

from noble

{
  localName: 'TT214H BlueFrog',
  txPowerLevel: undefined,
  manufacturerData: <Buffer ab 00 2a 05 08 03 31 3d e5 2e fa 00 46 43 83 42 01 c0 01 b6 28 00 00 00 00 00 00 00 00>,
  serviceData: [],
  serviceUuids: [ '1523', '1623' ],
  solicitationServiceUuids: [],
  serviceSolicitationUuids: []
}

from bluetoothcli

^Croot@jura:/home/amazon/btEngine# bluetoothctl info F8:FB:C3:2A:78:70
Device F8:FB:C3:2A:78:70 (random)
        Name: TT214H BlueFrog
        Alias: TT214H BlueFrog
        Paired: no
        Trusted: no
        Blocked: no
        Connected: no
        LegacyPairing: no
        UUID: Unknown                   (00001523-0000-1000-8000-00805f9b34fb)
        UUID: Unknown                   (00001623-0000-1000-8000-00805f9b34fb)
        ManufacturerData Key: 0x00ab
        ManufacturerData Value:
  2a 05 08 03 31 3d e5 2e fa 00 46 43 83 42 01 c0  *...1=....FC.B..
  01 b6 28 00 00 00 00 00 00 00 00                 ..(........   

From test_exec

[  info  ] [thread 55801]       Loading machines...
[  info  ] [thread 55801]       Loaded 543 machines.
[  info  ] [thread 55801]       Loading JOE from 'machinefiles/EF567_c.xml'...
[  info  ] [thread 55801]       JOE loaded.
[  info  ] [thread 55801]       Found machine 'GIGA X3c (INTB)' Version: 6 with 31 products.
[  info  ] [thread 55801]       Sending stay in BLE mode...
[  info  ] [thread 55801]       Key: 42. <---- - 0x2A
[  info  ] [thread 55801]       Wrote: 77656D
[  info  ] [thread 55801]       Connected.

the relevant code section is below

noble.on('discover', async (peripheral: Peripheral)=> {
      if (peripheral.address === CoffeeMachineUtils.toHexString(self.machineId)) {
        self.machine = peripheral;

        try {
          self.setState(MACHINE_STATE.CONNECTING)
          await peripheral.connectAsync();
          self.setState(MACHINE_STATE.CONNECTED)
          noble.stopScanning();
          console.log(peripheral.advertisement.manufacturerData)
        } catch (e) {
          self.setState(MACHINE_STATE.DISCONNECTED)
          throw e;
        }
      }
    })
rzr commented 9 months ago

Is this reproductible with other devices ?

mteichtahl commented 9 months ago

It is. Yes. Both with other Bluetooth devices and central devices. We tested with both a pi and osx - same results Please note: My working hours may not be your working hours. Please do not feel obligated to reply outside of your normal work schedule!Sent on the go - please excuse mistakes On 23 Feb 2024, at 7:35 am, Philippe Coval @.***> wrote: Is this reproductible with other devices ?

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

rzr commented 9 months ago

Does this relate to other problem observed elsewhere:

https://github.com/abandonware/bleno/issues/23

mteichtahl commented 9 months ago

Thanks for the tip. I’ll work through this and try swapping to raspbian

mteichtahl commented 9 months ago

We have now tried raspbian as well - it seems we are seeing the same behaviour

rzr commented 8 months ago

Do you know if it's a regression ? I would compare to earlier versions ?