base-aprs-client 0.0.1__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.
- base_aprs_client-0.0.1/.github/workflows/ci.yml +37 -0
- base_aprs_client-0.0.1/.github/workflows/publish.yml +20 -0
- base_aprs_client-0.0.1/.gitignore +129 -0
- base_aprs_client-0.0.1/LICENSE +21 -0
- base_aprs_client-0.0.1/PKG-INFO +193 -0
- base_aprs_client-0.0.1/README.md +142 -0
- base_aprs_client-0.0.1/examples/aprs_net/.gitignore +8 -0
- base_aprs_client-0.0.1/examples/aprs_net/README.md +93 -0
- base_aprs_client-0.0.1/examples/aprs_net/aprs_net/__init__.py +0 -0
- base_aprs_client-0.0.1/examples/aprs_net/aprs_net/aprs_net.py +701 -0
- base_aprs_client-0.0.1/examples/aprs_net/aprs_net/net.py +617 -0
- base_aprs_client-0.0.1/examples/aprs_net/aprs_net/state.py +436 -0
- base_aprs_client-0.0.1/examples/aprs_net/pyproject.toml +18 -0
- base_aprs_client-0.0.1/examples/aprs_net/rxconfig.py +9 -0
- base_aprs_client-0.0.1/examples/aprs_net/screenshot-net.png +0 -0
- base_aprs_client-0.0.1/examples/aprs_net/screenshot-setup.png +0 -0
- base_aprs_client-0.0.1/examples/aprs_net/uv.lock +980 -0
- base_aprs_client-0.0.1/examples/chat.py +91 -0
- base_aprs_client-0.0.1/examples/send_message.py +88 -0
- base_aprs_client-0.0.1/pyproject.toml +91 -0
- base_aprs_client-0.0.1/setup.cfg +4 -0
- base_aprs_client-0.0.1/src/base_aprs_client/__init__.py +55 -0
- base_aprs_client-0.0.1/src/base_aprs_client/aio.py +730 -0
- base_aprs_client-0.0.1/src/base_aprs_client/client.py +482 -0
- base_aprs_client-0.0.1/src/base_aprs_client/common.py +99 -0
- base_aprs_client-0.0.1/src/base_aprs_client/py.typed +0 -0
- base_aprs_client-0.0.1/src/base_aprs_client/simulator.py +190 -0
- base_aprs_client-0.0.1/src/base_aprs_client/store.py +321 -0
- base_aprs_client-0.0.1/src/base_aprs_client.egg-info/PKG-INFO +193 -0
- base_aprs_client-0.0.1/src/base_aprs_client.egg-info/SOURCES.txt +45 -0
- base_aprs_client-0.0.1/src/base_aprs_client.egg-info/dependency_links.txt +1 -0
- base_aprs_client-0.0.1/src/base_aprs_client.egg-info/requires.txt +8 -0
- base_aprs_client-0.0.1/src/base_aprs_client.egg-info/scm_file_list.json +42 -0
- base_aprs_client-0.0.1/src/base_aprs_client.egg-info/scm_version.json +8 -0
- base_aprs_client-0.0.1/src/base_aprs_client.egg-info/top_level.txt +1 -0
- base_aprs_client-0.0.1/tests/__init__.py +0 -0
- base_aprs_client-0.0.1/tests/conftest.py +48 -0
- base_aprs_client-0.0.1/tests/fakes.py +47 -0
- base_aprs_client-0.0.1/tests/test_aio.py +422 -0
- base_aprs_client-0.0.1/tests/test_aprs_net.py +284 -0
- base_aprs_client-0.0.1/tests/test_client.py +109 -0
- base_aprs_client-0.0.1/tests/test_e2e.py +264 -0
- base_aprs_client-0.0.1/tests/test_examples.py +108 -0
- base_aprs_client-0.0.1/tests/test_kiss.py +174 -0
- base_aprs_client-0.0.1/tests/test_simulator.py +65 -0
- base_aprs_client-0.0.1/tests/test_store.py +183 -0
- base_aprs_client-0.0.1/uv.lock +705 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
lint:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
with:
|
|
14
|
+
fetch-depth: 0 # setuptools_scm needs tags
|
|
15
|
+
- uses: astral-sh/setup-uv@v6
|
|
16
|
+
- run: uv sync --locked --all-extras
|
|
17
|
+
- run: uv run ruff check
|
|
18
|
+
- run: uv run ruff format --check
|
|
19
|
+
- run: uv run ty check
|
|
20
|
+
|
|
21
|
+
test:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
strategy:
|
|
24
|
+
fail-fast: false
|
|
25
|
+
matrix:
|
|
26
|
+
python-version: ["3.11", "3.12", "3.13", "3.14"]
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
with:
|
|
30
|
+
fetch-depth: 0 # setuptools_scm needs tags
|
|
31
|
+
- uses: astral-sh/setup-uv@v6
|
|
32
|
+
with:
|
|
33
|
+
python-version: ${{ matrix.python-version }}
|
|
34
|
+
- name: Install Dire Wolf (for the KISS TCP tests)
|
|
35
|
+
run: sudo apt-get update && sudo apt-get install -y direwolf
|
|
36
|
+
- run: uv sync --locked --all-extras
|
|
37
|
+
- run: uv run pytest
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
name: Upload Python Package
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [created]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
deploy:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
environment: pypi
|
|
11
|
+
permissions:
|
|
12
|
+
# PyPI trusted publishing (OIDC); no API token needed
|
|
13
|
+
id-token: write
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
with:
|
|
17
|
+
fetch-depth: 0 # setuptools_scm needs tags
|
|
18
|
+
- uses: astral-sh/setup-uv@v6
|
|
19
|
+
- run: uv build
|
|
20
|
+
- run: uv publish --trusted-publishing always
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
pip-wheel-metadata/
|
|
24
|
+
share/python-wheels/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
.installed.cfg
|
|
27
|
+
*.egg
|
|
28
|
+
MANIFEST
|
|
29
|
+
|
|
30
|
+
# PyInstaller
|
|
31
|
+
# Usually these files are written by a python script from a template
|
|
32
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
33
|
+
*.manifest
|
|
34
|
+
*.spec
|
|
35
|
+
|
|
36
|
+
# Installer logs
|
|
37
|
+
pip-log.txt
|
|
38
|
+
pip-delete-this-directory.txt
|
|
39
|
+
|
|
40
|
+
# Unit test / coverage reports
|
|
41
|
+
htmlcov/
|
|
42
|
+
.tox/
|
|
43
|
+
.nox/
|
|
44
|
+
.coverage
|
|
45
|
+
.coverage.*
|
|
46
|
+
.cache
|
|
47
|
+
nosetests.xml
|
|
48
|
+
coverage.xml
|
|
49
|
+
*.cover
|
|
50
|
+
*.py,cover
|
|
51
|
+
.hypothesis/
|
|
52
|
+
.pytest_cache/
|
|
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
|
+
target/
|
|
76
|
+
|
|
77
|
+
# Jupyter Notebook
|
|
78
|
+
.ipynb_checkpoints
|
|
79
|
+
|
|
80
|
+
# IPython
|
|
81
|
+
profile_default/
|
|
82
|
+
ipython_config.py
|
|
83
|
+
|
|
84
|
+
# pyenv
|
|
85
|
+
.python-version
|
|
86
|
+
|
|
87
|
+
# pipenv
|
|
88
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
89
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
90
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
91
|
+
# install all needed dependencies.
|
|
92
|
+
#Pipfile.lock
|
|
93
|
+
|
|
94
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
|
95
|
+
__pypackages__/
|
|
96
|
+
|
|
97
|
+
# Celery stuff
|
|
98
|
+
celerybeat-schedule
|
|
99
|
+
celerybeat.pid
|
|
100
|
+
|
|
101
|
+
# SageMath parsed files
|
|
102
|
+
*.sage.py
|
|
103
|
+
|
|
104
|
+
# Environments
|
|
105
|
+
.env
|
|
106
|
+
.venv
|
|
107
|
+
env/
|
|
108
|
+
venv/
|
|
109
|
+
ENV/
|
|
110
|
+
env.bak/
|
|
111
|
+
venv.bak/
|
|
112
|
+
|
|
113
|
+
# Spyder project settings
|
|
114
|
+
.spyderproject
|
|
115
|
+
.spyproject
|
|
116
|
+
|
|
117
|
+
# Rope project settings
|
|
118
|
+
.ropeproject
|
|
119
|
+
|
|
120
|
+
# mkdocs documentation
|
|
121
|
+
/site
|
|
122
|
+
|
|
123
|
+
# mypy
|
|
124
|
+
.mypy_cache/
|
|
125
|
+
.dmypy.json
|
|
126
|
+
dmypy.json
|
|
127
|
+
|
|
128
|
+
# Pyre type checker
|
|
129
|
+
.pyre/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 python-aprs
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: base-aprs-client
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Base layer for building more complex APRS interactions with python.
|
|
5
|
+
Author-email: Masen Furer KF7HVM <kf7hvm@0x26.net>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2022 python-aprs
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/python-aprs/base-aprs-client
|
|
29
|
+
Keywords: Ham Radio,APRS
|
|
30
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
31
|
+
Classifier: Topic :: Communications :: Ham Radio
|
|
32
|
+
Classifier: Framework :: AsyncIO
|
|
33
|
+
Classifier: Programming Language :: Python
|
|
34
|
+
Classifier: Programming Language :: Python :: 3
|
|
35
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
40
|
+
Requires-Python: >=3.11
|
|
41
|
+
Description-Content-Type: text/markdown
|
|
42
|
+
License-File: LICENSE
|
|
43
|
+
Requires-Dist: aprs3>=8.2.0
|
|
44
|
+
Requires-Dist: ax253>=0.2.1
|
|
45
|
+
Requires-Dist: kiss3>=8.1.1
|
|
46
|
+
Requires-Dist: attrs>20
|
|
47
|
+
Provides-Extra: db
|
|
48
|
+
Requires-Dist: aiosqlite>=0.20; extra == "db"
|
|
49
|
+
Requires-Dist: sqlalchemy[asyncio]>=2.0.30; extra == "db"
|
|
50
|
+
Dynamic: license-file
|
|
51
|
+
|
|
52
|
+
# base-aprs-client
|
|
53
|
+
|
|
54
|
+
Base layer for building APRS client applications in Python, on top of
|
|
55
|
+
[aprs3](https://github.com/python-aprs/aprs3),
|
|
56
|
+
[kiss3](https://github.com/python-aprs/kiss3) and
|
|
57
|
+
[ax253](https://github.com/python-aprs/ax253).
|
|
58
|
+
|
|
59
|
+
`AsyncClient` (asyncio) and `Client` (its synchronous wrapper) implement
|
|
60
|
+
the APRS station semantics that every application needs:
|
|
61
|
+
|
|
62
|
+
* sending messages, with acknowledgement and timed retries
|
|
63
|
+
* acknowledging incoming messages addressed to `mycall`, and delivering
|
|
64
|
+
each one once even when the sender retries
|
|
65
|
+
* [reply-acks](http://www.aprs.org/aprs11/replyacks.txt), on by default
|
|
66
|
+
* splitting long messages on word boundaries, or truncating them
|
|
67
|
+
* sending status and position reports
|
|
68
|
+
* reconnecting with backoff when the connection drops, keeping
|
|
69
|
+
unacknowledged messages
|
|
70
|
+
* with a `PacketStore`, logging every frame and sending queued frames when
|
|
71
|
+
they are due, even across restarts
|
|
72
|
+
|
|
73
|
+
It works over APRS-IS, KISS-over-TCP (e.g. Dire Wolf) or a serial KISS TNC.
|
|
74
|
+
|
|
75
|
+
## Example
|
|
76
|
+
|
|
77
|
+
```python
|
|
78
|
+
import asyncio
|
|
79
|
+
from base_aprs_client import AsyncClient
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
async def main():
|
|
83
|
+
async with AsyncClient.aprsis(
|
|
84
|
+
"N0CALL-1",
|
|
85
|
+
passcode="-1", # use a real passcode to transmit
|
|
86
|
+
filter="r/46.1/-122.9/50",
|
|
87
|
+
) as client:
|
|
88
|
+
client.send_status("Hello from base-aprs-client")
|
|
89
|
+
await client.send_message("N0CALL-2", "hi", ack=True) # waits for the ack
|
|
90
|
+
async for frame in client:
|
|
91
|
+
print(frame)
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
asyncio.run(main())
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The synchronous `Client` runs the same client on a background thread:
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from base_aprs_client import Client
|
|
101
|
+
|
|
102
|
+
with Client.kiss_tcp("N0CALL-1", "localhost", 8001) as client:
|
|
103
|
+
ack = client.send_message("N0CALL-2", "hi", ack=True)
|
|
104
|
+
print(ack.result(timeout=60))
|
|
105
|
+
for frame in client.read(min_frames=1):
|
|
106
|
+
print(frame)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`Client(mycall, sync_frame_io)` with an already started `aprs.TCP`,
|
|
110
|
+
`aprs.TCPKISS` or `aprs.SerialKISS` still works as before; its event loop
|
|
111
|
+
only runs inside the client's calls.
|
|
112
|
+
|
|
113
|
+
## Local testing without a radio
|
|
114
|
+
|
|
115
|
+
`APRSISSimulator` is a tiny APRS-IS-like relay: every line one client sends
|
|
116
|
+
is forwarded to all the others.
|
|
117
|
+
|
|
118
|
+
```python
|
|
119
|
+
from aprs import TCP
|
|
120
|
+
from base_aprs_client import APRSISSimulator, Client
|
|
121
|
+
|
|
122
|
+
with APRSISSimulator() as sim:
|
|
123
|
+
with TCP(host=sim.host, port=sim.port) as t1, TCP(host=sim.host, port=sim.port) as t2:
|
|
124
|
+
sim.wait_for_clients(2)
|
|
125
|
+
alice = Client("N0CALL-1", t1)
|
|
126
|
+
bob = Client("N0CALL-2", t2)
|
|
127
|
+
alice.send_message(bob.mycall, "hi bob")
|
|
128
|
+
print(bob.read(min_frames=1))
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Run it standalone on port 14588 with `python -m base_aprs_client.simulator`.
|
|
132
|
+
|
|
133
|
+
## Examples
|
|
134
|
+
|
|
135
|
+
The [examples](examples) directory has two scripts that work over APRS-IS
|
|
136
|
+
(`--aprsis host:port`), a KISS TNC on TCP (`--tcp host:port`) or a serial
|
|
137
|
+
TNC (`--serial device`):
|
|
138
|
+
|
|
139
|
+
* `send_message.py` sends one message and waits for the ack, splitting long
|
|
140
|
+
text into parts. It uses `Client`.
|
|
141
|
+
* `chat.py` is a terminal chat: each line you type goes to `--to`, and
|
|
142
|
+
messages addressed to you are printed as they arrive. It uses
|
|
143
|
+
`AsyncClient`.
|
|
144
|
+
|
|
145
|
+
Start `python -m base_aprs_client.simulator` and point two copies of
|
|
146
|
+
`chat.py` at `--aprsis localhost:14588` to try them without a radio.
|
|
147
|
+
|
|
148
|
+
## Packet log and send queue
|
|
149
|
+
|
|
150
|
+
`base_aprs_client.store.PacketStore` keeps a log of frames heard and sent,
|
|
151
|
+
and a queue of frames to transmit later. It uses SQLAlchemy 2.0 with an
|
|
152
|
+
async session, so it never blocks the event loop; SQLite through aiosqlite
|
|
153
|
+
is the default, and any async SQLAlchemy URL works. Install with
|
|
154
|
+
`pip install base-aprs-client[db]`.
|
|
155
|
+
|
|
156
|
+
Give it to a client to log everything it hears and sends, and to transmit
|
|
157
|
+
frames scheduled with `client.schedule(frame, delay=...)`:
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
from aprs import InformationField
|
|
161
|
+
from base_aprs_client import AsyncClient
|
|
162
|
+
from base_aprs_client.store import PacketStore
|
|
163
|
+
|
|
164
|
+
async with PacketStore("sqlite+aiosqlite:///N0CALL.db") as store:
|
|
165
|
+
async with AsyncClient.aprsis("N0CALL-1", passcode="12345", store=store) as client:
|
|
166
|
+
await client.schedule(InformationField.from_bytes(b">QRT soon"), delay=600)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
The store can also be used on its own:
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
from base_aprs_client.store import PacketStore
|
|
173
|
+
|
|
174
|
+
async with PacketStore("sqlite+aiosqlite:///N0CALL.db") as store:
|
|
175
|
+
await store.record_received(frame)
|
|
176
|
+
await store.schedule(reply, delay=10)
|
|
177
|
+
for record in await store.due():
|
|
178
|
+
if await store.claim(record): # False if another task already sent it
|
|
179
|
+
transport.write(record.frame)
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
## Development
|
|
183
|
+
|
|
184
|
+
```
|
|
185
|
+
uv sync --all-extras
|
|
186
|
+
uv run pytest
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
CI runs the suite on every supported Python (3.11+). The KISS tests run a
|
|
190
|
+
serial TNC on a pseudo-terminal, and send through
|
|
191
|
+
[Dire Wolf](https://github.com/wb2osz/direwolf) when it is installed
|
|
192
|
+
(`apt install direwolf`); they are skipped otherwise. Lint and format with
|
|
193
|
+
`uv run ruff check` and `uv run ruff format`, type-check with `uv run ty check`.
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# base-aprs-client
|
|
2
|
+
|
|
3
|
+
Base layer for building APRS client applications in Python, on top of
|
|
4
|
+
[aprs3](https://github.com/python-aprs/aprs3),
|
|
5
|
+
[kiss3](https://github.com/python-aprs/kiss3) and
|
|
6
|
+
[ax253](https://github.com/python-aprs/ax253).
|
|
7
|
+
|
|
8
|
+
`AsyncClient` (asyncio) and `Client` (its synchronous wrapper) implement
|
|
9
|
+
the APRS station semantics that every application needs:
|
|
10
|
+
|
|
11
|
+
* sending messages, with acknowledgement and timed retries
|
|
12
|
+
* acknowledging incoming messages addressed to `mycall`, and delivering
|
|
13
|
+
each one once even when the sender retries
|
|
14
|
+
* [reply-acks](http://www.aprs.org/aprs11/replyacks.txt), on by default
|
|
15
|
+
* splitting long messages on word boundaries, or truncating them
|
|
16
|
+
* sending status and position reports
|
|
17
|
+
* reconnecting with backoff when the connection drops, keeping
|
|
18
|
+
unacknowledged messages
|
|
19
|
+
* with a `PacketStore`, logging every frame and sending queued frames when
|
|
20
|
+
they are due, even across restarts
|
|
21
|
+
|
|
22
|
+
It works over APRS-IS, KISS-over-TCP (e.g. Dire Wolf) or a serial KISS TNC.
|
|
23
|
+
|
|
24
|
+
## Example
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
import asyncio
|
|
28
|
+
from base_aprs_client import AsyncClient
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
async def main():
|
|
32
|
+
async with AsyncClient.aprsis(
|
|
33
|
+
"N0CALL-1",
|
|
34
|
+
passcode="-1", # use a real passcode to transmit
|
|
35
|
+
filter="r/46.1/-122.9/50",
|
|
36
|
+
) as client:
|
|
37
|
+
client.send_status("Hello from base-aprs-client")
|
|
38
|
+
await client.send_message("N0CALL-2", "hi", ack=True) # waits for the ack
|
|
39
|
+
async for frame in client:
|
|
40
|
+
print(frame)
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
asyncio.run(main())
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
The synchronous `Client` runs the same client on a background thread:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from base_aprs_client import Client
|
|
50
|
+
|
|
51
|
+
with Client.kiss_tcp("N0CALL-1", "localhost", 8001) as client:
|
|
52
|
+
ack = client.send_message("N0CALL-2", "hi", ack=True)
|
|
53
|
+
print(ack.result(timeout=60))
|
|
54
|
+
for frame in client.read(min_frames=1):
|
|
55
|
+
print(frame)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`Client(mycall, sync_frame_io)` with an already started `aprs.TCP`,
|
|
59
|
+
`aprs.TCPKISS` or `aprs.SerialKISS` still works as before; its event loop
|
|
60
|
+
only runs inside the client's calls.
|
|
61
|
+
|
|
62
|
+
## Local testing without a radio
|
|
63
|
+
|
|
64
|
+
`APRSISSimulator` is a tiny APRS-IS-like relay: every line one client sends
|
|
65
|
+
is forwarded to all the others.
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from aprs import TCP
|
|
69
|
+
from base_aprs_client import APRSISSimulator, Client
|
|
70
|
+
|
|
71
|
+
with APRSISSimulator() as sim:
|
|
72
|
+
with TCP(host=sim.host, port=sim.port) as t1, TCP(host=sim.host, port=sim.port) as t2:
|
|
73
|
+
sim.wait_for_clients(2)
|
|
74
|
+
alice = Client("N0CALL-1", t1)
|
|
75
|
+
bob = Client("N0CALL-2", t2)
|
|
76
|
+
alice.send_message(bob.mycall, "hi bob")
|
|
77
|
+
print(bob.read(min_frames=1))
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Run it standalone on port 14588 with `python -m base_aprs_client.simulator`.
|
|
81
|
+
|
|
82
|
+
## Examples
|
|
83
|
+
|
|
84
|
+
The [examples](examples) directory has two scripts that work over APRS-IS
|
|
85
|
+
(`--aprsis host:port`), a KISS TNC on TCP (`--tcp host:port`) or a serial
|
|
86
|
+
TNC (`--serial device`):
|
|
87
|
+
|
|
88
|
+
* `send_message.py` sends one message and waits for the ack, splitting long
|
|
89
|
+
text into parts. It uses `Client`.
|
|
90
|
+
* `chat.py` is a terminal chat: each line you type goes to `--to`, and
|
|
91
|
+
messages addressed to you are printed as they arrive. It uses
|
|
92
|
+
`AsyncClient`.
|
|
93
|
+
|
|
94
|
+
Start `python -m base_aprs_client.simulator` and point two copies of
|
|
95
|
+
`chat.py` at `--aprsis localhost:14588` to try them without a radio.
|
|
96
|
+
|
|
97
|
+
## Packet log and send queue
|
|
98
|
+
|
|
99
|
+
`base_aprs_client.store.PacketStore` keeps a log of frames heard and sent,
|
|
100
|
+
and a queue of frames to transmit later. It uses SQLAlchemy 2.0 with an
|
|
101
|
+
async session, so it never blocks the event loop; SQLite through aiosqlite
|
|
102
|
+
is the default, and any async SQLAlchemy URL works. Install with
|
|
103
|
+
`pip install base-aprs-client[db]`.
|
|
104
|
+
|
|
105
|
+
Give it to a client to log everything it hears and sends, and to transmit
|
|
106
|
+
frames scheduled with `client.schedule(frame, delay=...)`:
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from aprs import InformationField
|
|
110
|
+
from base_aprs_client import AsyncClient
|
|
111
|
+
from base_aprs_client.store import PacketStore
|
|
112
|
+
|
|
113
|
+
async with PacketStore("sqlite+aiosqlite:///N0CALL.db") as store:
|
|
114
|
+
async with AsyncClient.aprsis("N0CALL-1", passcode="12345", store=store) as client:
|
|
115
|
+
await client.schedule(InformationField.from_bytes(b">QRT soon"), delay=600)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The store can also be used on its own:
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
from base_aprs_client.store import PacketStore
|
|
122
|
+
|
|
123
|
+
async with PacketStore("sqlite+aiosqlite:///N0CALL.db") as store:
|
|
124
|
+
await store.record_received(frame)
|
|
125
|
+
await store.schedule(reply, delay=10)
|
|
126
|
+
for record in await store.due():
|
|
127
|
+
if await store.claim(record): # False if another task already sent it
|
|
128
|
+
transport.write(record.frame)
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Development
|
|
132
|
+
|
|
133
|
+
```
|
|
134
|
+
uv sync --all-extras
|
|
135
|
+
uv run pytest
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
CI runs the suite on every supported Python (3.11+). The KISS tests run a
|
|
139
|
+
serial TNC on a pseudo-terminal, and send through
|
|
140
|
+
[Dire Wolf](https://github.com/wb2osz/direwolf) when it is installed
|
|
141
|
+
(`apt install direwolf`); they are skipped otherwise. Lint and format with
|
|
142
|
+
`uv run ruff check` and `uv run ruff format`, type-check with `uv run ty check`.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# APRS Net Control
|
|
2
|
+
|
|
3
|
+
A web app for running an APRS net, built with [Reflex](https://reflex.dev) on
|
|
4
|
+
`base-aprs-client`.
|
|
5
|
+
|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
Stations check in by sending any APRS message to net control. Each new
|
|
9
|
+
station gets one reply ("ACK N0CALL, thanks for checking in to Tuesday Night
|
|
10
|
+
Net"). A check-in that names other callsigns ("checking in with N7DEM") logs
|
|
11
|
+
those stations too. From the page you can:
|
|
12
|
+
|
|
13
|
+
* watch check-ins arrive, with each station's last position when it beacons
|
|
14
|
+
* log check-ins by hand, as voice or APRS (counted separately). Voice
|
|
15
|
+
check-ins are announced in a status ("Voice check-ins: W1AW N7DEM ..."),
|
|
16
|
+
sent once when it fills APRS's 62-character status limit, or when you
|
|
17
|
+
press Send now or close the net. Leave the callsign blank, or type `??`,
|
|
18
|
+
for a station you couldn't copy: it's logged but never announced. The
|
|
19
|
+
megaphone on each row leaves a station out of the status
|
|
20
|
+
* edit or remove check-ins, and record the net control station (NCS)
|
|
21
|
+
* relay an announcement from a station as a status ("W1AW: ...")
|
|
22
|
+
* send messages, see when they're acked, and cancel one still sending. Unacked messages are resent
|
|
23
|
+
gently: 3 tries, 5 minutes apart, by default (both settable)
|
|
24
|
+
* send a bulletin, status and position beacon (with its own text) when the net opens and then on
|
|
25
|
+
a timer. The bulletin can be changed, and switched off and on, while the
|
|
26
|
+
net runs
|
|
27
|
+
* see every packet heard and sent
|
|
28
|
+
* close the net, which sends a summary status with the end time in the
|
|
29
|
+
server's time zone ("Tuesday Night Net closed 20:15 PST with 12
|
|
30
|
+
check-ins"), and download the check-ins as CSV
|
|
31
|
+
|
|
32
|
+
Each browser keeps a copy of the net's settings and check-ins in
|
|
33
|
+
localStorage. If the server stops mid-net, restart it and the page offers to
|
|
34
|
+
reopen the net with the saved check-ins.
|
|
35
|
+
|
|
36
|
+
It connects to APRS-IS, a KISS TNC on TCP (Dire Wolf listens on
|
|
37
|
+
`localhost:8001`), or a serial KISS TNC.
|
|
38
|
+
|
|
39
|
+
## Running it
|
|
40
|
+
|
|
41
|
+
The app is its own [uv](https://docs.astral.sh/uv/) project, with its
|
|
42
|
+
dependencies locked in `uv.lock` and `base-aprs-client` installed from this
|
|
43
|
+
checkout:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
cd examples/aprs_net
|
|
47
|
+
uv run reflex run
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The first run creates `.venv` and builds the frontend, which takes a minute.
|
|
51
|
+
|
|
52
|
+
Then open http://localhost:3000, enter your callsign and connection, and
|
|
53
|
+
open the net. To transmit through APRS-IS you need the passcode for your
|
|
54
|
+
callsign. With `-1` the net can hear check-ins but its replies are dropped by
|
|
55
|
+
the server.
|
|
56
|
+
|
|
57
|
+

|
|
58
|
+
|
|
59
|
+
Each browser remembers the settings of the last net it opened and fills
|
|
60
|
+
them in next time. To fill in the form ahead of time on any browser, set
|
|
61
|
+
`APRS_NET_*` environment variables, one per form field: `APRS_NET_CALL`,
|
|
62
|
+
`APRS_NET_CONNECTION` (`aprsis`, `kiss_tcp` or `kiss_serial`),
|
|
63
|
+
`APRS_NET_ADDRESS`, `APRS_NET_PASSCODE`, `APRS_NET_NAME`,
|
|
64
|
+
`APRS_NET_BEACON_COMMENT` and so on. The **Environment variables** button
|
|
65
|
+
shows the current settings as `export` lines to copy. Settings remembered by
|
|
66
|
+
the browser take precedence over the environment.
|
|
67
|
+
|
|
68
|
+
### Trying it without a radio
|
|
69
|
+
|
|
70
|
+
Run the local APRS-IS relay, and point the app at it:
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
uv run python -m base_aprs_client.simulator &
|
|
74
|
+
APRS_NET_CALL=N0CALL-10 APRS_NET_ADDRESS=localhost:14588 uv run reflex run
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Then check in from another terminal with the chat example:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
uv run python ../chat.py --call N0CALL-1 --to N0CALL-10 --aprsis localhost:14588
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## How it's put together
|
|
84
|
+
|
|
85
|
+
* `aprs_net/net.py` has the net logic and no web code: `Net` wraps an
|
|
86
|
+
`AsyncClient`, answers check-ins, runs the timers, and counts changes in
|
|
87
|
+
`version`. `tests/test_aprs_net.py` tests it against the simulator.
|
|
88
|
+
* `aprs_net/state.py` is the Reflex state. The one `Net` lives at module
|
|
89
|
+
level, since the server is one radio station shared by every open page.
|
|
90
|
+
Each page polls it once a second and copies it into its state when
|
|
91
|
+
`version` changes. Run the backend with a single worker so every page sees
|
|
92
|
+
the same net.
|
|
93
|
+
* `aprs_net/aprs_net.py` is the page.
|
|
File without changes
|