nymea / nymea-networkmanager

This daemon allows to set up the wireless network using a Bluetooth LE connection.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to start NetworkManagerBluetoothServer with newest Intel NUC devices

Naterd opened this issue · comments

Network manager is unable to start its bluetooth server, I am seeing
Bluetooth error occured: QLowEnergyController::AdvertisingError "Error occurred trying to start advertising"

I have confirmed that bluetooth does indeed work on the 2 different NUC devices that I have using other methods. However, when installing the debian package and attempting to get the networkmanager to advertise, I am seeing that error over and over. The bluetooth device never shows up as advertising to my personal device.

Building everything from source and running directly also produces the same error.

Mar 23 16:43:15 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: Starting bluetooth server...
Mar 23 16:43:15 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: -------------------------------------
Mar 23 16:43:15 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: Local device "test" "34:7D:F6:90:52:67"
Mar 23 16:43:15 test nymea-networkmanager[7758]:  W | qt.bluetooth: Using BlueZ kernel ATT interface
Mar 23 16:43:15 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: Create NetworkService.
Mar 23 16:43:15 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: Create WirelessService.
Mar 23 16:43:15 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: WirelessService: Using WirelessNetworkDevice("wlp0s20f3", "34:7D:F6:90:52:63", WirelessNetworkDevice::WirelessModeInfrastructure, 0 [Mb/s], "NetworkDeviceStateDisconnected")
Mar 23 16:43:15 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: Start advertising "BT WLAN setup" "34:7D:F6:90:52:67"
Mar 23 16:43:15 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: Controller state advertising...
Mar 23 16:43:15 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: Set running true
Mar 23 16:43:15 test nymea-networkmanager[7758]:  I | Application: Bluetooth server started
Mar 23 16:43:16 test nymea-networkmanager[7758]:  W | qt.bluetooth.bluez: received advertising error
Mar 23 16:43:16 test nymea-networkmanager[7758]:  W | NetworkManagerBluetoothServer: Bluetooth error occured: QLowEnergyController::AdvertisingError "Error occurred trying to start advertising"
Mar 23 16:43:16 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: Controller state disonnected.
Mar 23 16:43:16 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: Set running false
Mar 23 16:43:16 test nymea-networkmanager[7758]:  I | Application: Bluetooth server stopped
Mar 23 16:43:16 test nymea-networkmanager[7758]:  I | Application: Restart the bluetooth service because of "always" mode.
Mar 23 16:43:18 test nymea-networkmanager[7758]:  W | NymeaService: Could not enable/disable bluetooth hardware resource. D-Bus interface not available.
Mar 23 16:43:18 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: -------------------------------------
Mar 23 16:43:18 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: Starting bluetooth server...
Mar 23 16:43:18 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: -------------------------------------
Mar 23 16:43:18 test nymea-networkmanager[7758]:  I | NetworkManagerBluetoothServer: Local device "test" "34:7D:F6:90:52:67"

I have tested on Ubuntu 18 and 20.04.1 LTS versions, along with NUC model numbers: NUC8BEH, NUC10FNK

Bluetooth logs are showing some command disallowed errors when attempting to advertise.

< HCI Command: LE Read Advertising Channel TX Power (0x08|0x0007) plen 0                                                                                 #715 [hci0] 353.221320
> HCI Event: Command Complete (0x0e) plen 5                                                                                                              #716 [hci0] 353.340028
      LE Read Advertising Channel TX Power (0x08|0x0007) ncmd 1
        Status: Command Disallowed (0x0c)
        TX power: 1 dbm (0x01)
< HCI Command: LE Set Advertise Enable (0x08|0x000a) plen 1                                                                                              #717 [hci0] 353.341877
        Advertising: Disabled (0x00)
> HCI Event: Command Complete (0x0e) plen 4                                                                                                              #718 [hci0] 353.343070
      LE Set Advertise Enable (0x08|0x000a) ncmd 1
        Status: Command Disallowed (0x0c)
< HCI Command: LE Set Advertising Parameters (0x08|0x0006) plen 15                                                                                       #719 [hci0] 353.344132
        Min advertising interval: 100.000 msec (0x00a0)
        Max advertising interval: 100.000 msec (0x00a0)
        Type: Connectable undirected - ADV_IND (0x00)
        Own address type: Public (0x00)
        Direct address type: Public (0x00)
        Direct address: 00:00:00:00:00:00 (OUI 00-00-00)
        Channel map: 37, 38, 39 (0x07)
        Filter policy: Allow Scan Request from Any, Allow Connect Request from Any (0x00)
> HCI Event: Command Complete (0x0e) plen 4                                                                                                              #720 [hci0] 353.345047
      LE Set Advertising Parameters (0x08|0x0006) ncmd 1
        Status: Command Disallowed (0x0c)
@ RAW Open: nymea-networkma (privileged) version 2.22                                                                                                       {0x011f} 356.218829
@ Control Close: 0xffff                                                                                                                                     {0x011f} 356.218902
@ RAW Open: nymea-networkma (privileged) version 2.22                                                                                                {0x011f} [hci0] 356.218924

image (4)

I am not sure if this is some strange hardware bug crash or what additional steps I can take to continue troubleshooting.

I have bashed my head at this for over a month thinking it was somehow a configuration error or a bad device.

Any assistance would be much appreciated.

Hello @Naterd,

this look like a permission issue, since hci returns a 0x0c Disallowed when trying to advertise.

Here a few question:

  1. Are you starting the service as user?

  2. The nymea-networkmanager uses the bluez DBus API to create the bluetooth LE server. Maybe worth to check the /etc/dbus-1/system.d/bluetooth.conf if the org.bluez.LEAdvertisement1 maybe is not allowed.

  3. Is bluez maybe installed as snap and there is an interface connection missing? (snap list | grep bluez) Or maybe does dmesg show some audit logs which could explain the missing permission?

1. Are you starting the service as user?
Service is started via systemd which I believe it defaults to root. I added User=root to the service file to make sure and I am getting the same errors.

The nymea-networkmanager uses the bluez DBus API to create the bluetooth LE server. Maybe worth to check the /etc/dbus-1/system.d/bluetooth.conf if the org.bluez.LEAdvertisement1 maybe is not allowed.

<busconfig>

  <!-- ../system.conf have denied everything, so we just punch some holes -->

  <policy user="root">
    <allow own="org.bluez"/>
    <allow send_destination="org.bluez"/>
    <allow send_interface="org.bluez.Agent1"/>
    <allow send_interface="org.bluez.MediaEndpoint1"/>
    <allow send_interface="org.bluez.MediaPlayer1"/>
    <allow send_interface="org.bluez.Profile1"/>
    <allow send_interface="org.bluez.GattCharacteristic1"/>
    <allow send_interface="org.bluez.GattDescriptor1"/>
    <allow send_interface="org.bluez.LEAdvertisement1"/>
    <allow send_interface="org.freedesktop.DBus.ObjectManager"/>
    <allow send_interface="org.freedesktop.DBus.Properties"/>
    <allow send_interface="org.mpris.MediaPlayer2.Player"/>
  </policy>

  <!-- allow users of bluetooth group to communicate -->
  <policy group="bluetooth">
    <allow send_destination="org.bluez"/>
  </policy>

  <policy context="default">
    <allow send_destination="org.bluez"/>
  </policy>

</busconfig>

3. Is bluez maybe installed as snap and there is an interface connection missing? (snap list | grep bluez) Or maybe does dmesg show some audit logs which could explain the missing permission?

snap list | grep bluez returns nothing so I do not think it is installed as a snap.

I do not see any permissions errors in dmesg, the only thing I can see related to bluetooth is

[    4.311457] Bluetooth: Core ver 2.22
[    4.311471] Bluetooth: HCI device and connection manager initialized
[    4.311474] Bluetooth: HCI socket layer initialized
[    4.311475] Bluetooth: L2CAP socket layer initialized
[    4.311478] Bluetooth: SCO socket layer initialized
[    4.340650] Bluetooth: hci0: Bootloader revision 0.4 build 0 week 30 2018
[    4.341655] Bluetooth: hci0: Device revision is 2
[    4.341656] Bluetooth: hci0: Secure boot is enabled
[    4.341657] Bluetooth: hci0: OTP lock is enabled
[    4.341658] Bluetooth: hci0: API lock is enabled
[    4.341658] Bluetooth: hci0: Debug lock is disabled
[    4.341659] Bluetooth: hci0: Minimum firmware build 1 week 10 2014
[    4.345570] Bluetooth: hci0: Found device firmware: intel/ibt-19-0-4.sfi
[    5.985038] Bluetooth: hci0: Waiting for firmware download to complete
[    5.986625] Bluetooth: hci0: Firmware loaded in 1609734 usecs
[    5.986646] Bluetooth: hci0: Waiting for device to boot
[    6.001640] Bluetooth: hci0: Device booted in 14647 usecs
[    6.001968] Bluetooth: hci0: Found Intel DDC parameters: intel/ibt-19-0-4.ddc
[    6.003635] Bluetooth: hci0: Applying Intel DDC parameters completed
[    6.004640] Bluetooth: hci0: Firmware revision 0.0 build 121 week 36 2020
[  465.501659] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[  465.501660] Bluetooth: BNEP filters: protocol multicast
[  465.501663] Bluetooth: BNEP socket layer initialized
[  465.519266] Bluetooth: RFCOMM TTY layer initialized
[  465.519273] Bluetooth: RFCOMM socket layer initialized
[  465.519276] Bluetooth: RFCOMM ver 1.11

@t-mon

As you suggest the error points to it not having permissions to advertise but I do not see why it should not have permissions when running as root.

Device info shows it supports LE

Index list with 1 item
hci0:	Primary controller
	addr 34:7D:F6:90:52:67 version 10 manufacturer 2 class 0x1c0104
	supported settings: powered connectable fast-connectable discoverable bondable link-security ssp br/edr le advertising secure-conn debug-keys privacy configuration static-addr
	current settings: powered bondable ssp br/edr le secure-conn
	name test
	short name
hci0:	Configuration options
	supported options: public-address
	missing options:

This ended up being a bug with the bluetooth changes introduced after kernel 4.18 when using the newer Intel NUC devices. More details #here

Unfortunately the only way I got it to work was to install an old version of Ubuntu Server 18.04 with a kernel version <= 4.18

Once I did that, everything worked easily.

Glad you found a solution! Thanks for sharing it 👍