Added BLE connection toggle to RNode hardware config
This commit is contained in:
parent
a7b581716a
commit
c12a6ce0ec
|
@ -1,6 +1,6 @@
|
|||
__debug_build__ = False
|
||||
__disable_shaders__ = False
|
||||
__version__ = "1.0.1"
|
||||
__version__ = "1.1.0"
|
||||
__variant__ = ""
|
||||
|
||||
import sys
|
||||
|
@ -722,6 +722,17 @@ class SidebandApp(MDApp):
|
|||
|
||||
if check_permission(bt_permission_name):
|
||||
RNS.log("Have bluetooth connect permissions", RNS.LOG_DEBUG)
|
||||
|
||||
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:
|
||||
RNS.log("Do not have bluetooth connect permissions")
|
||||
|
@ -813,9 +824,9 @@ class SidebandApp(MDApp):
|
|||
|
||||
def request_bluetooth_permissions(self):
|
||||
if RNS.vendor.platformutils.get_platform() == "android":
|
||||
if not check_permission("android.permission.BLUETOOTH_CONNECT"):
|
||||
RNS.log("Requesting bluetooth permission", RNS.LOG_DEBUG)
|
||||
request_permissions(["android.permission.BLUETOOTH_CONNECT"])
|
||||
if not check_permission("android.permission.BLUETOOTH_CONNECT") or not check_permission("android.permission.BLUETOOTH_SCAN"):
|
||||
RNS.log("Requesting Bluetooth permissions", RNS.LOG_DEBUG)
|
||||
request_permissions(["android.permission.BLUETOOTH_CONNECT", "android.permission.BLUETOOTH_SCAN"])
|
||||
|
||||
self.check_bluetooth_permissions()
|
||||
|
||||
|
@ -3710,6 +3721,15 @@ class SidebandApp(MDApp):
|
|||
|
||||
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):
|
||||
if sender.active:
|
||||
self.sideband.config["hw_rnode_enable_framebuffer"] = True
|
||||
|
@ -3777,6 +3797,7 @@ class SidebandApp(MDApp):
|
|||
t_atl = ""
|
||||
|
||||
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_frequency.text = t_freq
|
||||
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_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_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_ready = True
|
||||
|
|
|
@ -1580,6 +1580,7 @@ class SidebandCore():
|
|||
return response
|
||||
|
||||
except Exception as e:
|
||||
if not type(e) == ConnectionRefusedError:
|
||||
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)
|
||||
|
||||
|
@ -3613,12 +3614,12 @@ class SidebandCore():
|
|||
RNS.log("Disallowing RNode bluetooth since config is disabled", RNS.LOG_DEBUG)
|
||||
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)
|
||||
# rnode_allow_ble = True
|
||||
rnode_allow_ble = True
|
||||
else:
|
||||
RNS.log("Disallowing RNode BLE due to missing permission", RNS.LOG_DEBUG)
|
||||
# rnode_allow_ble = False
|
||||
RNS.log("Disallowing RNode BLE", RNS.LOG_DEBUG)
|
||||
rnode_allow_ble = False
|
||||
|
||||
else:
|
||||
RNS.log("Disallowing RNode bluetooth due to missing permission", RNS.LOG_DEBUG)
|
||||
|
|
|
@ -2391,6 +2391,21 @@ MDScreen:
|
|||
pos_hint: {"center_y": 0.3}
|
||||
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:
|
||||
id: hardware_rnode_info
|
||||
markup: True
|
||||
|
|
Loading…
Reference in New Issue