mmrelay 1.1.3__py3-none-any.whl → 1.2.0__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.

@@ -0,0 +1,54 @@
1
+ """
2
+ Constants package for MMRelay.
3
+
4
+ This package organizes all application constants by functional area:
5
+ - app: Application metadata and version information
6
+ - queue: Message queue configuration constants
7
+ - network: Network connection and timeout constants
8
+ - formats: Message format templates and prefixes
9
+ - messages: User-facing strings and templates
10
+ - database: Database-related constants
11
+ - config: Configuration section and key constants
12
+
13
+ Usage:
14
+ from mmrelay.constants import queue
15
+ from mmrelay.constants.app import APP_NAME
16
+ from mmrelay.constants.queue import DEFAULT_MESSAGE_DELAY
17
+ """
18
+
19
+ # Re-export commonly used constants for convenience
20
+ from .app import APP_AUTHOR, APP_NAME
21
+ from .config import (
22
+ CONFIG_KEY_LEVEL,
23
+ CONFIG_SECTION_LOGGING,
24
+ CONFIG_SECTION_MATRIX,
25
+ CONFIG_SECTION_MESHTASTIC,
26
+ DEFAULT_LOG_LEVEL,
27
+ )
28
+ from .formats import DEFAULT_MATRIX_PREFIX, DEFAULT_MESHTASTIC_PREFIX
29
+ from .queue import (
30
+ DEFAULT_MESSAGE_DELAY,
31
+ MAX_QUEUE_SIZE,
32
+ QUEUE_HIGH_WATER_MARK,
33
+ QUEUE_MEDIUM_WATER_MARK,
34
+ )
35
+
36
+ __all__ = [
37
+ # App constants
38
+ "APP_NAME",
39
+ "APP_AUTHOR",
40
+ # Config constants
41
+ "CONFIG_SECTION_MATRIX",
42
+ "CONFIG_SECTION_MESHTASTIC",
43
+ "CONFIG_SECTION_LOGGING",
44
+ "CONFIG_KEY_LEVEL",
45
+ "DEFAULT_LOG_LEVEL",
46
+ # Queue constants
47
+ "DEFAULT_MESSAGE_DELAY",
48
+ "MAX_QUEUE_SIZE",
49
+ "QUEUE_HIGH_WATER_MARK",
50
+ "QUEUE_MEDIUM_WATER_MARK",
51
+ # Format constants
52
+ "DEFAULT_MESHTASTIC_PREFIX",
53
+ "DEFAULT_MATRIX_PREFIX",
54
+ ]
@@ -0,0 +1,29 @@
1
+ """
2
+ Application metadata constants.
3
+
4
+ Contains version information, application name, and other metadata
5
+ used throughout the MMRelay application.
6
+ """
7
+
8
+ # Application identification
9
+ APP_NAME = "mmrelay"
10
+ APP_AUTHOR = None # No author directory for platformdirs
11
+
12
+ # Application display names
13
+ APP_DISPLAY_NAME = "M<>M Relay"
14
+ APP_FULL_NAME = "Meshtastic Matrix Relay"
15
+
16
+ # Matrix client identification
17
+ MATRIX_DEVICE_NAME = "MMRelay"
18
+
19
+ # Platform-specific constants
20
+ WINDOWS_PLATFORM = "win32"
21
+
22
+ # Package and installation constants
23
+ PACKAGE_NAME_E2E = "mmrelay[e2e]"
24
+ PYTHON_OLM_PACKAGE = "python-olm"
25
+
26
+ # Configuration file names
27
+ CREDENTIALS_FILENAME = "credentials.json"
28
+ CONFIG_FILENAME = "config.yaml"
29
+ STORE_DIRNAME = "store"
@@ -0,0 +1,78 @@
1
+ """
2
+ Configuration section and key constants.
3
+
4
+ Contains configuration section names, key names, and default values
5
+ used throughout the configuration system.
6
+ """
7
+
8
+ # Configuration section names
9
+ CONFIG_SECTION_MATRIX = "matrix"
10
+ CONFIG_SECTION_MATRIX_ROOMS = "matrix_rooms"
11
+ CONFIG_SECTION_MESHTASTIC = "meshtastic"
12
+ CONFIG_SECTION_LOGGING = "logging"
13
+ CONFIG_SECTION_DATABASE = "database"
14
+ CONFIG_SECTION_PLUGINS = "plugins"
15
+ CONFIG_SECTION_COMMUNITY_PLUGINS = "community-plugins"
16
+ CONFIG_SECTION_CUSTOM_PLUGINS = "custom-plugins"
17
+
18
+ # Matrix configuration keys
19
+ CONFIG_KEY_HOMESERVER = "homeserver"
20
+ CONFIG_KEY_ACCESS_TOKEN = (
21
+ "access_token" # nosec B105 - This is a config key name, not a hardcoded password
22
+ )
23
+ CONFIG_KEY_BOT_USER_ID = "bot_user_id"
24
+ CONFIG_KEY_PREFIX_ENABLED = "prefix_enabled"
25
+ CONFIG_KEY_PREFIX_FORMAT = "prefix_format"
26
+
27
+ # Matrix rooms configuration keys
28
+ CONFIG_KEY_ID = "id"
29
+ CONFIG_KEY_MESHTASTIC_CHANNEL = "meshtastic_channel"
30
+
31
+ # Meshtastic configuration keys (additional to network.py)
32
+ CONFIG_KEY_MESHNET_NAME = "meshnet_name"
33
+ CONFIG_KEY_MESSAGE_INTERACTIONS = "message_interactions"
34
+ CONFIG_KEY_REACTIONS = "reactions"
35
+ CONFIG_KEY_REPLIES = "replies"
36
+ CONFIG_KEY_BROADCAST_ENABLED = "broadcast_enabled"
37
+ CONFIG_KEY_DETECTION_SENSOR = "detection_sensor"
38
+ CONFIG_KEY_MESSAGE_DELAY = "message_delay"
39
+ CONFIG_KEY_HEALTH_CHECK = "health_check"
40
+ CONFIG_KEY_ENABLED = "enabled"
41
+ CONFIG_KEY_HEARTBEAT_INTERVAL = "heartbeat_interval"
42
+
43
+ # Logging configuration keys
44
+ CONFIG_KEY_LEVEL = "level"
45
+ CONFIG_KEY_LOG_TO_FILE = "log_to_file"
46
+ CONFIG_KEY_FILENAME = "filename"
47
+ CONFIG_KEY_MAX_LOG_SIZE = "max_log_size"
48
+ CONFIG_KEY_BACKUP_COUNT = "backup_count"
49
+ CONFIG_KEY_COLOR_ENABLED = "color_enabled"
50
+ CONFIG_KEY_DEBUG = "debug"
51
+
52
+ # Database configuration keys
53
+ CONFIG_KEY_PATH = "path"
54
+ CONFIG_KEY_MSG_MAP = "msg_map"
55
+ CONFIG_KEY_MSGS_TO_KEEP = "msgs_to_keep"
56
+ CONFIG_KEY_WIPE_ON_RESTART = "wipe_on_restart"
57
+
58
+ # Plugin configuration keys
59
+ CONFIG_KEY_ACTIVE = "active"
60
+ CONFIG_KEY_CHANNELS = "channels"
61
+ CONFIG_KEY_UNITS = "units"
62
+ CONFIG_KEY_REPOSITORY = "repository"
63
+ CONFIG_KEY_TAG = "tag"
64
+
65
+ # Default configuration values
66
+ DEFAULT_LOG_LEVEL = "info"
67
+ DEFAULT_WEATHER_UNITS = "metric"
68
+ DEFAULT_WEATHER_UNITS_IMPERIAL = "imperial"
69
+ DEFAULT_PREFIX_ENABLED = True
70
+ DEFAULT_BROADCAST_ENABLED = True
71
+ DEFAULT_DETECTION_SENSOR = True
72
+ DEFAULT_HEALTH_CHECK_ENABLED = True
73
+ DEFAULT_HEARTBEAT_INTERVAL = 60
74
+ DEFAULT_COLOR_ENABLED = True
75
+ DEFAULT_WIPE_ON_RESTART = False
76
+
77
+ # E2EE constants
78
+ E2EE_KEY_SHARING_DELAY_SECONDS = 5
@@ -0,0 +1,22 @@
1
+ """
2
+ Database-related constants.
3
+
4
+ Contains default values for database configuration, message retention,
5
+ and data management settings.
6
+ """
7
+
8
+ # Message retention defaults
9
+ DEFAULT_MSGS_TO_KEEP = 500
10
+ DEFAULT_MAX_DATA_ROWS_PER_NODE_BASE = 100 # Base plugin default
11
+ DEFAULT_MAX_DATA_ROWS_PER_NODE_MESH_RELAY = 50 # Reduced for mesh relay performance
12
+
13
+ # Progress tracking
14
+ PROGRESS_TOTAL_STEPS = 100
15
+ PROGRESS_COMPLETE = 100
16
+
17
+ # Text truncation
18
+ DEFAULT_TEXT_TRUNCATION_LENGTH = 50
19
+
20
+ # Distance calculations
21
+ DEFAULT_DISTANCE_KM_FALLBACK = 1000 # Fallback distance when calculation fails
22
+ DEFAULT_RADIUS_KM = 5 # Default radius for location-based filtering
@@ -0,0 +1,20 @@
1
+ """
2
+ Message format constants.
3
+
4
+ Contains default message prefixes, format templates, and other
5
+ formatting-related constants used for message display and relay.
6
+ """
7
+
8
+ # Default message prefix formats
9
+ DEFAULT_MESHTASTIC_PREFIX = "{display5}[M]: "
10
+ DEFAULT_MATRIX_PREFIX = "[{long}/{mesh}]: "
11
+
12
+ # Port number constants for message types
13
+ TEXT_MESSAGE_APP = "TEXT_MESSAGE_APP"
14
+ DETECTION_SENSOR_APP = "DETECTION_SENSOR_APP"
15
+
16
+ # Emoji flag value
17
+ EMOJI_FLAG_VALUE = 1
18
+
19
+ # Default channel
20
+ DEFAULT_CHANNEL = 0
@@ -0,0 +1,45 @@
1
+ """
2
+ User-facing messages and string templates.
3
+
4
+ Contains error messages, log templates, command responses, and other
5
+ strings that are displayed to users or logged.
6
+ """
7
+
8
+ # Log configuration defaults
9
+ DEFAULT_LOG_SIZE_MB = 5
10
+ DEFAULT_LOG_BACKUP_COUNT = 1
11
+ LOG_SIZE_BYTES_MULTIPLIER = 1024 * 1024 # Convert MB to bytes
12
+
13
+ # Numeric constants for comparisons
14
+ PORTNUM_NUMERIC_VALUE = 1 # Numeric equivalent of TEXT_MESSAGE_APP
15
+ DEFAULT_CHANNEL_VALUE = 0
16
+
17
+ # Message formatting constants
18
+ MAX_TRUNCATION_LENGTH = 20 # Maximum characters for variable truncation
19
+ TRUNCATION_LOG_LIMIT = 6 # Only log first N truncations to avoid spam
20
+ DEFAULT_MESSAGE_TRUNCATE_BYTES = 227 # Default message truncation size
21
+ MESHNET_NAME_ABBREVIATION_LENGTH = 4 # Characters for short meshnet names
22
+ SHORTNAME_FALLBACK_LENGTH = 3 # Characters for shortname fallback
23
+ MESSAGE_PREVIEW_LENGTH = 40 # Characters for message preview in logs
24
+ DISPLAY_NAME_DEFAULT_LENGTH = 5 # Default display name truncation
25
+
26
+ # Component logger names
27
+ COMPONENT_LOGGERS = {
28
+ "matrix_nio": ["nio", "nio.client", "nio.http", "nio.crypto", "nio.responses"],
29
+ "bleak": ["bleak", "bleak.backends"],
30
+ "meshtastic": [
31
+ "meshtastic",
32
+ "meshtastic.serial_interface",
33
+ "meshtastic.tcp_interface",
34
+ "meshtastic.ble_interface",
35
+ ],
36
+ }
37
+
38
+ # Log level styling
39
+ LOG_LEVEL_STYLES = {
40
+ "DEBUG": {"color": "cyan"},
41
+ "INFO": {"color": "green"},
42
+ "WARNING": {"color": "yellow"},
43
+ "ERROR": {"color": "red"},
44
+ "CRITICAL": {"color": "red", "bold": True},
45
+ }
@@ -0,0 +1,42 @@
1
+ """
2
+ Network and connection constants.
3
+
4
+ Contains timeout values, retry limits, connection types, and other
5
+ network-related configuration constants.
6
+ """
7
+
8
+ # Connection types
9
+ CONNECTION_TYPE_TCP = "tcp"
10
+ CONNECTION_TYPE_SERIAL = "serial"
11
+ CONNECTION_TYPE_BLE = "ble"
12
+ CONNECTION_TYPE_NETWORK = (
13
+ "network" # DEPRECATED: Legacy alias for tcp, use CONNECTION_TYPE_TCP instead
14
+ )
15
+
16
+ # Configuration keys for connection settings
17
+ CONFIG_KEY_BLE_ADDRESS = "ble_address"
18
+ CONFIG_KEY_SERIAL_PORT = "serial_port"
19
+ CONFIG_KEY_HOST = "host"
20
+ CONFIG_KEY_CONNECTION_TYPE = "connection_type"
21
+
22
+ # Connection retry and timing
23
+ DEFAULT_BACKOFF_TIME = 10 # seconds
24
+ DEFAULT_RETRY_ATTEMPTS = 1
25
+ INFINITE_RETRIES = 0 # 0 means infinite retries
26
+ MINIMUM_MESSAGE_DELAY = 2.0 # Minimum delay for message queue fallback
27
+
28
+ # Matrix client timeouts
29
+ MATRIX_EARLY_SYNC_TIMEOUT = 2000 # milliseconds
30
+ MATRIX_MAIN_SYNC_TIMEOUT = 5000 # milliseconds
31
+ MATRIX_ROOM_SEND_TIMEOUT = 10.0 # seconds
32
+ MATRIX_LOGIN_TIMEOUT = 30.0 # seconds
33
+ MATRIX_SYNC_OPERATION_TIMEOUT = 60.0 # seconds
34
+
35
+ # Error codes
36
+ ERRNO_BAD_FILE_DESCRIPTOR = 9
37
+
38
+ # System detection
39
+ SYSTEMD_INIT_SYSTEM = "systemd"
40
+
41
+ # Time conversion
42
+ MILLISECONDS_PER_SECOND = 1000
@@ -0,0 +1,17 @@
1
+ """
2
+ Message queue constants.
3
+
4
+ Contains configuration values for the message queue system including
5
+ delays, size limits, and water marks for queue management.
6
+ """
7
+
8
+ # Message timing constants
9
+ DEFAULT_MESSAGE_DELAY = 2.0 # Firmware-enforced minimum delay in seconds
10
+
11
+ # Queue size management
12
+ MAX_QUEUE_SIZE = 500
13
+ QUEUE_HIGH_WATER_MARK = int(MAX_QUEUE_SIZE * 0.75) # 75% of MAX_QUEUE_SIZE
14
+ QUEUE_MEDIUM_WATER_MARK = int(MAX_QUEUE_SIZE * 0.50) # 50% of MAX_QUEUE_SIZE
15
+
16
+ # Queue logging thresholds
17
+ QUEUE_LOG_THRESHOLD = 2 # Only log queue status when size >= this value