Metadata-Version: 2.3
Name: ogn-client
Version: 1.3.3
Summary: A python module for the Open Glider Network
License: AGPL-3.0-only
Keywords: gliding,ogn
Author: Konstantin Gründger
Author-email: konstantin.gruendger@web.de
Maintainer: Konstantin Gründger
Maintainer-email: konstantin.gruendger@web.de
Requires-Python: >=3.9
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: GIS
Classifier: License :: OSI Approved :: GNU Affero General Public License v3
Classifier: Programming Language :: Python :: 3 :: Only
Requires-Dist: ogn-parser (>=0.3.12,<0.4.0)
Requires-Dist: requests (>=2.32.3,<3.0.0)
Project-URL: Repository, https://github.com/glidernet/python-ogn-client
Description-Content-Type: text/markdown

# python-ogn-client

[![build](https://github.com/Meisterschueler/python-ogn-client/actions/workflows/ci.yaml/badge.svg)](https://github.com/Meisterschueler/python-ogn-client/actions/workflows/ci.yaml)
[![PyPi Version](https://img.shields.io/pypi/v/ogn-client.svg)](https://pypi.python.org/pypi/ogn-client)

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.


## Installation

python-ogn-client is available at PyPI. So for installation simply use pip:

```
pip install ogn-client
```

## Example Usage

### Parse APRS/OGN packet.

```python
from ogn.parser import parse
from datetime import datetime

beacon = parse("FLRDDDEAD>APRS,qAS,EDER:/114500h5029.86N/00956.98E'342/049/A=005524 id0ADDDEAD -454fpm -1.1rot 8.8dB 0e +51.2kHz gps4x5",
				reference_timestamp=datetime(2015, 7, 31, 12, 34, 56))
```

### Connect to OGN and display all incoming beacons.

```python
from ogn.client import AprsClient
from ogn.parser import parse, ParseError

def process_beacon(raw_message):
    try:
        beacon = parse(raw_message)
        print('Received {aprs_type}: {raw_message}'.format(**beacon))
    except ParseError as e:
        print('Error, {}'.format(e.message))
    except NotImplementedError as e:
        print('{}: {}'.format(e, raw_message))

client = AprsClient(aprs_user='N0CALL')
client.connect()

try:
    client.run(callback=process_beacon, autoreconnect=True)
except KeyboardInterrupt:
    print('\nStop ogn gateway')
    client.disconnect()
```

### Connect to telnet console and display all decoded beacons.

```python
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()
```

## License
Licensed under the [AGPLv3](LICENSE).

