Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,7 @@

# Handle the int/float/bool arguments
pref = None
fields = set()
for pref in args.set:
found = False
field = splitCompoundName(pref[0].lower())[0]
Expand All @@ -609,11 +610,19 @@
)
found = setPref(config, pref[0], pref[1])
if found:
fields.add(field)
break

if found:
print("Writing modified preferences to device")
node.writeConfig(field)
if len(fields) > 1:
print("Using a configuration transaction")
node.beginSettingsTransaction()

Check warning on line 620 in meshtastic/__main__.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/__main__.py#L619-L620

Added lines #L619 - L620 were not covered by tests
for field in fields:
print(f"Writing {field} configuration to device")
node.writeConfig(field)
if len(fields) > 1:
node.commitSettingsTransaction()

Check warning on line 625 in meshtastic/__main__.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/__main__.py#L625

Added line #L625 was not covered by tests
else:
if mt_config.camel_case:
print(
Expand Down Expand Up @@ -1417,7 +1426,7 @@
"--get",
help=(
"Get a preferences field. Use an invalid field such as '0' to get a list of all fields."
" Can use either snake_case or camelCase format. (ex: 'ls_secs' or 'lsSecs')"
" Can use either snake_case or camelCase format. (ex: 'power.ls_secs' or 'power.lsSecs')"
),
nargs=1,
action="append",
Expand All @@ -1426,7 +1435,11 @@

group.add_argument(
"--set",
help="Set a preferences field. Can use either snake_case or camelCase format. (ex: 'ls_secs' or 'lsSecs')",
help=(
"Set a preferences field. Can use either snake_case or camelCase format."
" (ex: 'power.ls_secs' or 'power.lsSecs'). May be less reliable when"
" setting properties from more than one configuration section."
),
nargs=2,
action="append",
metavar=("FIELD", "VALUE"),
Expand Down
Loading