Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Blootooth pairing with Philips Smart TV (AndriodTV)
#1
Hello.
If I try to pair my Philips TV with moOde audio, I need to manually add 0x200000 (audio service) to the moode's bluetooth device class at first.
For example:
$ sudo hciconfig hci0 class 2c041c
Otherwise the moode is not detected as an audio device.
Is it possible to make this change to bluetooth device class profile permanently as default?
Thanks in advance.
Petr
Reply
#2
The default class supports audio without any need to change it and this has worked well for most users. I'm not sure why your TV requires a different class.

Code:
pi@rp1:~ $ hciconfig get class
hci0:   Type: Primary  Bus: UART
       BD Address: DC:A6:32:02:85:06  ACL MTU: 1021:8  SCO MTU: 64:1
       Class: 0x0c041c
       Service Classes: Rendering, Capturing
       Device Class: Audio/Video, Portable Audio
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#3
(11-14-2021, 12:13 PM)Tim Curtis Wrote: The default class supports audio without any need to change it and this has worked well for most users. I'm not sure why your TV requires a different class.

What works for most users, doesn't have to work for all users. My TV doesn't require a different class, but an additional service - audio.
Code:
pi@moode:~ $ hciconfig get class
hci0:   Type: Primary  Bus: UART
      BD Address: DC:A6:32:D3:27:B7  ACL MTU: 1021:8  SCO MTU: 64:1
      Class: 0x2c041c
      Service Classes: Rendering, Capturing, Audio
      Device Class: Audio/Video, Portable Audio
Reply
#4
I'll add to the TODO list to update the class. Ether make the new class permanent in /etc/bluetooth/main.conf or a configurable option in Audio Config.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#5
(07-03-2022, 11:10 AM)Tim Curtis Wrote: I'll add to the TODO list to update the class. Ether make the new class permanent in /etc/bluetooth/main.conf or a configurable option in Audio Config.

I believe that /etc/bluetooth/main.conf file has Class = 0x20041C inside now. But the higher word is overridden by something (hciconfig returns class 0x0C041C).
Thank you for your effort.
Petr
Reply
#6
I also noticed that.Very odd.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#7
I did some investigation and was not able to find a way to permanently set the class. It seems that the Class = value in /etc/bluetooth/main.conf is overridden by some process in bluez when it starts.

I also tried setting the class to 0x2c041c using hciconfig during moOde startup and that approach did not work either. The class  reverts to 0x0c041c.


Code:
// Start bluetooth controller and pairing agent
if ($_SESSION['feat_bitmask'] & FEAT_BLUETOOTH) {
    if (isset($_SESSION['btsvc']) && $_SESSION['btsvc'] == 1) {
        $started = ': started';
        startBluetooth();

        if (isset($_SESSION['pairing_agent']) && $_SESSION['pairing_agent'] == 1) {
            sysCmd('/var/www/daemon/blu_agent.py --agent --disable_pair_mode_switch --pair_mode --wait_for_bluez >/dev/null 2>&1 &');
            workerLog('worker: Bluetooth pairing agent (started)');
        }

        /*TEST// Ensure Bluetooth has completed startup then set the Class
        // Either wait for "org.bluez" to appear in dbus or try setting the class then checking to see of it was actually set
        for ($i = 0; $i < 10; $i++) {
            $class = '0x2c041c';
            //$result = sysCmd('dbus-send --system --print-reply --dest=org.freedesktop.DBus  /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep "org.bluez"');
            sysCmd('hciconfig hci0 class ' . $class);
            $result = sysCmd('hciconfig hci0 class | grep "Class: ' . $class . '"');
            if (empty($result)) {
                workerLog('worker: wait (' . ($i + 1) . ') for Bluetooth to complete startup');
                sleep(1);
            } else {
                workerLog('worker: Bluetooth (Class set to ' . $class . ')');
                break;
            }
        }END*/
    } else {
        $started = '';
    }
    workerLog('worker: Bluetooth (available' . $started . ')');
} else {
    workerLog('worker: Bluetooth (n/a)');
}

There are some old posts discussing the issue.
https://forums.raspberrypi.com/viewtopic.php?t=86963

It would be interesting to know what bluez is doing with regard to setting the Class.
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Forum Jump: