Added BLE connection toggle to RNode hardware config
This commit is contained in:
parent
a7b581716a
commit
c12a6ce0ec
|
@ -1,6 +1,6 @@
|
||||||
__debug_build__ = False
|
__debug_build__ = False
|
||||||
__disable_shaders__ = False
|
__disable_shaders__ = False
|
||||||
__version__ = "1.0.1"
|
__version__ = "1.1.0"
|
||||||
__variant__ = ""
|
__variant__ = ""
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
@ -722,7 +722,18 @@ class SidebandApp(MDApp):
|
||||||
|
|
||||||
if check_permission(bt_permission_name):
|
if check_permission(bt_permission_name):
|
||||||
RNS.log("Have bluetooth connect permissions", RNS.LOG_DEBUG)
|
RNS.log("Have bluetooth connect permissions", RNS.LOG_DEBUG)
|
||||||
self.sideband.setpersistent("permissions.bluetooth", True)
|
|
||||||
|
if android_api_version > 30:
|
||||||
|
if check_permission("android.permission.BLUETOOTH_SCAN"):
|
||||||
|
RNS.log("Have bluetooth scan permissions", RNS.LOG_DEBUG)
|
||||||
|
self.sideband.setpersistent("permissions.bluetooth", True)
|
||||||
|
|
||||||
|
else:
|
||||||
|
RNS.log("Do not have bluetooth scan permissions")
|
||||||
|
self.sideband.setpersistent("permissions.bluetooth", False)
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.sideband.setpersistent("permissions.bluetooth", True)
|
||||||
else:
|
else:
|
||||||
RNS.log("Do not have bluetooth connect permissions")
|
RNS.log("Do not have bluetooth connect permissions")
|
||||||
self.sideband.setpersistent("permissions.bluetooth", False)
|
self.sideband.setpersistent("permissions.bluetooth", False)
|
||||||
|
@ -813,9 +824,9 @@ class SidebandApp(MDApp):
|
||||||
|
|
||||||
def request_bluetooth_permissions(self):
|
def request_bluetooth_permissions(self):
|
||||||
if RNS.vendor.platformutils.get_platform() == "android":
|
if RNS.vendor.platformutils.get_platform() == "android":
|
||||||
if not check_permission("android.permission.BLUETOOTH_CONNECT"):
|
if not check_permission("android.permission.BLUETOOTH_CONNECT") or not check_permission("android.permission.BLUETOOTH_SCAN"):
|
||||||
RNS.log("Requesting bluetooth permission", RNS.LOG_DEBUG)
|
RNS.log("Requesting Bluetooth permissions", RNS.LOG_DEBUG)
|
||||||
request_permissions(["android.permission.BLUETOOTH_CONNECT"])
|
request_permissions(["android.permission.BLUETOOTH_CONNECT", "android.permission.BLUETOOTH_SCAN"])
|
||||||
|
|
||||||
self.check_bluetooth_permissions()
|
self.check_bluetooth_permissions()
|
||||||
|
|
||||||
|
@ -3710,6 +3721,15 @@ class SidebandApp(MDApp):
|
||||||
|
|
||||||
self.sideband.save_configuration()
|
self.sideband.save_configuration()
|
||||||
|
|
||||||
|
def hardware_rnode_ble_toggle_action(self, sender=None, event=None):
|
||||||
|
if sender.active:
|
||||||
|
self.sideband.config["hw_rnode_ble"] = True
|
||||||
|
self.request_bluetooth_permissions()
|
||||||
|
else:
|
||||||
|
self.sideband.config["hw_rnode_ble"] = False
|
||||||
|
|
||||||
|
self.sideband.save_configuration()
|
||||||
|
|
||||||
def hardware_rnode_framebuffer_toggle_action(self, sender=None, event=None):
|
def hardware_rnode_framebuffer_toggle_action(self, sender=None, event=None):
|
||||||
if sender.active:
|
if sender.active:
|
||||||
self.sideband.config["hw_rnode_enable_framebuffer"] = True
|
self.sideband.config["hw_rnode_enable_framebuffer"] = True
|
||||||
|
@ -3777,6 +3797,7 @@ class SidebandApp(MDApp):
|
||||||
t_atl = ""
|
t_atl = ""
|
||||||
|
|
||||||
self.hardware_rnode_screen.ids.hardware_rnode_bluetooth.active = self.sideband.config["hw_rnode_bluetooth"]
|
self.hardware_rnode_screen.ids.hardware_rnode_bluetooth.active = self.sideband.config["hw_rnode_bluetooth"]
|
||||||
|
self.hardware_rnode_screen.ids.hardware_rnode_ble.active = self.sideband.config["hw_rnode_ble"]
|
||||||
self.hardware_rnode_screen.ids.hardware_rnode_framebuffer.active = self.sideband.config["hw_rnode_enable_framebuffer"]
|
self.hardware_rnode_screen.ids.hardware_rnode_framebuffer.active = self.sideband.config["hw_rnode_enable_framebuffer"]
|
||||||
self.hardware_rnode_screen.ids.hardware_rnode_frequency.text = t_freq
|
self.hardware_rnode_screen.ids.hardware_rnode_frequency.text = t_freq
|
||||||
self.hardware_rnode_screen.ids.hardware_rnode_bandwidth.text = t_bw
|
self.hardware_rnode_screen.ids.hardware_rnode_bandwidth.text = t_bw
|
||||||
|
@ -3806,6 +3827,7 @@ class SidebandApp(MDApp):
|
||||||
self.hardware_rnode_screen.ids.hardware_rnode_atl_short.bind(on_text_validate=save_connectivity)
|
self.hardware_rnode_screen.ids.hardware_rnode_atl_short.bind(on_text_validate=save_connectivity)
|
||||||
self.hardware_rnode_screen.ids.hardware_rnode_atl_long.bind(on_text_validate=save_connectivity)
|
self.hardware_rnode_screen.ids.hardware_rnode_atl_long.bind(on_text_validate=save_connectivity)
|
||||||
self.hardware_rnode_screen.ids.hardware_rnode_bluetooth.bind(active=self.hardware_rnode_bt_toggle_action)
|
self.hardware_rnode_screen.ids.hardware_rnode_bluetooth.bind(active=self.hardware_rnode_bt_toggle_action)
|
||||||
|
self.hardware_rnode_screen.ids.hardware_rnode_ble.bind(active=self.hardware_rnode_ble_toggle_action)
|
||||||
self.hardware_rnode_screen.ids.hardware_rnode_framebuffer.bind(active=self.hardware_rnode_framebuffer_toggle_action)
|
self.hardware_rnode_screen.ids.hardware_rnode_framebuffer.bind(active=self.hardware_rnode_framebuffer_toggle_action)
|
||||||
|
|
||||||
self.hardware_rnode_ready = True
|
self.hardware_rnode_ready = True
|
||||||
|
|
|
@ -1580,8 +1580,9 @@ class SidebandCore():
|
||||||
return response
|
return response
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log(f"An error occurred while executing the service RPC request: {request}", RNS.LOG_ERROR)
|
if not type(e) == ConnectionRefusedError:
|
||||||
RNS.log(f"The contained exception was: {e}", RNS.LOG_ERROR)
|
RNS.log(f"An error occurred while executing the service RPC request: {request}", RNS.LOG_ERROR)
|
||||||
|
RNS.log(f"The contained exception was: {e}", RNS.LOG_ERROR)
|
||||||
|
|
||||||
def getstate(self, prop, allow_cache=False):
|
def getstate(self, prop, allow_cache=False):
|
||||||
with self.state_lock:
|
with self.state_lock:
|
||||||
|
@ -3613,12 +3614,12 @@ class SidebandCore():
|
||||||
RNS.log("Disallowing RNode bluetooth since config is disabled", RNS.LOG_DEBUG)
|
RNS.log("Disallowing RNode bluetooth since config is disabled", RNS.LOG_DEBUG)
|
||||||
rnode_allow_bluetooth = False
|
rnode_allow_bluetooth = False
|
||||||
|
|
||||||
if self.config["hw_rnode_ble"] and self.getpersistent("permissions.ble"):
|
if self.config["hw_rnode_ble"] and self.getpersistent("permissions.bluetooth"):
|
||||||
RNS.log("Allowing RNode BLE", RNS.LOG_DEBUG)
|
RNS.log("Allowing RNode BLE", RNS.LOG_DEBUG)
|
||||||
# rnode_allow_ble = True
|
rnode_allow_ble = True
|
||||||
else:
|
else:
|
||||||
RNS.log("Disallowing RNode BLE due to missing permission", RNS.LOG_DEBUG)
|
RNS.log("Disallowing RNode BLE", RNS.LOG_DEBUG)
|
||||||
# rnode_allow_ble = False
|
rnode_allow_ble = False
|
||||||
|
|
||||||
else:
|
else:
|
||||||
RNS.log("Disallowing RNode bluetooth due to missing permission", RNS.LOG_DEBUG)
|
RNS.log("Disallowing RNode bluetooth due to missing permission", RNS.LOG_DEBUG)
|
||||||
|
|
|
@ -2391,6 +2391,21 @@ MDScreen:
|
||||||
pos_hint: {"center_y": 0.3}
|
pos_hint: {"center_y": 0.3}
|
||||||
active: False
|
active: False
|
||||||
|
|
||||||
|
MDBoxLayout:
|
||||||
|
orientation: "horizontal"
|
||||||
|
size_hint_y: None
|
||||||
|
padding: [0,0,dp(24),dp(0)]
|
||||||
|
height: dp(48)
|
||||||
|
|
||||||
|
MDLabel:
|
||||||
|
text: "Device requires BLE"
|
||||||
|
font_style: "H6"
|
||||||
|
|
||||||
|
MDSwitch:
|
||||||
|
id: hardware_rnode_ble
|
||||||
|
pos_hint: {"center_y": 0.3}
|
||||||
|
active: False
|
||||||
|
|
||||||
MDLabel:
|
MDLabel:
|
||||||
id: hardware_rnode_info
|
id: hardware_rnode_info
|
||||||
markup: True
|
markup: True
|
||||||
|
|
Loading…
Reference in New Issue