fix(console): ver command now queries firmware info properly

Was using self_info (which has no firmware data). Now uses
send_device_query() like meshcore-cli, showing model, version,
build date and repeat mode.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-03-19 13:23:56 +01:00
parent 3acdc7a402
commit 5a4c259c0b
2 changed files with 27 additions and 5 deletions

View File

@@ -1923,6 +1923,19 @@ class DeviceManager:
# ── Device Management ────────────────────────────────────────
def query_device(self) -> Dict:
"""Query device for firmware version and hardware info."""
if not self.is_connected:
return {'success': False, 'error': 'Device not connected'}
try:
event = self.execute(self.mc.commands.send_device_query(), timeout=5)
if event and hasattr(event, 'payload'):
return {'success': True, 'data': event.payload}
return {'success': False, 'error': 'No device query response'}
except Exception as e:
logger.error(f"query_device failed: {e}")
return {'success': False, 'error': str(e)}
def get_clock(self) -> Dict:
"""Get device clock time."""
if not self.is_connected:

View File

@@ -767,11 +767,20 @@ def _execute_console_command(args: list) -> str:
return f"Error: {result.get('error')}"
elif cmd == 'ver':
info = device_manager.get_device_info()
if info:
fw = info.get('firmware', info.get('fw_ver', '?'))
return f"Firmware: {fw}"
return "Version info unavailable"
result = device_manager.query_device()
if result.get('success'):
data = result['data']
fw_ver = data.get('fw ver', 0)
if fw_ver >= 3:
lines = ["Device info:"]
lines.append(f" Model: {data.get('model', '?')}")
lines.append(f" Version: {data.get('ver', '?')}")
lines.append(f" Build date: {data.get('fw_build', '?')}")
if 'repeat' in data:
lines.append(f" Repeat: {'on' if data['repeat'] else 'off'}")
return "\n".join(lines)
return f"Firmware version: {fw_ver}"
return f"Error: {result.get('error')}"
elif cmd == 'scope' and len(args) >= 2:
scope = ' '.join(args[1:])