With introduction of the kill switch it was impossible to restart the
consumption of the OGN messages after a .disconnect() method has been
called.
This commit resets the kill flag after .connect() has been called.
Minimal example:
```
client = AprsClient(aprs_user='testuser', aprs_filter='')
client.connect()
client.run(callback=lambda x: x, autoreconnect=True)
...
client.disconnect()
client.connect()
client.run()
```
When starting an AprsClient with AprsClient.run(...) the client enters
a loop without an exit condition (i.e. a while True loop). If autoreconnect
is set to True, it is impossible to exit the aforementioned loop even if
AprsClient.disconnect() is called.
This causes problems when running the client in a thread (or as a
background service, etc.) as the process will not join nor terminate
unless explicitly shutdown with SIGKILL.
Minimal example:
```
import signal
from ogn.client import AprsClient
from ogn.parser import parse_aprs, parse_ogn_beacon, ParseError
def process_beacon(raw_message):
print('Received message')
client = AprsClient(aprs_user='N0CALL')
signal.signal(signal.SIGTERM, lambda signo, stackno: client.disconnect())
client.connect()
client.run(callback=process_beacon, autoreconnect=True)
```
This commit fixes such issues by adding a kill flag that is raised when
calling AprsClien.disconnect() to the while conditions of both loops inside
AprsClient.run().
Note: the outermost loop could still remain a while True loop as the
exit condition is checked at the end of the loop body.
APRS spec allows any callsign-like string, and it is widely used to signal
which software or device generated the packet.
For OGN use, I would recommend using OGN-specific destination callsigns,
maybe software/tracker-specific OGN-prefixed calls. APRS tocall
index is found here, AP-prefixed tocalls are used for APRS devices.
https://github.com/hessu/aprs-deviceid/blob/master/tocalls.yamlFixes#9.
A timed callback allows the modification of server-side filters
during runtime (the client instance provided as callback argument
includes the socket and its send function).
Since sock_file.readline() is blocking, a secure scheduling can't
be guaranteed but is likely due to regular server-sent status messages.
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.
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