A python3 module for the Open Glider Network.
Go to file
Fabian P. Schmidt bf03ac39dd Initial commit; Import from ogn-python
The repository ogn-python splits up into two separate repositories.
- python-ogn-client (the repository this commit belongs to):
  includes an APRS- and OGN-Parser, an APRS-Client and a DDB-Client.
- python-ogn-gateway:
  includes a database, CLI, logbook.

Import from glidernet/ogn-python, commit ba7ae37ef273aa5840719b31e4bca0c16d99eadd
2016-02-28 12:11:16 +01:00
ogn Initial commit; Import from ogn-python 2016-02-28 12:11:16 +01:00
tests Initial commit; Import from ogn-python 2016-02-28 12:11:16 +01:00
.gitignore Initial commit; Import from ogn-python 2016-02-28 12:11:16 +01:00
.travis.yml Initial commit; Import from ogn-python 2016-02-28 12:11:16 +01:00
CHANGELOG.md Initial commit; Import from ogn-python 2016-02-28 12:11:16 +01:00
CONTRIBUTORS Initial commit; Import from ogn-python 2016-02-28 12:11:16 +01:00
LICENSE Initial commit; Import from ogn-python 2016-02-28 12:11:16 +01:00
MANIFEST.in Initial commit; Import from ogn-python 2016-02-28 12:11:16 +01:00
README.md Initial commit; Import from ogn-python 2016-02-28 12:11:16 +01:00
requirements.txt Initial commit; Import from ogn-python 2016-02-28 12:11:16 +01:00
setup.cfg Initial commit; Import from ogn-python 2016-02-28 12:11:16 +01:00
setup.py Initial commit; Import from ogn-python 2016-02-28 12:11:16 +01:00

README.md

ogn-python

[Build Status] (https://travis-ci.org/glidernet/ogn-python) [Coverage Status] (https://coveralls.io/r/glidernet/ogn-python) [PyPi Version] (https://pypi.python.org/pypi/ogn-python)

A python module for the Open Glider Network. The submodule 'ogn.gateway' is an aprs client which could be invoked via a CLI or used by other python projects. The CLI allows to save all received beacons into a database with SQLAlchemy. The sqlite-backend is sufficient for simple testing, but some tasks (e.g. logbook generation) require a proper backend like postgresql. An external python project would instantiate ogn.gateway and register a custom callback, called each time a beacon is received.

Examples

Usage

Implement your own gateway by using ogn.gateway with a custom callback function. Each time a beacon is received, this function gets called and lets you process the incoming data.

Example:

#!/usr/bin/env python3
from ogn.gateway.client import ognGateway
from ogn.parser.parse import parse_aprs, parse_ogn_beacon
from ogn.parser.exceptions import ParseError


def process_beacon(raw_message):
    if raw_message[0] == '#':
        print('Server Status: {}'.format(raw_message))
        return

    try:
        message = parse_aprs(raw_message)
        message.update(parse_ogn_beacon(message['comment']))

        print('Received {beacon_type} from {name}'.format(**message))
    except ParseError as e:
        print('Error, {}'.format(e.message))


if __name__ == '__main__':
    gateway = ognGateway(aprs_user='N0CALL')
    gateway.connect()

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

    gateway.disconnect()

License

Licensed under the AGPLv3.