1

I try to connect my Ubuntu 23.10 with an LG C2 TV to then output the sound from LG to Ubuntu; the same works fine with my iPhone which then plays some music through my Ubuntu attached speakers. I use bluetoothctl:

devices Paired
Device 20:28:BC:81:F8:D9 [LG] webOS TV OLED55C22LB
connect 20:28:BC:81:F8:D9
Attempting to connect to 20:28:BC:81:F8:D9
[CHG] Device 20:28:BC:81:F8:D9 Connected: yes
Connection successful
[CHG] Device 20:28:BC:81:F8:D9 ServicesResolved: yes

but then I can't see in the LG's "Bluetooth Device" menu my Ubuntu as a speaker.
What should I do to solve this?

Actually, for iPhone to output audio to Bluetooth, I had first to specify that the Bluetooth connection's target (i.e. computer) is a speaker.

PS: I use pipewire, pipewire-pulse and wireplumber which work fine

info 20:28:BC:81:F8:D9
Device 20:28:BC:81:F8:D9 (public)
        Name: LG TV[[LG] webOS TV OLED55C22LB
        Alias: LG TV[[LG] webOS TV OLED55C22LB
        Class: 0x0008243c (533564)
        Icon: audio-card
        Paired: yes
        Bonded: yes
        Trusted: yes
        Blocked: no
        Connected: yes
        LegacyPairing: no
        UUID: Audio Source              (0000110a-0000-1000-8000-00805f9b34fb)
        UUID: Audio Sink                (0000110b-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control Target (0000110c-0000-1000-8000-00805f9b34fb)
        UUID: A/V Remote Control        (0000110e-0000-1000-8000-00805f9b34fb)
        UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
        UUID: Generic Access Profile    (00001800-0000-1000-8000-00805f9b34fb)
        UUID: Generic Attribute Profile (00001801-0000-1000-8000-00805f9b34fb)
        UUID: LG Electronics            (0000feb9-0000-1000-8000-00805f9b34fb)
        Modalias: bluetooth:v0046p1200d1436
        ManufacturerData Key: 0x00c4 (196)
        ManufacturerData Value:
  02 34 15 13 17 fd 80                             .4.....
Adrian
  • 577

1 Answers1

2

We can set the device class manually:

  1. Paste the following into /etc/systemd/system/bluetooth-class-askubuntu-1504191-1004020.service :

    [Unit]
    Description=Set Bluetooth device class to be a speaker
    After=bluetooth.service
    

    [Service]

    bluetooth.service reports ready before it sets the wrong class, so wait.

    ExecStartPre=/bin/sleep 5 ExecStart=/bin/hciconfig hci0 class 0x240414 Type=oneshot

    [Install] WantedBy=bluetooth.service

  2. sudo systemctl enable --now bluetooth-class-askubuntu-1504191-1004020.service

If we examine the new device class, we will see that it means its Service class is Rendering and Audio, its Major device class is Audio/Video, and its Minor service class is Loudspeaker. I extracted the numbers from my Logitech Bluetooth speaker, so this will your computer pretend to be the same.

The normal setting is 0x7C010C, which means its Service class is Rendering, Capturing, Object Transfer, Audio, and Telephony, its Major device class is Computer, and its Minor service class is Laptop. Your LG TV will skip devices of computer class and only show devices of class speaker:

In practice, most Bluetooth clients scan their surroundings in two successive steps: they first look for all bluetooth devices around them and find out their "class". You can do this on Linux with the hcitool scan command. Then, they use SDP in order to check if a device in a given class offers the type of service that they want.

This means that the hcid.conf "class" parameter needs to be set up properly if particular services are running on the host, such as "PAN", or "OBEX Obect Push", etc: in general a device looking for a service such as "Network Access Point" will only scan for this service on devices containing "Networking" in their major service class.

Setting Class = 0x240414 in /etc/bluetooth/main.conf doesn't work because it doesn't set all the bits. Devices vary in how much they care. Android doesn't care at all, and TVs might need some or all of the bits set properly. When I edited that file, only the major/minor part being 0x0414 got somewhat respected, and this is only after I disabled all the profiles (which also add their own bits to the class) in the bluetooth.service command line parameters. bluetoothd does not support setting the service class 0x24 as its struct mgmt_cp_set_dev_class doesn't include a variable for that.

Daniel T
  • 5,339