fix(console): get/set help formatting, fix get path_hash_mode

- get help / set help: detailed parameter descriptions with
  explanations, matching meshcore-cli style
- get path_hash_mode: library returns int not Event, fixed check
- set help: now reachable (was behind len(args)>=3 guard)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-03-19 13:42:31 +01:00
parent 5a4c259c0b
commit 3057882f20
2 changed files with 41 additions and 12 deletions
+5 -12
View File
@@ -2026,14 +2026,11 @@ class DeviceManager:
return {'success': True, 'data': event.payload}
return {'success': False, 'error': 'No custom vars response'}
elif param == 'path_hash_mode':
event = self.execute(self.mc.commands.get_path_hash_mode(), timeout=5)
if event and hasattr(event, 'payload'):
return {'success': True, 'data': event.payload}
return {'success': False, 'error': 'No response'}
# get_path_hash_mode() returns int, not Event
value = self.execute(self.mc.commands.get_path_hash_mode(), timeout=5)
return {'success': True, 'data': {'path_hash_mode': value}}
elif param == 'help':
return {'success': True, 'data': {
'Available params': 'name, tx, coords, lat, lon, bat, radio, stats, custom, path_hash_mode'
}}
return {'success': True, 'help': 'get'}
else:
return {'success': False, 'error': f"Unknown param: {param}. Type 'get help' for list."}
except Exception as e:
@@ -2095,11 +2092,7 @@ class DeviceManager:
self.execute(self.mc.commands.set_path_hash_mode(int(value)), timeout=5)
return {'success': True, 'message': f'Path hash mode set to: {value}'}
elif param == 'help':
return {'success': True, 'data': {
'Available params': 'name, tx, coords, lat, lon, pin, telemetry_mode_base, '
'telemetry_mode_loc, telemetry_mode_env, advert_loc_policy, '
'manual_add_contacts, multi_acks, path_hash_mode, <custom_var>'
}}
return {'success': True, 'help': 'set'}
else:
# Try as custom variable
self.execute(self.mc.commands.set_custom_var(param, value), timeout=5)
+36
View File
@@ -698,6 +698,20 @@ def _execute_console_command(args: list) -> str:
elif cmd == 'get' and len(args) >= 2:
param = args[1]
result = device_manager.get_param(param)
if result.get('help') == 'get':
return (
"Get parameters from device:\n"
" name — node name\n"
" tx — TX power\n"
" coords — adv coordinates (lat, lon)\n"
" lat — latitude\n"
" lon — longitude\n"
" bat — battery level in mV\n"
" radio — radio parameters (freq, bw, sf, cr)\n"
" stats — device status/statistics\n"
" custom — all custom variables (JSON)\n"
" path_hash_mode — path hash mode"
)
if result.get('success'):
data = result.get('data', {})
lines = []
@@ -728,6 +742,28 @@ def _execute_console_command(args: list) -> str:
return result.get('message', 'OK')
return f"Error: {result.get('error')}"
elif cmd == 'set' and len(args) == 2 and args[1] == 'help':
result = device_manager.set_param('help', '')
return (
"Set device parameters:\n"
" Device:\n"
" name <name> — node name\n"
" tx <dbm> — TX power\n"
" coords <lat>,<lon> — coordinates\n"
" lat <lat> — latitude\n"
" lon <lon> — longitude\n"
" pin <pin> — BLE pin\n"
" radio <freq,bw,sf,cr> — radio params\n"
" multi_acks <on/off> — multi-acks feature\n"
" manual_add_contacts <on/off> — manual contact approval\n"
" telemetry_mode_base <mode> — basic telemetry (all/selected/off)\n"
" telemetry_mode_loc <mode> — location telemetry\n"
" telemetry_mode_env <mode> — environment telemetry\n"
" advert_loc_policy <policy> — location in adverts\n"
" path_hash_mode <value> — path hash mode\n"
" <custom_var> <value> — set custom variable"
)
elif cmd == 'set':
return "Usage: set <param> <value>\n Type 'set help' for available params"