A python3 module for the Open Glider Network.
Go to file
Fabian P. Schmidt abae52b165 Rename module ogn.gateway to ogn.client
Renamed also class ognGateway to AprsClient to comply with the PEP8 naming
convention and to emphasis that it is a generic aprs client, not ogn specific.
2016-03-08 02:05:50 +01:00
ogn Rename module ogn.gateway to ogn.client 2016-03-08 02:05:50 +01:00
tests Rename module ogn.gateway to ogn.client 2016-03-08 02:05:50 +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.