Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 32 additions & 16 deletions btdevicesmanager/src/bluetoothctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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."""
Expand All @@ -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."""
Expand All @@ -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"""
Expand Down
20 changes: 15 additions & 5 deletions btdevicesmanager/src/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -57,12 +58,13 @@ class BluetoothDevicesManager(Screen):
<ePixmap pixmap="skin_default/buttons/green.png" position="155,0" size="140,40" alphatest="on" />
<ePixmap pixmap="skin_default/buttons/yellow.png" position="305,0" size="140,40" alphatest="on" />
<ePixmap pixmap="skin_default/buttons/blue.png" position="455,0" size="140,40" alphatest="on" />
<ePixmap pixmap="skin_default/buttons/key_menu.png" position="0,430" size="35,25" alphatest="on" />
<widget source="key_red" render="Label" position="5,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
<widget source="key_green" render="Label" position="155,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1" />
<widget source="key_yellow" render="Label" position="305,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" foregroundColor="#ffffff" transparent="1" />
<widget source="key_blue" render="Label" position="455,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" foregroundColor="#ffffff" transparent="1" />
<widget name="devicelist" position="0,50" size="600,300" foregroundColor="#ffffff" zPosition="10" scrollbarMode="showOnDemand" transparent="1"/>
<widget name="ConnStatus" position="0,330" size="600,150" zPosition="1" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
<widget name="ConnStatus" position="0,330" size="600,120" zPosition="1" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
</screen>
"""

Expand All @@ -84,7 +86,7 @@ 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"))

Expand Down Expand Up @@ -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(_("Not connected to any device") + info_text)
self["devicelist"].setList(self.devicelist)
self.selectionChanged()

Expand Down Expand Up @@ -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()
Expand Down
Loading