fix bl
This commit is contained in:
parent
e963628158
commit
4bed805253
@ -84,7 +84,7 @@ class BluetoothScreen(QWidget):
|
||||
root.addLayout(actions)
|
||||
|
||||
# Подписка на событие успешного сопряжения
|
||||
self._bt_service.pairing_completed.connect(self.refresh_list)
|
||||
self._bt_service.pairing_completed.connect(lambda: self.refresh_list())
|
||||
|
||||
self.refresh_list()
|
||||
QTimer.singleShot(200, self._auto_connect_last)
|
||||
@ -152,7 +152,7 @@ class BluetoothScreen(QWidget):
|
||||
|
||||
def _connect_device(self, mac: str, silent: bool):
|
||||
"""Подключиться к устройству по MAC."""
|
||||
success = self._bt_service.connect(mac)
|
||||
success = self._bt_service.connect_device(mac)
|
||||
if not silent:
|
||||
if not success:
|
||||
self.status.setText(f"Статус: ошибка ({self._bt_service.last_error})")
|
||||
@ -166,7 +166,7 @@ class BluetoothScreen(QWidget):
|
||||
mac = self._selected_mac()
|
||||
if not mac:
|
||||
return
|
||||
success = self._bt_service.disconnect(mac)
|
||||
success = self._bt_service.disconnect_device(mac)
|
||||
if not success:
|
||||
self.status.setText(f"Статус: ошибка ({self._bt_service.last_error})")
|
||||
else:
|
||||
|
||||
@ -66,7 +66,7 @@ class BluetoothService(QObject):
|
||||
info = self.get_device_info(mac)
|
||||
return info.get("Connected", "no") == "yes"
|
||||
|
||||
def connect(self, mac: str) -> bool:
|
||||
def connect_device(self, mac: str) -> bool:
|
||||
"""Подключиться к устройству."""
|
||||
self._last_error = ""
|
||||
self._run_cmd(["bluetoothctl", "trust", mac])
|
||||
@ -75,7 +75,7 @@ class BluetoothService(QObject):
|
||||
self.connected_changed.emit(mac, success)
|
||||
return success
|
||||
|
||||
def disconnect(self, mac: str) -> bool:
|
||||
def disconnect_device(self, mac: str) -> bool:
|
||||
"""Отключить устройство."""
|
||||
self._last_error = ""
|
||||
result = self._run_cmd(["bluetoothctl", "disconnect", mac])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user