mmrelay 1.1.2__py3-none-any.whl → 1.1.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of mmrelay might be problematic. Click here for more details.
- mmrelay/__init__.py +1 -13
- mmrelay/cli.py +124 -64
- mmrelay/config.py +63 -36
- mmrelay/config_checker.py +41 -12
- mmrelay/constants/__init__.py +54 -0
- mmrelay/constants/app.py +17 -0
- mmrelay/constants/config.py +73 -0
- mmrelay/constants/database.py +22 -0
- mmrelay/constants/formats.py +20 -0
- mmrelay/constants/messages.py +36 -0
- mmrelay/constants/network.py +35 -0
- mmrelay/constants/queue.py +17 -0
- mmrelay/db_utils.py +281 -132
- mmrelay/log_utils.py +38 -14
- mmrelay/main.py +23 -4
- mmrelay/matrix_utils.py +413 -162
- mmrelay/meshtastic_utils.py +223 -106
- mmrelay/message_queue.py +475 -0
- mmrelay/plugin_loader.py +56 -53
- mmrelay/plugins/base_plugin.py +139 -39
- mmrelay/plugins/drop_plugin.py +13 -5
- mmrelay/plugins/mesh_relay_plugin.py +7 -10
- mmrelay/plugins/weather_plugin.py +10 -1
- mmrelay/setup_utils.py +67 -30
- mmrelay/tools/sample_config.yaml +13 -3
- {mmrelay-1.1.2.dist-info → mmrelay-1.1.4.dist-info}/METADATA +12 -14
- mmrelay-1.1.4.dist-info/RECORD +43 -0
- mmrelay-1.1.4.dist-info/licenses/LICENSE +675 -0
- mmrelay-1.1.2.dist-info/RECORD +0 -34
- mmrelay-1.1.2.dist-info/licenses/LICENSE +0 -21
- {mmrelay-1.1.2.dist-info → mmrelay-1.1.4.dist-info}/WHEEL +0 -0
- {mmrelay-1.1.2.dist-info → mmrelay-1.1.4.dist-info}/entry_points.txt +0 -0
- {mmrelay-1.1.2.dist-info → mmrelay-1.1.4.dist-info}/top_level.txt +0 -0
mmrelay/main.py
CHANGED
|
@@ -15,6 +15,7 @@ from nio.events.room_events import RoomMemberEvent
|
|
|
15
15
|
# Import version from package
|
|
16
16
|
# Import meshtastic_utils as a module to set event_loop
|
|
17
17
|
from mmrelay import __version__, meshtastic_utils
|
|
18
|
+
from mmrelay.constants.app import APP_DISPLAY_NAME, WINDOWS_PLATFORM
|
|
18
19
|
from mmrelay.db_utils import (
|
|
19
20
|
initialize_database,
|
|
20
21
|
update_longnames,
|
|
@@ -27,10 +28,16 @@ from mmrelay.matrix_utils import logger as matrix_logger
|
|
|
27
28
|
from mmrelay.matrix_utils import on_room_member, on_room_message
|
|
28
29
|
from mmrelay.meshtastic_utils import connect_meshtastic
|
|
29
30
|
from mmrelay.meshtastic_utils import logger as meshtastic_logger
|
|
31
|
+
from mmrelay.message_queue import (
|
|
32
|
+
DEFAULT_MESSAGE_DELAY,
|
|
33
|
+
get_message_queue,
|
|
34
|
+
start_message_queue,
|
|
35
|
+
stop_message_queue,
|
|
36
|
+
)
|
|
30
37
|
from mmrelay.plugin_loader import load_plugins
|
|
31
38
|
|
|
32
39
|
# Initialize logger
|
|
33
|
-
logger = get_logger(name=
|
|
40
|
+
logger = get_logger(name=APP_DISPLAY_NAME)
|
|
34
41
|
|
|
35
42
|
# Set the logging level for 'nio' to ERROR to suppress warnings
|
|
36
43
|
logging.getLogger("nio").setLevel(logging.ERROR)
|
|
@@ -51,9 +58,9 @@ def print_banner():
|
|
|
51
58
|
|
|
52
59
|
async def main(config):
|
|
53
60
|
"""
|
|
54
|
-
|
|
61
|
+
Coordinates the main asynchronous relay loop between Meshtastic and Matrix clients.
|
|
55
62
|
|
|
56
|
-
Initializes the database, loads plugins,
|
|
63
|
+
Initializes the database, loads plugins, starts the message queue, and establishes connections to both Meshtastic and Matrix. Joins configured Matrix rooms, registers event callbacks for message and membership events, and periodically updates node names from the Meshtastic network. Monitors connection health, manages the Matrix sync loop with reconnection and shutdown handling, and ensures graceful shutdown of all components. Optionally wipes the message map on startup and shutdown if configured.
|
|
57
64
|
"""
|
|
58
65
|
# Extract Matrix configuration
|
|
59
66
|
from typing import List
|
|
@@ -90,6 +97,12 @@ async def main(config):
|
|
|
90
97
|
# Load plugins early
|
|
91
98
|
load_plugins(passed_config=config)
|
|
92
99
|
|
|
100
|
+
# Start message queue with configured message delay
|
|
101
|
+
message_delay = config.get("meshtastic", {}).get(
|
|
102
|
+
"message_delay", DEFAULT_MESSAGE_DELAY
|
|
103
|
+
)
|
|
104
|
+
start_message_queue(message_delay=message_delay)
|
|
105
|
+
|
|
93
106
|
# Connect to Meshtastic
|
|
94
107
|
meshtastic_utils.meshtastic_client = connect_meshtastic(passed_config=config)
|
|
95
108
|
|
|
@@ -121,7 +134,7 @@ async def main(config):
|
|
|
121
134
|
loop = asyncio.get_running_loop()
|
|
122
135
|
|
|
123
136
|
# Handle signals differently based on the platform
|
|
124
|
-
if sys.platform !=
|
|
137
|
+
if sys.platform != WINDOWS_PLATFORM:
|
|
125
138
|
for sig in (signal.SIGINT, signal.SIGTERM):
|
|
126
139
|
loop.add_signal_handler(sig, lambda: asyncio.create_task(shutdown()))
|
|
127
140
|
else:
|
|
@@ -132,6 +145,9 @@ async def main(config):
|
|
|
132
145
|
# This provides proactive connection detection for all interface types
|
|
133
146
|
_ = asyncio.create_task(meshtastic_utils.check_connection())
|
|
134
147
|
|
|
148
|
+
# Ensure message queue processor is started now that event loop is running
|
|
149
|
+
get_message_queue().ensure_processor_started()
|
|
150
|
+
|
|
135
151
|
# Start the Matrix client sync loop
|
|
136
152
|
try:
|
|
137
153
|
while not shutdown_event.is_set():
|
|
@@ -173,6 +189,9 @@ async def main(config):
|
|
|
173
189
|
await shutdown()
|
|
174
190
|
finally:
|
|
175
191
|
# Cleanup
|
|
192
|
+
matrix_logger.info("Stopping message queue...")
|
|
193
|
+
stop_message_queue()
|
|
194
|
+
|
|
176
195
|
matrix_logger.info("Closing Matrix client...")
|
|
177
196
|
await matrix_client.close()
|
|
178
197
|
if meshtastic_utils.meshtastic_client:
|