07-06-2022, 10:55 AM
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.
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.
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.