Thank you for your donation!


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


Blootooth pairing with Philips Smart TV (AndriodTV)
#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


Messages In This Thread
RE: Blootooth pairing with Philips Smart TV (AndriodTV) - by Tim Curtis - 07-06-2022, 10:55 AM

Forum Jump: