From 3f9b6e54c8d3940b83bfd91ee39c511edc7bf088 Mon Sep 17 00:00:00 2001 From: MarekWo Date: Thu, 19 Mar 2026 12:08:11 +0100 Subject: [PATCH] fix(console): repeater req_* return value check meshcore _sync methods return dict (data) or None (error/timeout), not Event objects. hasattr(dict, 'payload') is always False, causing instant "timeout" errors. Changed to check `result is not None`. Co-Authored-By: Claude Opus 4.6 --- app/device_manager.py | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/app/device_manager.py b/app/device_manager.py index eef6fad..d3a36e9 100644 --- a/app/device_manager.py +++ b/app/device_manager.py @@ -1630,12 +1630,12 @@ class DeviceManager: try: # Pass timeout=0 to let library use device's suggested_timeout contact_timeout = contact.get('timeout', 0) or 0 - event = self.execute( + result = self.execute( self.mc.commands.req_status_sync(contact, contact_timeout), timeout=120 ) - if event and hasattr(event, 'payload'): - return {'success': True, 'data': event.payload} + if result is not None: + return {'success': True, 'data': result} return {'success': False, 'error': 'No status response (timeout)'} except Exception as e: logger.error(f"req_status failed: {e}") @@ -1650,12 +1650,12 @@ class DeviceManager: return {'success': False, 'error': f"Contact not found: {name_or_key}"} try: contact_timeout = contact.get('timeout', 0) or 0 - event = self.execute( + result = self.execute( self.mc.commands.req_regions_sync(contact, contact_timeout), timeout=120 ) - if event and hasattr(event, 'payload'): - return {'success': True, 'data': event.payload} + if result is not None: + return {'success': True, 'data': result} return {'success': False, 'error': 'No regions response (timeout)'} except Exception as e: logger.error(f"req_regions failed: {e}") @@ -1670,12 +1670,12 @@ class DeviceManager: return {'success': False, 'error': f"Contact not found: {name_or_key}"} try: contact_timeout = contact.get('timeout', 0) or 0 - event = self.execute( + result = self.execute( self.mc.commands.req_owner_sync(contact, contact_timeout), timeout=120 ) - if event and hasattr(event, 'payload'): - return {'success': True, 'data': event.payload} + if result is not None: + return {'success': True, 'data': result} return {'success': False, 'error': 'No owner response (timeout)'} except Exception as e: logger.error(f"req_owner failed: {e}") @@ -1690,12 +1690,12 @@ class DeviceManager: return {'success': False, 'error': f"Contact not found: {name_or_key}"} try: contact_timeout = contact.get('timeout', 0) or 0 - event = self.execute( + result = self.execute( self.mc.commands.req_acl_sync(contact, contact_timeout), timeout=120 ) - if event and hasattr(event, 'payload'): - return {'success': True, 'data': event.payload} + if result is not None: + return {'success': True, 'data': result} return {'success': False, 'error': 'No ACL response (timeout)'} except Exception as e: logger.error(f"req_acl failed: {e}") @@ -1710,12 +1710,12 @@ class DeviceManager: return {'success': False, 'error': f"Contact not found: {name_or_key}"} try: contact_timeout = contact.get('timeout', 0) or 0 - event = self.execute( + result = self.execute( self.mc.commands.req_basic_sync(contact, contact_timeout), timeout=120 ) - if event and hasattr(event, 'payload'): - return {'success': True, 'data': event.payload} + if result is not None: + return {'success': True, 'data': result} return {'success': False, 'error': 'No clock response (timeout)'} except Exception as e: logger.error(f"req_clock failed: {e}") @@ -1730,12 +1730,12 @@ class DeviceManager: return {'success': False, 'error': f"Contact not found: {name_or_key}"} try: contact_timeout = contact.get('timeout', 0) or 0 - event = self.execute( + result = self.execute( 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} + if result is not None: + return {'success': True, 'data': result} return {'success': False, 'error': 'No MMA response (timeout)'} except Exception as e: logger.error(f"req_mma failed: {e}")