From b6376d3b354ef06acc8dc3a43b2b6e1da326b244 Mon Sep 17 00:00:00 2001 From: Dima73 Date: Tue, 16 Sep 2025 18:23:41 +0300 Subject: [PATCH 1/3] [btdevicesmanager] add info text to pair BT remote control -also [bluetoothctl.py] add sanity check: Traceback (most recent call last): File "/usr/lib/enigma2/python/Components/ActionMap.py", line 56, in action File "/usr/lib/enigma2/python/Plugins/Extensions/BTDevicesManager/plugin.py", line 282, in keyYellow self._connect(current[1], current[2]) File "/usr/lib/enigma2/python/Plugins/Extensions/BTDevicesManager/plugin.py", line 259, in _connect iBluetoothctl.trust(mac_address) File "/usr/lib/enigma2/python/Plugins/Extensions/BTDevicesManager/bluetoothctl.py", line 217, in trust res = self.process.expect( File "/usr/lib/python3.9/site-packages/pexpect/spawnbase.py", line 354, in expect return self.expect_list(compiled_pattern_list, File "/usr/lib/python3.9/site-packages/pexpect/spawnbase.py", line 383, in expect_list return exp.expect_loop(timeout) File "/usr/lib/python3.9/site-packages/pexpect/expect.py", line 181, in expect_loop return self.timeout(e) File "/usr/lib/python3.9/site-packages/pexpect/expect.py", line 144, in timeout raise exc pexpect.exceptions.TIMEOUT: Timeout exceeded. --- btdevicesmanager/src/bluetoothctl.py | 48 ++++++++++++++++++---------- btdevicesmanager/src/plugin.py | 22 +++++++++---- 2 files changed, 48 insertions(+), 22 deletions(-) diff --git a/btdevicesmanager/src/bluetoothctl.py b/btdevicesmanager/src/bluetoothctl.py index 6d3da0eb2..504d60b11 100644 --- a/btdevicesmanager/src/bluetoothctl.py +++ b/btdevicesmanager/src/bluetoothctl.py @@ -214,10 +214,14 @@ def trust(self, mac_address): print(e) return False else: - res = self.process.expect( - [".*not available\r\n", "trust succe", EOF] - ) - return res == 1 + try: + res = self.process.expect( + [".*not available\r\n", "trust succe", EOF] + ) + return res == 1 + except Exception as e: + print(e) + return False def remove(self, mac_address): """Remove paired device by mac address, return success of the operation.""" @@ -227,10 +231,14 @@ def remove(self, mac_address): print(e) return False else: - res = self.process.expect( - ["not available", "Device has been removed", EOF] - ) - return res == 1 + try: + res = self.process.expect( + ["not available", "Device has been removed", EOF] + ) + return res == 1 + except Exception as e: + print(e) + return False def connect(self, mac_address): """Try to connect to a device by mac address.""" @@ -240,10 +248,14 @@ def connect(self, mac_address): print(e) return False else: - res = self.process.expect( - ["Failed to connect", "Connection successful", EOF] - ) - return res == 1 + try: + res = self.process.expect( + ["Failed to connect", "Connection successful", EOF] + ) + return res == 1 + except Exception as e: + print(e) + return False def disconnect(self, mac_address): """Try to disconnect to a device by mac address.""" @@ -253,10 +265,14 @@ def disconnect(self, mac_address): print(e) return False else: - res = self.process.expect( - ["Failed to disconnect", "Successful disconnected", EOF] - ) - return res == 1 + try: + res = self.process.expect( + ["Failed to disconnect", "Successful disconnected", EOF] + ) + return res == 1 + except Exception as e: + print(e) + return False def agent_noinputnooutput(self): """Start agent""" diff --git a/btdevicesmanager/src/plugin.py b/btdevicesmanager/src/plugin.py index b60827c01..b31d0a13b 100644 --- a/btdevicesmanager/src/plugin.py +++ b/btdevicesmanager/src/plugin.py @@ -30,6 +30,7 @@ from Components.ActionMap import ActionMap from Components.config import config, ConfigText, ConfigSubsection, ConfigYesNo from Components.MenuList import MenuList +from Components.SystemInfo import BoxInfo from Components.ServiceEventTracker import ServiceEventTracker from Plugins.Plugin import PluginDescriptor from Screens.Screen import Screen @@ -57,12 +58,13 @@ class BluetoothDevicesManager(Screen): + - + """ @@ -84,9 +86,9 @@ def __init__(self, session): self["key_red"] = StaticText(_("Exit")) self["key_green"] = StaticText(_("Scan")) - self["key_yellow"] = StaticText(_("Connect")) + self["key_yellow"] = StaticText("") self["key_blue"] = StaticText("") - self["ConnStatus"] = Label(_("Not connected to any device")) + self["ConnStatus"] = Label(_("No connected to any device")) self.devicelist = [] self["devicelist"] = MenuList(self.devicelist) @@ -152,7 +154,14 @@ def readDeviceList(self): if self.devicelist: self["ConnStatus"].setText("") else: - self["ConnStatus"].setText(_("No connected to any device")) + info_text = "" + if BoxInfo.getItem("model") == "gbquad4kpro": + info_text = "\n" +_("Press Menu+OK keys on the BT/IR remote control until the LED starts flashing. The 'GIGABLUE-BT20' remote will appear during the scan.") + elif BoxInfo.getItem("model") == "gbtrio4kpro": + info_text = "\n" +_("Press Info+OK keys on the BT/IR remote control until the LED starts flashing.") + elif BoxInfo.getItem("model") == "sf8008": + info_text = "\n" +_("Hold down the OK button on the BT remote control (bluetooth RCU06) until the LED flashes. The 'DEFINE' remote will appear during the scan.") + self["ConnStatus"].setText(_("No connected to any device") + info_text) self["devicelist"].setList(self.devicelist) self.selectionChanged() @@ -335,8 +344,9 @@ def poll(self): def flush(self): try: - pid = open("/var/run/aplay.pid").read().split()[0] - kill(int(pid), SIGUSR2) + if isfile("/var/run/aplay.pid"): + pid = open("/var/run/aplay.pid").read().split()[0] + kill(int(pid), SIGUSR2) except Exception: pass self.timestamp = datetime.now() From f274728590daeadb9cf020afe93eae54cc628e83 Mon Sep 17 00:00:00 2001 From: Dimitrij Date: Wed, 17 Sep 2025 07:00:56 +0300 Subject: [PATCH 2/3] [edit] "Not connected to any device" is the correct spelling --- btdevicesmanager/src/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/btdevicesmanager/src/plugin.py b/btdevicesmanager/src/plugin.py index b31d0a13b..b615208b9 100644 --- a/btdevicesmanager/src/plugin.py +++ b/btdevicesmanager/src/plugin.py @@ -88,7 +88,7 @@ def __init__(self, session): self["key_green"] = StaticText(_("Scan")) self["key_yellow"] = StaticText("") self["key_blue"] = StaticText("") - self["ConnStatus"] = Label(_("No connected to any device")) + self["ConnStatus"] = Label(_("Not connected to any device")) self.devicelist = [] self["devicelist"] = MenuList(self.devicelist) @@ -161,7 +161,7 @@ def readDeviceList(self): info_text = "\n" +_("Press Info+OK keys on the BT/IR remote control until the LED starts flashing.") elif BoxInfo.getItem("model") == "sf8008": info_text = "\n" +_("Hold down the OK button on the BT remote control (bluetooth RCU06) until the LED flashes. The 'DEFINE' remote will appear during the scan.") - self["ConnStatus"].setText(_("No connected to any device") + info_text) + self["ConnStatus"].setText(_("Not connected to any device") + info_text) self["devicelist"].setList(self.devicelist) self.selectionChanged() From f67d6add7fa308aba32028270100226aaf356eff Mon Sep 17 00:00:00 2001 From: Dimitrij Date: Fri, 3 Oct 2025 10:55:52 +0300 Subject: [PATCH 3/3] Hide info text for sf8008 -First need to add BT support. in octagon BSP. --- btdevicesmanager/src/plugin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/btdevicesmanager/src/plugin.py b/btdevicesmanager/src/plugin.py index b615208b9..c4614f552 100644 --- a/btdevicesmanager/src/plugin.py +++ b/btdevicesmanager/src/plugin.py @@ -159,8 +159,8 @@ def readDeviceList(self): info_text = "\n" +_("Press Menu+OK keys on the BT/IR remote control until the LED starts flashing. The 'GIGABLUE-BT20' remote will appear during the scan.") elif BoxInfo.getItem("model") == "gbtrio4kpro": info_text = "\n" +_("Press Info+OK keys on the BT/IR remote control until the LED starts flashing.") - elif BoxInfo.getItem("model") == "sf8008": - info_text = "\n" +_("Hold down the OK button on the BT remote control (bluetooth RCU06) until the LED flashes. The 'DEFINE' remote will appear during the scan.") + #elif BoxInfo.getItem("model") == "sf8008": + # info_text = "\n" +_("Hold down the OK button on the BT remote control (bluetooth RCU06) until the LED flashes. The 'DEFINE' remote will appear during the scan.") self["ConnStatus"].setText(_("Not connected to any device") + info_text) self["devicelist"].setList(self.devicelist) self.selectionChanged()