mirror of
https://github.com/pdxlocations/contact.git
synced 2026-03-28 17:12:35 +01:00
Compare commits
4 Commits
v1.2.1
...
reinitiali
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
088d13c88b | ||
|
|
c83ccea4ef | ||
|
|
d7f0bee54c | ||
|
|
fb60773ae6 |
14
main.py
14
main.py
@@ -52,7 +52,12 @@ def main(stdscr):
|
||||
logging.info("Initializing interface %s", args)
|
||||
with globals.lock:
|
||||
globals.interface = initialize_interface(args)
|
||||
|
||||
if globals.interface.localNode.localConfig.lora.region == 0:
|
||||
confirmation = get_list_input("Your region is UNSET. Set it now?", "Yes", ["Yes", "No"])
|
||||
if confirmation == "Yes":
|
||||
set_region()
|
||||
globals.interface.close()
|
||||
globals.interface = initialize_interface(args)
|
||||
logging.info("Interface initialized")
|
||||
globals.myNodeNum = get_nodeNum()
|
||||
globals.channel_list = get_channels()
|
||||
@@ -61,13 +66,6 @@ def main(stdscr):
|
||||
init_nodedb()
|
||||
load_messages_from_db()
|
||||
logging.info("Starting main UI")
|
||||
|
||||
if globals.interface.localNode.localConfig.lora.region == 0:
|
||||
confirmation = get_list_input("Your region is UNSET. Set it now?", "Yes", ["Yes", "No"])
|
||||
if confirmation == "Yes":
|
||||
set_region()
|
||||
globals.interface.close()
|
||||
globals.interface = initialize_interface(args)
|
||||
|
||||
main_ui(stdscr)
|
||||
except Exception as e:
|
||||
|
||||
17
settings.py
17
settings.py
@@ -352,9 +352,20 @@ def settings_menu(stdscr, interface):
|
||||
def set_region():
|
||||
node = globals.interface.getNode('^local')
|
||||
device_config = node.localConfig
|
||||
regions = [region.name for region in device_config.lora.DESCRIPTOR.fields_by_name["region"].enum_type.values]
|
||||
new_region = get_list_input('Select your region:', 'UNSET', regions)
|
||||
node.localConfig.lora.region = new_region
|
||||
lora_descriptor = device_config.lora.DESCRIPTOR
|
||||
|
||||
# Get the enum mapping of region names to their numerical values
|
||||
region_enum = lora_descriptor.fields_by_name["region"].enum_type
|
||||
region_name_to_number = {v.name: v.number for v in region_enum.values}
|
||||
|
||||
regions = list(region_name_to_number.keys())
|
||||
|
||||
new_region_name = get_list_input('Select your region:', 'UNSET', regions)
|
||||
|
||||
# Convert region name to corresponding enum number
|
||||
new_region_number = region_name_to_number.get(new_region_name, 0) # Default to 0 if not found
|
||||
|
||||
node.localConfig.lora.region = new_region_number
|
||||
node.writeConfig("lora")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user