From fe7c67ee9aba1812a05e145dbf652a0a529a05d6 Mon Sep 17 00:00:00 2001 From: MarekWo Date: Thu, 19 Mar 2026 11:58:46 +0100 Subject: [PATCH] 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 --- app/device_manager.py | 37 +++++++++++++++++++------------------ app/main.py | 12 +++++++----- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/app/device_manager.py b/app/device_manager.py index c870da6..eef6fad 100644 --- a/app/device_manager.py +++ b/app/device_manager.py @@ -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} diff --git a/app/main.py b/app/main.py index 1b94038..0f4b897 100644 --- a/app/main.py +++ b/app/main.py @@ -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: