mc-aprs 0.0.1a26__tar.gz

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.
@@ -0,0 +1,168 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110
+ .pdm.toml
111
+ .pdm-python
112
+ .pdm-build/
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ #.idea/
163
+
164
+ # project - specific
165
+ tests/test_data/precompiled_registrations.json
166
+ tests/test_data/registrations.db
167
+ tests/test_data/mc-aprs.yaml
168
+ tests/test_data/registration_overrides.json
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Adam Fourney
4
+ Copyright (c) 2026 Mambo430
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
@@ -0,0 +1,156 @@
1
+ Metadata-Version: 2.5
2
+ Name: mc-aprs
3
+ Version: 0.0.1a26
4
+ Summary: A MeshCore-APRS Gateway
5
+ Project-URL: Documentation, https://github.com/Mambo430/MC-APRS#readme
6
+ Project-URL: Issues, https://github.com/Mambo430/MC-APRS/issues
7
+ Project-URL: Source, https://github.com/Mambo430/MC-APRS
8
+ Author-email: Adam Fourney <adam.fourney@gmail.com>
9
+ License-File: LICENSE
10
+ Keywords: aprs,aprs-gateway,aprs-is,gateway,lora,lora-gateway,meshcore,meshcore-gateway
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3.10
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: Implementation :: CPython
17
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
18
+ Classifier: Topic :: Communications :: Ham Radio
19
+ Requires-Python: >=3.10
20
+ Requires-Dist: aprslib
21
+ Requires-Dist: meshcore
22
+ Requires-Dist: packaging
23
+ Requires-Dist: pyyaml
24
+ Requires-Dist: requests
25
+ Description-Content-Type: text/markdown
26
+
27
+ # MC-APRS
28
+
29
+ An APRS to MeshCore Bridge.
30
+
31
+ ---
32
+
33
+ > [!WARNING]
34
+ > Legal operation of this software requires an amateur radio license and a valid call sign.
35
+
36
+ > [!NOTE]
37
+ > This code is under active development, and contributions are welcomed. See [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
38
+
39
+ ## New!
40
+
41
+ :fire: Change the gateway's APRS map icon. See [APRS_SYMBOLS.md](./APRS_SYMBOLS.md) for details.
42
+
43
+ :fire: Call sign registrations are now (optionally) beaconed to [MESHID-01](https://aprs.fi/?c=message&call=MESHID-01) to facilitate a global roaming profile.
44
+
45
+ The bundled registration database updates from the MC-APRS repository. Local and APRS-beaconed registrations are also supported.
46
+
47
+ ## Introduction
48
+
49
+ MC-APRS is a bidirectional MeshCore APRS gateway for operators **with amateur radio licenses**. It connects to a MeshCore Companion over its serial interface and uses direct messages plus pre-registered MeshCore public-key prefixes to associate operators with amateur radio call signs. Operation requires a Companion gateway and MeshCore client nodes.
50
+
51
+ Direct messages to the gateway are forwarded to APRS-IS using the registered call sign. APRS messages addressed to that call sign are sent as MeshCore direct messages to the registered contact. If registration beaconing is enabled, the public-key-prefix-to-call-sign association is also announced to `MESHID-01` so other compatible gateways can learn it.
52
+
53
+ The original Meshtastic edition is demonstrated in this [YouTube video](https://www.youtube.com/watch?v=qUvpZUwl-cY); it does not demonstrate the MeshCore serial interface.
54
+
55
+ Each gateway mimics an iGate and can support multiple MeshCore users, provided their call signs are registered. MeshCore contacts must be available to the Companion for the gateway to send them messages.
56
+ | aprs? | Advert | Demo |
57
+ | :---: | :---: | :---: |
58
+ | ![Public_aprs?](imgs/Public_aprs%3F.png) | ![Advert](imgs/Advert.png) | ![Demo](imgs/Demo.png) |
59
+
60
+
61
+ ## Special Commands
62
+
63
+ Various special commands can be issued by sending direct MeshCore messages to the gateway. The following commands are currently supported.
64
+
65
+ **Register a device:**
66
+
67
+ Use the following command to register the sending MeshCore public-key prefix to a call sign, replacing `<YOUR_CALLSIGN>` appropriately:
68
+
69
+ ```
70
+ !register <YOUR_CALLSIGN>
71
+ ```
72
+
73
+ e.g.,
74
+
75
+ ```
76
+ !register N0CALL-1
77
+ ```
78
+
79
+ **Unregister a device:**
80
+
81
+ Use the following command to unregister the sending MeshCore contact and its call sign.
82
+
83
+ ```
84
+ !unregister
85
+ ```
86
+
87
+ **Print version information:**
88
+
89
+ Use the following command to print the gateway's info and version.
90
+
91
+ ```
92
+ !version
93
+ ```
94
+
95
+ **Check whether the gateway is online:**
96
+
97
+ Send `aprs?` as a direct message for a private online reply, or send it on Public/channel 0 for a public response. The command is case-insensitive and does not require registration. Channel 0 messages may include a sender prefix (for example, `N0CALL-1: aprs?`); the gateway recognizes the command after that prefix. For each channel request, it sends a Flood Advert after its reply so nearby nodes can discover it and start a direct conversation, regardless of the periodic auto-advert setting or when the previous advert was sent.
98
+
99
+ ## Installation, Configuration, and Running
100
+
101
+ On Debian-based systems, install and run the edited copy from a local clone in a virtual environment. This avoids trying to modify the OS-managed Python installation (PEP 668):
102
+
103
+ ```console
104
+ git clone https://github.com/Mambo430/MC-APRS.git
105
+ cd /home/spiritual/MC-APRS
106
+ python3 -m venv .venv
107
+ .venv/bin/python -m pip install -e .
108
+ .venv/bin/python -m mc_aprs
109
+ ```
110
+
111
+ The editable install uses the code in this checkout, so changes you make are available without reinstalling. Always use `.venv/bin/python` to run this checkout; `/usr/bin/python` is separate and will not see the package installed in the virtual environment.
112
+
113
+ **Install the published release:**
114
+
115
+ ```console
116
+ python3 -m venv .venv
117
+ .venv/bin/python -m pip install mc-aprs
118
+ .venv/bin/python -m mc_aprs
119
+ ```
120
+
121
+ The installation name is `mc-aprs`; the Python module name is `mc_aprs`.
122
+
123
+ The first time MC-APRS runs, it will create a sample `mc-aprs.yaml` file. **Edit the sample**, then run it again.
124
+
125
+ ```console
126
+ nano ~/.config/mc-aprs/mc-aprs.yaml
127
+ .venv/bin/python -m mc_aprs
128
+ ```
129
+
130
+ Set `meshcore_interface.device` to the Companion serial port (for example, `/dev/ttyACM0`) and ensure the account running MC-APRS has permission to access it. The serial baud rate defaults to `115200`.
131
+
132
+ To enable periodic MeshCore Flood Advertisements from the Companion, set `meshcore_interface.flood_advert: true`. MC-APRS sends one when it connects, then every 12 hours. It is disabled by default.
133
+
134
+ Gateway APRS beacon coordinates are entered manually under `gateway_beacon.latitude` and `gateway_beacon.longitude`. MeshCore client position reports are not forwarded by this gateway.
135
+
136
+ ## Addressing APRS messages
137
+
138
+ Prefix a MeshCore message with the APRS destination callsign and a colon:
139
+
140
+ ```
141
+ DEST-CALL: your message
142
+ ```
143
+
144
+ After the first addressed message, replies can omit the destination prefix and will go to the last APRS station contacted by that MeshCore device. Text replies from APRS stations, including service error messages, are forwarded to the registered MeshCore device.
145
+
146
+ ## Compliance
147
+
148
+ MC-APRS only forwards messages from registered MeshCore contacts, attributing each forwarded message to a call sign. Channel messages are not forwarded. Messages sent from the gateway to APRS-IS are clear text, as is APRS traffic generally.
149
+
150
+ ## A Note for APRS-IS Admins
151
+
152
+ MC-APRS identifies itself to APRS-IS level 2 servers with the software version number `APZMCG`. In accordance with the [Protocol Reference](http://www.aprs.org/doc/APRS101.PDF), `APZ` designates an experimental application in development; `MCG` identifies the MeshCore gateway.
153
+
154
+ ## License
155
+
156
+ MC-APRS is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,130 @@
1
+ # MC-APRS
2
+
3
+ An APRS to MeshCore Bridge.
4
+
5
+ ---
6
+
7
+ > [!WARNING]
8
+ > Legal operation of this software requires an amateur radio license and a valid call sign.
9
+
10
+ > [!NOTE]
11
+ > This code is under active development, and contributions are welcomed. See [CONTRIBUTING.md](./CONTRIBUTING.md) for details.
12
+
13
+ ## New!
14
+
15
+ :fire: Change the gateway's APRS map icon. See [APRS_SYMBOLS.md](./APRS_SYMBOLS.md) for details.
16
+
17
+ :fire: Call sign registrations are now (optionally) beaconed to [MESHID-01](https://aprs.fi/?c=message&call=MESHID-01) to facilitate a global roaming profile.
18
+
19
+ The bundled registration database updates from the MC-APRS repository. Local and APRS-beaconed registrations are also supported.
20
+
21
+ ## Introduction
22
+
23
+ MC-APRS is a bidirectional MeshCore APRS gateway for operators **with amateur radio licenses**. It connects to a MeshCore Companion over its serial interface and uses direct messages plus pre-registered MeshCore public-key prefixes to associate operators with amateur radio call signs. Operation requires a Companion gateway and MeshCore client nodes.
24
+
25
+ Direct messages to the gateway are forwarded to APRS-IS using the registered call sign. APRS messages addressed to that call sign are sent as MeshCore direct messages to the registered contact. If registration beaconing is enabled, the public-key-prefix-to-call-sign association is also announced to `MESHID-01` so other compatible gateways can learn it.
26
+
27
+ The original Meshtastic edition is demonstrated in this [YouTube video](https://www.youtube.com/watch?v=qUvpZUwl-cY); it does not demonstrate the MeshCore serial interface.
28
+
29
+ Each gateway mimics an iGate and can support multiple MeshCore users, provided their call signs are registered. MeshCore contacts must be available to the Companion for the gateway to send them messages.
30
+ | aprs? | Advert | Demo |
31
+ | :---: | :---: | :---: |
32
+ | ![Public_aprs?](imgs/Public_aprs%3F.png) | ![Advert](imgs/Advert.png) | ![Demo](imgs/Demo.png) |
33
+
34
+
35
+ ## Special Commands
36
+
37
+ Various special commands can be issued by sending direct MeshCore messages to the gateway. The following commands are currently supported.
38
+
39
+ **Register a device:**
40
+
41
+ Use the following command to register the sending MeshCore public-key prefix to a call sign, replacing `<YOUR_CALLSIGN>` appropriately:
42
+
43
+ ```
44
+ !register <YOUR_CALLSIGN>
45
+ ```
46
+
47
+ e.g.,
48
+
49
+ ```
50
+ !register N0CALL-1
51
+ ```
52
+
53
+ **Unregister a device:**
54
+
55
+ Use the following command to unregister the sending MeshCore contact and its call sign.
56
+
57
+ ```
58
+ !unregister
59
+ ```
60
+
61
+ **Print version information:**
62
+
63
+ Use the following command to print the gateway's info and version.
64
+
65
+ ```
66
+ !version
67
+ ```
68
+
69
+ **Check whether the gateway is online:**
70
+
71
+ Send `aprs?` as a direct message for a private online reply, or send it on Public/channel 0 for a public response. The command is case-insensitive and does not require registration. Channel 0 messages may include a sender prefix (for example, `N0CALL-1: aprs?`); the gateway recognizes the command after that prefix. For each channel request, it sends a Flood Advert after its reply so nearby nodes can discover it and start a direct conversation, regardless of the periodic auto-advert setting or when the previous advert was sent.
72
+
73
+ ## Installation, Configuration, and Running
74
+
75
+ On Debian-based systems, install and run the edited copy from a local clone in a virtual environment. This avoids trying to modify the OS-managed Python installation (PEP 668):
76
+
77
+ ```console
78
+ git clone https://github.com/Mambo430/MC-APRS.git
79
+ cd /home/spiritual/MC-APRS
80
+ python3 -m venv .venv
81
+ .venv/bin/python -m pip install -e .
82
+ .venv/bin/python -m mc_aprs
83
+ ```
84
+
85
+ The editable install uses the code in this checkout, so changes you make are available without reinstalling. Always use `.venv/bin/python` to run this checkout; `/usr/bin/python` is separate and will not see the package installed in the virtual environment.
86
+
87
+ **Install the published release:**
88
+
89
+ ```console
90
+ python3 -m venv .venv
91
+ .venv/bin/python -m pip install mc-aprs
92
+ .venv/bin/python -m mc_aprs
93
+ ```
94
+
95
+ The installation name is `mc-aprs`; the Python module name is `mc_aprs`.
96
+
97
+ The first time MC-APRS runs, it will create a sample `mc-aprs.yaml` file. **Edit the sample**, then run it again.
98
+
99
+ ```console
100
+ nano ~/.config/mc-aprs/mc-aprs.yaml
101
+ .venv/bin/python -m mc_aprs
102
+ ```
103
+
104
+ Set `meshcore_interface.device` to the Companion serial port (for example, `/dev/ttyACM0`) and ensure the account running MC-APRS has permission to access it. The serial baud rate defaults to `115200`.
105
+
106
+ To enable periodic MeshCore Flood Advertisements from the Companion, set `meshcore_interface.flood_advert: true`. MC-APRS sends one when it connects, then every 12 hours. It is disabled by default.
107
+
108
+ Gateway APRS beacon coordinates are entered manually under `gateway_beacon.latitude` and `gateway_beacon.longitude`. MeshCore client position reports are not forwarded by this gateway.
109
+
110
+ ## Addressing APRS messages
111
+
112
+ Prefix a MeshCore message with the APRS destination callsign and a colon:
113
+
114
+ ```
115
+ DEST-CALL: your message
116
+ ```
117
+
118
+ After the first addressed message, replies can omit the destination prefix and will go to the last APRS station contacted by that MeshCore device. Text replies from APRS stations, including service error messages, are forwarded to the registered MeshCore device.
119
+
120
+ ## Compliance
121
+
122
+ MC-APRS only forwards messages from registered MeshCore contacts, attributing each forwarded message to a call sign. Channel messages are not forwarded. Messages sent from the gateway to APRS-IS are clear text, as is APRS traffic generally.
123
+
124
+ ## A Note for APRS-IS Admins
125
+
126
+ MC-APRS identifies itself to APRS-IS level 2 servers with the software version number `APZMCG`. In accordance with the [Protocol Reference](http://www.aprs.org/doc/APRS101.PDF), `APZ` designates an experimental application in development; `MCG` identifies the MeshCore gateway.
127
+
128
+ ## License
129
+
130
+ MC-APRS is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
@@ -0,0 +1,79 @@
1
+ [build-system]
2
+ requires = ["hatchling >= 1.26.1"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "mc-aprs"
7
+ dynamic = ["version"]
8
+ description = 'A MeshCore-APRS Gateway'
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ #license = "MIT"
12
+ license-files = { paths = ["LICENSE"] }
13
+ keywords = [
14
+ "aprs",
15
+ "aprs-gateway",
16
+ "aprs-is",
17
+ "gateway",
18
+ "lora",
19
+ "lora-gateway",
20
+ "meshcore",
21
+ "meshcore-gateway",
22
+ ]
23
+ authors = [
24
+ { name = "Adam Fourney", email = "adam.fourney@gmail.com" },
25
+ ]
26
+ classifiers = [
27
+ "Development Status :: 4 - Beta",
28
+ "Topic :: Communications :: Ham Radio",
29
+ "Programming Language :: Python",
30
+ "Programming Language :: Python :: 3.10",
31
+ "Programming Language :: Python :: 3.11",
32
+ "Programming Language :: Python :: 3.12",
33
+ "Programming Language :: Python :: Implementation :: CPython",
34
+ "Programming Language :: Python :: Implementation :: PyPy",
35
+ ]
36
+ dependencies = [
37
+ "meshcore",
38
+ "aprslib",
39
+ "PyYAML",
40
+ "requests",
41
+ "packaging",
42
+ ]
43
+
44
+ [project.urls]
45
+ Documentation = "https://github.com/Mambo430/MC-APRS#readme"
46
+ Issues = "https://github.com/Mambo430/MC-APRS/issues"
47
+ Source = "https://github.com/Mambo430/MC-APRS"
48
+
49
+ [tool.hatch.version]
50
+ path = "src/mc_aprs/__about__.py"
51
+
52
+ [tool.hatch.envs.types]
53
+ extra-dependencies = [
54
+ "mypy>=1.0.0",
55
+ ]
56
+ [tool.hatch.envs.types.scripts]
57
+ check = "mypy --install-types --ignore-missing-imports --non-interactive {args:src/mc_aprs tests}"
58
+
59
+ [tool.coverage.run]
60
+ source_pkgs = ["mc_aprs", "tests"]
61
+ branch = true
62
+ parallel = true
63
+ omit = [
64
+ "src/mc_aprs/__about__.py",
65
+ ]
66
+
67
+ [tool.coverage.paths]
68
+ mc_aprs = ["src/mc_aprs", "*/mc_aprs/src/mc_aprs"]
69
+ tests = ["tests", "*/MC-APRS/tests"]
70
+
71
+ [tool.coverage.report]
72
+ exclude_lines = [
73
+ "no cov",
74
+ "if __name__ == .__main__.:",
75
+ "if TYPE_CHECKING:",
76
+ ]
77
+
78
+ [tool.hatch.build.targets.sdist]
79
+ only-include = ["src/mc_aprs"]
@@ -0,0 +1,4 @@
1
+ # SPDX-FileCopyrightText: 2024-present Adam Fourney <adam.fourney@gmail.com>
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ __version__ = "0.0.1a26"
@@ -0,0 +1,3 @@
1
+ # SPDX-FileCopyrightText: 2024-present Adam Fourney <adam.fourney@gmail.com>
2
+ #
3
+ # SPDX-License-Identifier: MIT
@@ -0,0 +1,69 @@
1
+ # SPDX-FileCopyrightText: 2024-present Adam Fourney <adam.fourney@gmail.com>
2
+ #
3
+ # SPDX-License-Identifier: MIT
4
+ import logging
5
+ import yaml
6
+ import os
7
+ import sys
8
+ import traceback
9
+ from logging.handlers import TimedRotatingFileHandler
10
+ from ._config import init_config, ConfigError
11
+ from ._gateway import Gateway
12
+
13
+ # Set up logging
14
+ ################
15
+ LOG_FORMAT = "[%(asctime)s] %(levelname)s:%(name)s:%(message)s"
16
+ logger = logging.getLogger("mc_aprs")
17
+ logging.root.setLevel(logging.DEBUG)
18
+
19
+
20
+ class LocalDebugFilter(logging.Filter):
21
+ """
22
+ Only show debug messages from MC-APRS.
23
+ """
24
+
25
+ def filter(self, record):
26
+ if record.name == "mc_aprs" or record.name.startswith("mc_aprs."):
27
+ return True
28
+ else:
29
+ return record.levelno > logging.DEBUG
30
+
31
+
32
+ stream_handler = logging.StreamHandler()
33
+ stream_handler.setFormatter(logging.Formatter(LOG_FORMAT))
34
+ stream_handler.addFilter(LocalDebugFilter())
35
+ logging.root.addHandler(stream_handler)
36
+ logging.captureWarnings(True)
37
+
38
+ # Load the configuration
39
+ config = None
40
+ try:
41
+ config = init_config()
42
+ except ConfigError as e:
43
+ sys.stderr.write(str(e).rstrip() + "\n")
44
+ sys.exit(1)
45
+
46
+ # Configure file logs
47
+ logs_dir = config.get("logs_dir")
48
+ if logs_dir is not None:
49
+ log_file = os.path.join(logs_dir, "mc-aprs.log")
50
+ logger.debug(f"Writing logs to: {log_file}")
51
+ file_handler = TimedRotatingFileHandler(
52
+ log_file, when="d", interval=1, backupCount=7
53
+ )
54
+ file_handler.setFormatter(logging.Formatter(LOG_FORMAT))
55
+ file_handler.addFilter(LocalDebugFilter())
56
+ logging.root.addHandler(file_handler)
57
+
58
+ # Start the gateway. Log any errors, and exit cleanly
59
+ gateway = None
60
+ try:
61
+ gateway = Gateway(config)
62
+ gateway.run()
63
+ except:
64
+ logger.error(traceback.format_exc())
65
+ raise
66
+ finally:
67
+ if gateway is not None:
68
+ gateway.close()
69
+ logging.shutdown()