mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-03-28 17:43:05 +01:00
35 lines
1.1 KiB
Python
35 lines
1.1 KiB
Python
"""Base class for fanout integration modules."""
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
class FanoutModule:
|
|
"""Base class for all fanout integrations.
|
|
|
|
Each module wraps a specific integration (MQTT, webhook, etc.) and
|
|
receives dispatched messages/packets from the FanoutManager.
|
|
|
|
Subclasses must override the ``status`` property.
|
|
"""
|
|
|
|
def __init__(self, config_id: str, config: dict) -> None:
|
|
self.config_id = config_id
|
|
self.config = config
|
|
|
|
async def start(self) -> None:
|
|
"""Start the module (e.g. connect to broker). Override for persistent connections."""
|
|
|
|
async def stop(self) -> None:
|
|
"""Stop the module (e.g. disconnect from broker)."""
|
|
|
|
async def on_message(self, data: dict) -> None:
|
|
"""Called for decoded messages (DM/channel). Override if needed."""
|
|
|
|
async def on_raw(self, data: dict) -> None:
|
|
"""Called for raw RF packets. Override if needed."""
|
|
|
|
@property
|
|
def status(self) -> str:
|
|
"""Return 'connected', 'disconnected', or 'error'."""
|
|
raise NotImplementedError
|