Device cleanup (#592)
- Replaced device_find_\* usage by device_get_\* variants. - Removed deprecated device_find_\* functions. - Improved reliability of Bluetooth scanning, pairing, connection, and HID host lifecycle behavior, including peer auto-connect handling. - Improved Bluetooth/USB status indicators and clarified “Eject failed” alerts with the affected mount path.
This commit is contained in:
committed by
GitHub
parent
3354924359
commit
d1f06cb774
@@ -166,8 +166,18 @@ class StatusbarService final : public Service {
|
||||
|
||||
void updateBluetoothIcon() {
|
||||
auto radio_state = bluetooth::getRadioState();
|
||||
Device* btdev = device_find_first_active_by_type(&BLUETOOTH_TYPE);
|
||||
bool scanning = btdev ? bluetooth_is_scanning(btdev) : false;
|
||||
bool scanning;
|
||||
|
||||
{
|
||||
Device* btdev;
|
||||
if (device_get_first_active_by_type(&BLUETOOTH_TYPE, &btdev) == ERROR_NONE) {
|
||||
scanning = bluetooth_is_scanning(btdev);
|
||||
device_put(btdev);
|
||||
} else {
|
||||
scanning = false;
|
||||
}
|
||||
}
|
||||
|
||||
Device* serial_dev = bluetooth_serial_get_device();
|
||||
Device* midi_dev = bluetooth_midi_get_device();
|
||||
bool connected = (serial_dev && bluetooth_serial_is_connected(serial_dev)) ||
|
||||
@@ -211,11 +221,27 @@ class StatusbarService final : public Service {
|
||||
}
|
||||
}
|
||||
|
||||
void updateUsbIcon() {
|
||||
Device* hid_dev = device_find_first_active_by_type(&USB_HOST_HID_TYPE);
|
||||
Device* midi_dev = device_find_first_active_by_type(&USB_HOST_MIDI_TYPE);
|
||||
static bool isHidOrMidiConnected() {
|
||||
Device* hid_dev = nullptr;
|
||||
device_get_first_active_by_type(&USB_HOST_HID_TYPE, &hid_dev);
|
||||
Device* midi_dev = nullptr;
|
||||
device_get_first_active_by_type(&USB_HOST_MIDI_TYPE, &midi_dev);
|
||||
|
||||
bool connected = (hid_dev && usb_host_hid_is_connected(hid_dev)) ||
|
||||
(midi_dev && usb_midi_is_connected(midi_dev));
|
||||
|
||||
if (hid_dev) {
|
||||
device_put(hid_dev);
|
||||
}
|
||||
if (midi_dev) {
|
||||
device_put(midi_dev);
|
||||
}
|
||||
|
||||
return connected;
|
||||
}
|
||||
|
||||
void updateUsbIcon() {
|
||||
bool connected = isHidOrMidiConnected();
|
||||
if (!connected) {
|
||||
// MSC: scan filesystems for any mounted /usb* path
|
||||
file_system_for_each(&connected, [](struct FileSystem* fs, void* ctx) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user