2016-02-28 11:35:10 +00:00
|
|
|
# python-ogn-client
|
2016-02-28 11:11:16 +00:00
|
|
|
|
2017-09-15 19:28:01 +00:00
|
|
|
[](https://travis-ci.org/glidernet/python-ogn-client)
|
|
|
|
[](https://pypi.python.org/pypi/ogn-client)
|
|
|
|
[](https://coveralls.io/github/glidernet/python-ogn-client?branch=master)
|
2016-02-28 11:11:16 +00:00
|
|
|
|
2016-02-28 11:35:10 +00:00
|
|
|
A python3 module for the [Open Glider Network](http://wiki.glidernet.org/).
|
|
|
|
It can be used to connect to the OGN-APRS-Servers and to parse APRS-/OGN-Messages.
|
2016-02-28 11:11:16 +00:00
|
|
|
|
2016-03-18 20:27:42 +00:00
|
|
|
A full featured gateway with build-in database is provided by [ogn-python](https://github.com/glidernet/ogn-python).
|
2016-02-28 11:11:16 +00:00
|
|
|
|
|
|
|
|
2017-12-02 09:33:45 +00:00
|
|
|
## Installation
|
|
|
|
|
|
|
|
python-ogn-client is available at PyPI. So for installation simply use pip:
|
|
|
|
|
|
|
|
```
|
|
|
|
pip install ogn-client
|
|
|
|
```
|
|
|
|
|
2016-02-28 11:35:10 +00:00
|
|
|
## Example Usage
|
2016-02-28 11:11:16 +00:00
|
|
|
|
2019-09-07 14:26:32 +00:00
|
|
|
### Parse APRS/OGN packet.
|
2016-02-28 11:11:16 +00:00
|
|
|
|
2020-07-22 11:23:58 +00:00
|
|
|
```python
|
2017-09-30 16:25:24 +00:00
|
|
|
from ogn.parser import parse
|
2018-05-03 05:47:38 +00:00
|
|
|
from datetime import datetime
|
2016-02-28 11:35:10 +00:00
|
|
|
|
2017-09-30 16:25:24 +00:00
|
|
|
beacon = parse("FLRDDDEAD>APRS,qAS,EDER:/114500h5029.86N/00956.98E'342/049/A=005524 id0ADDDEAD -454fpm -1.1rot 8.8dB 0e +51.2kHz gps4x5",
|
2018-05-03 05:47:38 +00:00
|
|
|
reference_timestamp=datetime(2015, 07, 31, 12, 34, 56))
|
2016-02-28 11:35:10 +00:00
|
|
|
```
|
|
|
|
|
2019-09-07 14:26:32 +00:00
|
|
|
### Connect to OGN and display all incoming beacons.
|
2016-02-28 11:35:10 +00:00
|
|
|
|
2020-07-22 11:23:58 +00:00
|
|
|
```python
|
2016-03-08 01:31:17 +00:00
|
|
|
from ogn.client import AprsClient
|
2017-09-30 16:25:24 +00:00
|
|
|
from ogn.parser import parse, ParseError
|
2016-02-28 11:11:16 +00:00
|
|
|
|
|
|
|
def process_beacon(raw_message):
|
|
|
|
try:
|
2017-09-30 16:25:24 +00:00
|
|
|
beacon = parse(raw_message)
|
2018-09-29 21:19:01 +00:00
|
|
|
print('Received {aprs_type}: {raw_message}'.format(**beacon))
|
2016-02-28 11:11:16 +00:00
|
|
|
except ParseError as e:
|
|
|
|
print('Error, {}'.format(e.message))
|
|
|
|
|
2016-03-08 01:31:17 +00:00
|
|
|
client = AprsClient(aprs_user='N0CALL')
|
2016-02-28 11:35:10 +00:00
|
|
|
client.connect()
|
2016-02-28 11:11:16 +00:00
|
|
|
|
2016-02-28 11:35:10 +00:00
|
|
|
try:
|
|
|
|
client.run(callback=process_beacon, autoreconnect=True)
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
print('\nStop ogn gateway')
|
|
|
|
client.disconnect()
|
2016-02-28 11:11:16 +00:00
|
|
|
```
|
|
|
|
|
2019-09-07 14:26:32 +00:00
|
|
|
### Connect to telnet console and display all decoded beacons.
|
|
|
|
|
2020-07-22 11:23:58 +00:00
|
|
|
```python
|
2019-09-07 14:26:32 +00:00
|
|
|
from ogn.client import TelnetClient
|
|
|
|
from ogn.parser.telnet_parser import parse
|
|
|
|
|
|
|
|
def process_beacon(raw_message):
|
|
|
|
beacon = parse(raw_message)
|
|
|
|
if beacon:
|
|
|
|
print(beacon)
|
|
|
|
|
|
|
|
client = TelnetClient()
|
|
|
|
client.connect()
|
|
|
|
|
|
|
|
try:
|
|
|
|
client.run(callback=process_beacon)
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
print('\nStop ogn gateway')
|
|
|
|
client.disconnect()
|
|
|
|
```
|
|
|
|
|
2016-02-28 11:11:16 +00:00
|
|
|
## License
|
|
|
|
Licensed under the [AGPLv3](LICENSE).
|