fix(console): human-readable clock, fix repeater timeouts

- Clock command now shows datetime like meshcore-cli: "Current time: 2026-03-19 11:39:07 (1773916747)"
- Repeater req_* commands: pass timeout=0 to meshcore library so it uses
  device's suggested_timeout instead of hardcoded 30s (matching meshcore-cli behavior)
- Execute timeout raised to 120s to accommodate slow repeater responses

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-03-19 11:58:46 +01:00
parent 4f64cc92e5
commit fe7c67ee9a
2 changed files with 26 additions and 23 deletions

View File

@@ -1628,10 +1628,11 @@ class DeviceManager:
if not contact:
return {'success': False, 'error': f"Contact not found: {name_or_key}"}
try:
timeout = contact.get('timeout', 0) or 30
# Pass timeout=0 to let library use device's suggested_timeout
contact_timeout = contact.get('timeout', 0) or 0
event = self.execute(
self.mc.commands.req_status_sync(contact, timeout),
timeout=timeout + 5
self.mc.commands.req_status_sync(contact, contact_timeout),
timeout=120
)
if event and hasattr(event, 'payload'):
return {'success': True, 'data': event.payload}
@@ -1648,10 +1649,10 @@ class DeviceManager:
if not contact:
return {'success': False, 'error': f"Contact not found: {name_or_key}"}
try:
timeout = contact.get('timeout', 0) or 30
contact_timeout = contact.get('timeout', 0) or 0
event = self.execute(
self.mc.commands.req_regions_sync(contact, timeout),
timeout=timeout + 5
self.mc.commands.req_regions_sync(contact, contact_timeout),
timeout=120
)
if event and hasattr(event, 'payload'):
return {'success': True, 'data': event.payload}
@@ -1668,10 +1669,10 @@ class DeviceManager:
if not contact:
return {'success': False, 'error': f"Contact not found: {name_or_key}"}
try:
timeout = contact.get('timeout', 0) or 30
contact_timeout = contact.get('timeout', 0) or 0
event = self.execute(
self.mc.commands.req_owner_sync(contact, timeout),
timeout=timeout + 5
self.mc.commands.req_owner_sync(contact, contact_timeout),
timeout=120
)
if event and hasattr(event, 'payload'):
return {'success': True, 'data': event.payload}
@@ -1688,10 +1689,10 @@ class DeviceManager:
if not contact:
return {'success': False, 'error': f"Contact not found: {name_or_key}"}
try:
timeout = contact.get('timeout', 0) or 30
contact_timeout = contact.get('timeout', 0) or 0
event = self.execute(
self.mc.commands.req_acl_sync(contact, timeout),
timeout=timeout + 5
self.mc.commands.req_acl_sync(contact, contact_timeout),
timeout=120
)
if event and hasattr(event, 'payload'):
return {'success': True, 'data': event.payload}
@@ -1708,10 +1709,10 @@ class DeviceManager:
if not contact:
return {'success': False, 'error': f"Contact not found: {name_or_key}"}
try:
timeout = contact.get('timeout', 0) or 30
contact_timeout = contact.get('timeout', 0) or 0
event = self.execute(
self.mc.commands.req_basic_sync(contact, timeout),
timeout=timeout + 5
self.mc.commands.req_basic_sync(contact, contact_timeout),
timeout=120
)
if event and hasattr(event, 'payload'):
return {'success': True, 'data': event.payload}
@@ -1728,10 +1729,10 @@ class DeviceManager:
if not contact:
return {'success': False, 'error': f"Contact not found: {name_or_key}"}
try:
timeout = contact.get('timeout', 0) or 30
contact_timeout = contact.get('timeout', 0) or 0
event = self.execute(
self.mc.commands.req_mma_sync(contact, from_secs, to_secs, timeout),
timeout=timeout + 5
self.mc.commands.req_mma_sync(contact, from_secs, to_secs, contact_timeout),
timeout=120
)
if event and hasattr(event, 'payload'):
return {'success': True, 'data': event.payload}

View File

@@ -702,18 +702,20 @@ def _execute_console_command(args: list) -> str:
elif cmd == 'clock':
if len(args) >= 2 and args[1] == 'sync':
import time as _time
import datetime as _dt
epoch = int(_time.time())
result = device_manager.set_clock(epoch)
if result.get('success'):
return f"Clock synced to {epoch}"
dt_str = _dt.datetime.fromtimestamp(epoch).strftime("%Y-%m-%d %H:%M:%S")
return f"Clock synced to {dt_str} ({epoch})"
return f"Error: {result.get('error')}"
result = device_manager.get_clock()
if result.get('success'):
import datetime as _dt
data = result['data']
lines = ["Device clock:"]
for k, v in data.items():
lines.append(f" {k}: {v}")
return "\n".join(lines)
timestamp = data.get('time', 0)
dt_str = _dt.datetime.fromtimestamp(timestamp).strftime("%Y-%m-%d %H:%M:%S")
return f"Current time: {dt_str} ({timestamp})"
return f"Error: {result.get('error')}"
elif cmd == 'time' and len(args) >= 2: