sebhildebrandt / systeminformation

System Information Library for Node.JS
MIT License
2.75k stars 312 forks source link

Incorrect manufacturer detected for Bluetooth Apple Magic Keyboard #783

Open schontz opened 1 year ago

schontz commented 1 year ago

I have a Bluetooth Magic Keyboard, full size. bluetoothDevices() gives me the following:

[
  {
    device: '0x800020 < HID ACL >',
    name: 'FirstName LastName’s Keyboard',
    manufacturer: 'FirstName',
    macDevice: 'd4:dc:cd:83:d2:XX',
    macHost: '3c:06:30:3f:24:YY',
    batteryPercent: null,
    type: 'Keyboard',
    connected: true
  }
]

When I run system_profiler SPBluetoothDataType -json, I get:

{
  "SPBluetoothDataType" : [
    {
      "controller_properties" : {
        "controller_address" : "3C:06:30:3F:24:YY",
        "controller_chipset" : "BCM_4378",
        "controller_discoverable" : "attrib_off",
        "controller_firmwareVersion" : "20.1.500.3160",
        "controller_productID" : "0x4A01",
        "controller_state" : "attrib_on",
        "controller_supportedServices" : "0x382039 < HFP AVRCP A2DP HID Braille AACP GATT SerialPort >",
        "controller_transport" : "PCIe",
        "controller_vendorID" : "0x004C (Apple)"
      },
      "device_connected" : [
        {
          "FirstName LastName’s Keyboard" : {
            "device_address" : "D4:DC:CD:83:D2:XX",
            "device_batteryLevelMain" : "100%",
            "device_firmwareVersion" : "1.6.0",
            "device_minorType" : "Keyboard",
            "device_productID" : "0x026C",
            "device_rssi" : "-55",
            "device_services" : "0x800020 < HID ACL >",
            "device_vendorID" : "0x004C"
          }
        }
      ]
    }
  ]
}
schontz commented 1 year ago

I am on macOS Ventura 13.2.1. On versions < 5.12, I get no bluetooth devices. On version >= 5.12, I get my name as the manufacturer.

schontz commented 1 year ago

The issue is that if device_manufacturer is missing, it parses the manufacturer from the device_name. Instead, it should be parsing it from device_vendorID, e.g., as listed here.

sebhildebrandt commented 1 year ago

@schontz … will provide a fix for that. Thank you for your investigation.

schontz commented 1 year ago

I have a POC that uses that table. I'll submit a PR, and if it's useful you can merge it.