mirror of
https://github.com/meshtastic/python.git
synced 2026-01-01 12:27:59 -05:00
allow passing multiple --setpref args in a single run
This commit is contained in:
11
.vscode/launch.json
vendored
11
.vscode/launch.json
vendored
@@ -4,7 +4,6 @@
|
||||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
|
||||
{
|
||||
"name": "meshtastic BLE",
|
||||
"type": "python",
|
||||
@@ -21,6 +20,14 @@
|
||||
"justMyCode": true,
|
||||
"args": ["--debug", "--info"]
|
||||
},
|
||||
{
|
||||
"name": "meshtastic setpref",
|
||||
"type": "python",
|
||||
"request": "launch",
|
||||
"module": "meshtastic",
|
||||
"justMyCode": true,
|
||||
"args": ["--debug", "--setpref", "a", "1", "--setpref", "b", "2"]
|
||||
},
|
||||
{
|
||||
"name": "meshtastic shell",
|
||||
"type": "python",
|
||||
@@ -35,7 +42,7 @@
|
||||
"request": "launch",
|
||||
"module": "meshtastic",
|
||||
"justMyCode": true,
|
||||
"args": [ "--debug", "--test"]
|
||||
"args": ["--debug", "--test"]
|
||||
},
|
||||
{
|
||||
"name": "meshtastic sendtext",
|
||||
|
||||
@@ -36,9 +36,15 @@ def onConnected(interface):
|
||||
wantAck=True, wantResponse=True)
|
||||
|
||||
if args.setpref:
|
||||
name = args.setpref[0]
|
||||
val = int(args.setpref[1])
|
||||
setattr(interface.radioConfig.preferences, name, val)
|
||||
for pref in args.setpref:
|
||||
name = pref[0]
|
||||
print(f"Setting preference {name} to {pref[1]}")
|
||||
# FIXME, currently this tool only supports setting integers
|
||||
try:
|
||||
val = int(pref[1])
|
||||
setattr(interface.radioConfig.preferences, name, val)
|
||||
except Exception as ex:
|
||||
print(f"Can't set {name} due to {ex}")
|
||||
print("Writing modified preferences to device...")
|
||||
interface.writeConfig()
|
||||
|
||||
@@ -85,7 +91,8 @@ def main():
|
||||
parser.add_argument("--info", help="Read and display the radio config information",
|
||||
action="store_true")
|
||||
|
||||
parser.add_argument("--setpref", help="Set a preferences field", nargs=2)
|
||||
parser.add_argument(
|
||||
"--setpref", help="Set a preferences field", nargs=2, action='append')
|
||||
|
||||
parser.add_argument(
|
||||
"--dest", help="The destination node id for the --send commands, if not set '^all' is assumed", default="^all")
|
||||
|
||||
Reference in New Issue
Block a user