mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-08-07 09:12:57 +02:00
fix(channels): stop channel iteration on consecutive empty slots
meshcore lib 2.2.21 has a bug where list.extend() return value (None) is assigned to self.channels, corrupting state for indices >= 20. Stop iterating after 3 consecutive empty/failed channels to avoid hitting this bug and reduce error log spam. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+15
-1
@@ -206,9 +206,16 @@ class DeviceManager:
|
||||
|
||||
async def _load_channel_secrets(self):
|
||||
"""Load channel secrets from device for pkt_payload computation."""
|
||||
consecutive_empty = 0
|
||||
try:
|
||||
for idx in range(self._max_channels):
|
||||
event = await self.mc.commands.get_channel(idx)
|
||||
try:
|
||||
event = await self.mc.commands.get_channel(idx)
|
||||
except Exception:
|
||||
consecutive_empty += 1
|
||||
if consecutive_empty >= 3:
|
||||
break # likely past last configured channel
|
||||
continue
|
||||
if event:
|
||||
data = getattr(event, 'payload', None) or {}
|
||||
secret = data.get('channel_secret', data.get('secret', b''))
|
||||
@@ -216,6 +223,13 @@ class DeviceManager:
|
||||
secret = secret.hex()
|
||||
if secret and len(secret) == 32:
|
||||
self._channel_secrets[idx] = secret
|
||||
consecutive_empty = 0
|
||||
else:
|
||||
consecutive_empty += 1
|
||||
else:
|
||||
consecutive_empty += 1
|
||||
if consecutive_empty >= 3:
|
||||
break # stop after 3 consecutive empty channels
|
||||
logger.info(f"Cached {len(self._channel_secrets)} channel secrets")
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to load channel secrets: {e}")
|
||||
|
||||
Reference in New Issue
Block a user