mirror of
https://github.com/meshtastic/python.git
synced 2025-12-30 03:17:54 -05:00
init
This commit is contained in:
9
.vscode/launch.json
vendored
9
.vscode/launch.json
vendored
@@ -4,6 +4,7 @@
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"name": "meshtastic BLE",
|
||||
"type": "debugpy",
|
||||
@@ -262,6 +263,14 @@
|
||||
"justMyCode": true,
|
||||
"args": ["--nodes", "--show-fields", "AKA,Pubkey,Role,Role,Role,Latitude,Latitude,deviceMetrics.voltage"]
|
||||
}
|
||||
{
|
||||
"name": "meshtastic --export-config",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"module": "meshtastic",
|
||||
"justMyCode": true,
|
||||
"args": ["--export-config", "config.json"]
|
||||
},
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
@@ -1122,11 +1122,31 @@ def subscribe() -> None:
|
||||
|
||||
# pub.subscribe(onNode, "meshtastic.node")
|
||||
|
||||
def ensure_true_defaults(config_dict: dict, true_defaults: set[tuple[str, ...]]) -> None:
|
||||
"""Ensure that default=True keys are present in the config_dict and set to True."""
|
||||
for path in true_defaults:
|
||||
d = config_dict
|
||||
for key in path[:-1]:
|
||||
if key not in d or not isinstance(d[key], dict):
|
||||
d[key] = {}
|
||||
d = d[key]
|
||||
if path[-1] not in d:
|
||||
d[path[-1]] = True
|
||||
|
||||
def export_config(interface) -> str:
|
||||
"""used in --export-config"""
|
||||
configObj = {}
|
||||
|
||||
true_defaults = {
|
||||
("bluetooth", "enabled"),
|
||||
("lora", "sx126xRxBoostedGain"),
|
||||
("lora", "txEnabled"),
|
||||
("lora", "usePreset"),
|
||||
("position", "positionBroadcastSmartEnabled"),
|
||||
("security", "serialEnabled"),
|
||||
("mqtt", "encryptionEnabled"),
|
||||
}
|
||||
|
||||
owner = interface.getLongName()
|
||||
owner_short = interface.getShortName()
|
||||
channel_url = interface.localNode.getURL()
|
||||
@@ -1185,6 +1205,8 @@ def export_config(interface) -> str:
|
||||
else:
|
||||
configObj["config"] = config
|
||||
|
||||
ensure_true_defaults(configObj["config"], true_defaults)
|
||||
|
||||
module_config = MessageToDict(interface.localNode.moduleConfig)
|
||||
if module_config:
|
||||
# Convert inner keys to correct snake/camelCase
|
||||
|
||||
Reference in New Issue
Block a user