Skip to content

Commit

Permalink
callsign argument
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharyburnett committed Sep 17, 2020
1 parent 66ec7b3 commit a3619d1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ packetraven_gui
#### Python API:
to retrieve packets directly from https://aprs.fi:
```python
from packetraven import BALLOON_CALLSIGNS, APRS_fi
from packetraven import DEFAULT_CALLSIGNS, APRS_fi

api_key = '' # enter your APRS.fi API key here - you can get a free API key from https://aprs.fi/page/api

aprs_fi = APRS_fi(BALLOON_CALLSIGNS, api_key)
aprs_fi = APRS_fi(DEFAULT_CALLSIGNS, api_key)
aprs_fi_packets = aprs_fi.packets

print(aprs_fi_packets)
Expand Down
12 changes: 8 additions & 4 deletions client/packetraven_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pathlib import Path
import time

from packetraven import BALLOON_CALLSIGNS
from packetraven import DEFAULT_CALLSIGNS
from packetraven.connections import APRS_fi, PacketRadio, PacketTextFile
from packetraven.tracks import APRSTrack
from packetraven.utilities import get_logger
Expand All @@ -19,16 +19,18 @@
def main():
parser = argparse.ArgumentParser()
parser.add_argument('-k', '--key', help='API key from https://aprs.fi/page/api')
parser.add_argument('-c', '--callsigns', help='comma-separated list of callsigns to track')
parser.add_argument('-r', '--noradio', action='store_true', help='skip attempting to connect to APRS packet radio')
parser.add_argument('-p', '--port', help='name of serial port connected to APRS packet radio')
parser.add_argument('-l', '--log', help='path to log file to save log messages')
parser.add_argument('-o', '--output', help='path to output file to save packets')
parser.add_argument('-t', '--interval', help='seconds between each main loop')
args = parser.parse_args()

serial_port = args.port
aprs_fi_api_key = args.key

callsigns = args.callsigns.strip('"').split(',') if args.callsigns is not None else DEFAULT_CALLSIGNS

if args.log is not None:
log_filename = Path(args.log).expanduser()
if log_filename.is_dir():
Expand All @@ -45,6 +47,8 @@ def main():
else:
output_filename = None

serial_port = args.port

aprs_connections = []
if not args.noradio:
if serial_port is not None and 'txt' in serial_port:
Expand All @@ -63,8 +67,8 @@ def main():
LOGGER.warning(f'{error.__class__.__name__} - {error}')

try:
aprs_api = APRS_fi(BALLOON_CALLSIGNS, api_key=aprs_fi_api_key)
LOGGER.info(f'established connection to {aprs_api.location}')
aprs_api = APRS_fi(callsigns, api_key=aprs_fi_api_key)
LOGGER.info(f'established connection to {aprs_api.location} parsing selected callsigns ({", ".join(callsigns)})')
aprs_connections.append(aprs_api)
except ConnectionError as error:
LOGGER.warning(f'{error.__class__.__name__} - {error}')
Expand Down
6 changes: 3 additions & 3 deletions client/packetraven_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import tkinter
from tkinter import filedialog, messagebox, simpledialog

from packetraven import BALLOON_CALLSIGNS
from packetraven import DEFAULT_CALLSIGNS
from packetraven.connections import APRS_fi, PacketRadio, PacketTextFile, next_available_port
from packetraven.tracks import APRSTrack
from packetraven.utilities import get_logger
Expand Down Expand Up @@ -176,7 +176,7 @@ def toggle(self):
aprs_fi_api_key = simpledialog.askstring('APRS.fi API Key', 'enter API key for https://aprs.fi', parent=self.main_window)

try:
aprs_api = APRS_fi(BALLOON_CALLSIGNS, api_key=aprs_fi_api_key)
aprs_api = APRS_fi(DEFAULT_CALLSIGNS, api_key=aprs_fi_api_key)
LOGGER.info(f'established connection to API')
self.connections.append(aprs_api)
except Exception as error:
Expand Down Expand Up @@ -234,7 +234,7 @@ def run(self):
if seconds_to_impact >= 0:
LOGGER.info(f'{callsign:8} - Estimated time until landing (s): {seconds_to_impact}')

if callsign in BALLOON_CALLSIGNS:
if callsign in DEFAULT_CALLSIGNS:
self.replace_text(self.elements['longitude'], coordinates[0])
self.replace_text(self.elements['latitude'], coordinates[1])
self.replace_text(self.elements['altitude'], coordinates[2])
Expand Down
2 changes: 1 addition & 1 deletion packetraven/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from packetraven.connections import APRSPacketDatabaseTable, APRS_fi, PacketRadio, PacketTextFile

BALLOON_CALLSIGNS = ['W3EAX-10', 'W3EAX-11', 'W3EAX-14']
DEFAULT_CALLSIGNS = ['W3EAX-10', 'W3EAX-11', 'W3EAX-14']

0 comments on commit a3619d1

Please sign in to comment.