Show error toast on PK export failure

This commit is contained in:
Jack Kingsman
2026-03-02 11:46:40 -08:00
parent 05df314619
commit 2581cc6af7
2 changed files with 29 additions and 0 deletions
+24
View File
@@ -270,6 +270,30 @@ class CommunityMqttPublisher(BaseMqttPublisher):
_log_prefix = "Community MQTT"
_not_configured_timeout: float | None = 30
def __init__(self) -> None:
super().__init__()
self._key_unavailable_warned: bool = False
async def start(self, settings: AppSettings) -> None:
self._key_unavailable_warned = False
await super().start(settings)
def _on_not_configured(self) -> None:
from app.keystore import has_private_key
from app.websocket import broadcast_error
if (
self._settings
and self._settings.community_mqtt_enabled
and not has_private_key()
and not self._key_unavailable_warned
):
broadcast_error(
"Community MQTT unavailable",
"Radio firmware does not support private key export.",
)
self._key_unavailable_warned = True
def _is_configured(self) -> bool:
"""Check if community MQTT is enabled and keys are available."""
from app.keystore import has_private_key
+5
View File
@@ -120,6 +120,10 @@ class BaseMqttPublisher(ABC):
"""Called before connecting. Return True to proceed, False to retry."""
return True
def _on_not_configured(self) -> None:
"""Called each time the loop finds the publisher not configured."""
return # no-op by default; subclasses may override
# ── Connection loop ────────────────────────────────────────────────
async def _connection_loop(self) -> None:
@@ -130,6 +134,7 @@ class BaseMqttPublisher(ABC):
while True:
if not self._is_configured():
self._on_not_configured()
self.connected = False
self._client = None
self._version_event.clear()