Skip to content

Commit 885eb48

Browse files
committed
init
1 parent 172c123 commit 885eb48

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

.vscode/launch.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
78
{
89
"name": "meshtastic BLE",
910
"type": "debugpy",
@@ -262,6 +263,14 @@
262263
"justMyCode": true,
263264
"args": ["--nodes", "--show-fields", "AKA,Pubkey,Role,Role,Role,Latitude,Latitude,deviceMetrics.voltage"]
264265
}
266+
{
267+
"name": "meshtastic --export-config",
268+
"type": "debugpy",
269+
"request": "launch",
270+
"module": "meshtastic",
271+
"justMyCode": true,
272+
"args": ["--export-config", "config.json"]
273+
},
265274

266275
]
267276
}

meshtastic/__main__.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,11 +1122,31 @@ def subscribe() -> None:
11221122

11231123
# pub.subscribe(onNode, "meshtastic.node")
11241124

1125+
def ensure_true_defaults(config_dict: dict, true_defaults: set[tuple[str, ...]]) -> None:
1126+
"""Ensure that default=True keys are present in the config_dict and set to True."""
1127+
for path in true_defaults:
1128+
d = config_dict
1129+
for key in path[:-1]:
1130+
if key not in d or not isinstance(d[key], dict):
1131+
d[key] = {}
1132+
d = d[key]
1133+
if path[-1] not in d:
1134+
d[path[-1]] = True
11251135

11261136
def export_config(interface) -> str:
11271137
"""used in --export-config"""
11281138
configObj = {}
11291139

1140+
true_defaults = {
1141+
("bluetooth", "enabled"),
1142+
("lora", "sx126xRxBoostedGain"),
1143+
("lora", "txEnabled"),
1144+
("lora", "usePreset"),
1145+
("position", "positionBroadcastSmartEnabled"),
1146+
("security", "serialEnabled"),
1147+
("mqtt", "encryptionEnabled"),
1148+
}
1149+
11301150
owner = interface.getLongName()
11311151
owner_short = interface.getShortName()
11321152
channel_url = interface.localNode.getURL()
@@ -1185,6 +1205,8 @@ def export_config(interface) -> str:
11851205
else:
11861206
configObj["config"] = config
11871207

1208+
ensure_true_defaults(configObj["config"], true_defaults)
1209+
11881210
module_config = MessageToDict(interface.localNode.moduleConfig)
11891211
if module_config:
11901212
# Convert inner keys to correct snake/camelCase

0 commit comments

Comments
 (0)