Added RNode airtime controls

This commit is contained in:
Mark Qvist 2023-09-13 21:14:30 +02:00
parent 306228fb3f
commit 579c30e558
4 changed files with 119 additions and 11 deletions

View File

@ -10,7 +10,7 @@ source.exclude_patterns = app_storage/*,venv/*,Makefile,./Makefil*,requirements,
version.regex = __version__ = ['"](.*)['"]
version.filename = %(source.dir)s/main.py
android.numeric_version = 20230815
android.numeric_version = 20230912
# Cryptography recipe is currently broken, using RNS-internal crypto for now
requirements = kivy==2.2.1,libbz2,pillow,qrcode==7.3.1,usb4a,usbserial4a

View File

@ -1,6 +1,6 @@
__debug_build__ = False
__disable_shaders__ = False
__version__ = "0.5.4"
__version__ = "0.5.5"
__variant__ = "beta"
import sys
@ -1745,11 +1745,40 @@ class SidebandApp(MDApp):
self.sideband.setstate("app.displaying", self.root.ids.screen_manager.current)
def hardware_rnode_save(self):
try:
self.sideband.config["hw_rnode_frequency"] = int(float(self.root.ids.hardware_rnode_frequency.text)*1000000)
except:
pass
try:
self.sideband.config["hw_rnode_bandwidth"] = int(float(self.root.ids.hardware_rnode_bandwidth.text)*1000)
except:
pass
try:
self.sideband.config["hw_rnode_tx_power"] = int(self.root.ids.hardware_rnode_txpower.text)
except:
pass
try:
self.sideband.config["hw_rnode_spreading_factor"] = int(self.root.ids.hardware_rnode_spreadingfactor.text)
except:
pass
try:
self.sideband.config["hw_rnode_coding_rate"] = int(self.root.ids.hardware_rnode_codingrate.text)
except:
pass
try:
self.sideband.config["hw_rnode_atl_short"] = float(self.root.ids.hardware_rnode_atl_short.text)
except:
self.sideband.config["hw_rnode_atl_short"] = None
try:
self.sideband.config["hw_rnode_atl_long"] = float(self.root.ids.hardware_rnode_atl_long.text)
except:
self.sideband.config["hw_rnode_atl_long"] = None
if self.root.ids.hardware_rnode_beaconinterval.text == "":
self.sideband.config["hw_rnode_beaconinterval"] = None
@ -1820,6 +1849,15 @@ class SidebandApp(MDApp):
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
else:
self.sideband.config["hw_rnode_enable_framebuffer"] = False
self.sideband.save_configuration()
def hardware_rnode_init(self, sender=None):
if not self.hardware_rnode_ready:
self.root.ids.hardware_rnode_scrollview.effect_cls = ScrollEffect
@ -1864,8 +1902,17 @@ class SidebandApp(MDApp):
t_btd = str(self.sideband.config["hw_rnode_bt_device"])
else:
t_btd = ""
if self.sideband.config["hw_rnode_atl_short"] != None:
t_ats = str(self.sideband.config["hw_rnode_atl_short"])
else:
t_ats = ""
if self.sideband.config["hw_rnode_atl_long"] != None:
t_atl = str(self.sideband.config["hw_rnode_atl_long"])
else:
t_atl = ""
self.root.ids.hardware_rnode_bluetooth.active = self.sideband.config["hw_rnode_bluetooth"]
self.root.ids.hardware_rnode_framebuffer.active = self.sideband.config["hw_rnode_enable_framebuffer"]
self.root.ids.hardware_rnode_frequency.text = t_freq
self.root.ids.hardware_rnode_bandwidth.text = t_bw
self.root.ids.hardware_rnode_txpower.text = t_p
@ -1874,6 +1921,8 @@ class SidebandApp(MDApp):
self.root.ids.hardware_rnode_beaconinterval.text = t_bi
self.root.ids.hardware_rnode_beacondata.text = t_bd
self.root.ids.hardware_rnode_bt_device.text = t_btd
self.root.ids.hardware_rnode_atl_short.text = t_ats
self.root.ids.hardware_rnode_atl_long.text = t_atl
self.root.ids.hardware_rnode_frequency.bind(focus=focus_save)
self.root.ids.hardware_rnode_bandwidth.bind(focus=focus_save)
self.root.ids.hardware_rnode_txpower.bind(focus=focus_save)
@ -1889,7 +1938,10 @@ class SidebandApp(MDApp):
self.root.ids.hardware_rnode_codingrate.bind(on_text_validate=save_connectivity)
self.root.ids.hardware_rnode_beaconinterval.bind(on_text_validate=save_connectivity)
self.root.ids.hardware_rnode_beacondata.bind(on_text_validate=save_connectivity)
self.root.ids.hardware_rnode_atl_short.bind(on_text_validate=save_connectivity)
self.root.ids.hardware_rnode_atl_long.bind(on_text_validate=save_connectivity)
self.root.ids.hardware_rnode_bluetooth.bind(active=self.hardware_rnode_bt_toggle_action)
self.root.ids.hardware_rnode_framebuffer.bind(active=self.hardware_rnode_framebuffer_toggle_action)
def hardware_rnode_validate(self, sender=None):

View File

@ -380,8 +380,14 @@ class SidebandCore():
self.config["hw_rnode_beacondata"] = None
if not "hw_rnode_bluetooth" in self.config:
self.config["hw_rnode_bluetooth"] = False
if not "hw_rnode_enable_framebuffer" in self.config:
self.config["hw_rnode_enable_framebuffer"] = False
if not "hw_rnode_bt_device" in self.config:
self.config["hw_rnode_bt_device"] = None
if not "hw_rnode_atl_short" in self.config:
self.config["hw_rnode_atl_short"] = None
if not "hw_rnode_atl_long" in self.config:
self.config["hw_rnode_atl_long"] = None
if not "hw_modem_baudrate" in self.config:
self.config["hw_modem_baudrate"] = 115200
@ -1678,6 +1684,16 @@ class SidebandCore():
else:
ifac_netkey = self.config["connect_rnode_ifac_passphrase"]
if self.config["hw_rnode_atl_short"] == "":
atl_short = None
else:
atl_short = self.config["hw_rnode_atl_short"]
if self.config["hw_rnode_atl_long"] == "":
atl_long = None
else:
atl_long = self.config["hw_rnode_atl_long"]
rnodeinterface = RNS.Interfaces.Android.RNodeInterface.RNodeInterface(
RNS.Transport,
"RNodeInterface",
@ -1692,6 +1708,8 @@ class SidebandCore():
id_callsign = self.config["hw_rnode_beacondata"],
allow_bluetooth = rnode_allow_bluetooth,
target_device_name = bt_device_name,
st_alock = atl_short,
lt_alock = atl_long,
)
rnodeinterface.OUT = True
@ -1716,11 +1734,15 @@ class SidebandCore():
if len(rnodeinterface.hw_errors) > 0:
self.setpersistent("startup.errors.rnode", rnodeinterface.hw_errors[0])
if self.config["hw_rnode_enable_framebuffer"] == True:
if self.interface_rnode.online:
self.interface_rnode.display_image(sideband_fb_data)
self.interface_rnode.enable_external_framebuffer()
else:
self.interface_rnode.last_imagedata = sideband_fb_data
else:
if self.interface_rnode.online:
self.interface_rnode.disable_external_framebuffer()
except Exception as e:
RNS.log("Error while adding RNode Interface. The contained exception was: "+str(e))

View File

@ -1430,6 +1430,40 @@ MDNavigationLayout:
text: ""
font_size: dp(24)
MDBoxLayout:
orientation: "horizontal"
spacing: "24dp"
size_hint_y: None
height: self.minimum_height
# padding: [dp(0), dp(0), dp(0), dp(35)]
MDTextField:
id: hardware_rnode_atl_short
hint_text: "Airime Limit % (15s)"
text: ""
font_size: dp(24)
MDTextField:
id: hardware_rnode_atl_long
hint_text: "Airime Limit % (1h)"
text: ""
font_size: dp(24)
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None
padding: [0,0,dp(24),dp(0)]
height: dp(48)
MDLabel:
text: "Control RNode Display"
font_style: "H6"
MDSwitch:
id: hardware_rnode_framebuffer
pos_hint: {"center_y": 0.3}
active: False
MDBoxLayout:
orientation: "horizontal"
size_hint_y: None