diff --git a/README.md b/README.md new file mode 100644 index 0000000..cc2a570 --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# README + +I got tired of APRS-IS websites not showing me all the paths that packets +take, only the shortest path to IS. So this is a Python 3 tool that turns +direwolf logs into a REST API in JSON format. + +## Setup +1. Run direwolf with logging to CSV on by using `-l`. (`-L` not yet implemented). +1. Install requirements using `pip install -r requirements.txt`. +2. Run `app.py` with either a Python call or gunicorn (or some other WSGI server). +You can use screen to detach the session. + - Default URL is http://127.0.0.1:5000 +3. Access the API from whatever other system you want. + + + +## Endpoints: +-`/packets` - gives the most recent packets, with the fields from the Dire Wolf +User Guide. + +Example of an object packet sent by W1CDN-1 and digipeated by K0UND-2: +``` +{ + "chan": 0, + "utime": 1680566406, + "isotime": "2023-04-04T00:00:06Z", + "source": "W1CDN-1", + "heard": "K0UND-2", + "level": "113(71/42)", + "error": 0, + "dti": ";", + "name": "147.390GF", + "symbol": "/r", + "latitude": 47.924167, + "longitude": -97.009667, + "speed": 0.0, + "course": 0.0, + "altitude": 0.0, + "frequency": 147.39, + "offset": 600.0, + "tone": 0.0, + "system": "DireWolf, WB2OSZ", + "status": 0, + "telemetry": 0.0, + "comment": " https://www.wa0jxt.org/" + }, +``` diff --git a/app.py b/app.py index 2fcbb8b..a20eeff 100644 --- a/app.py +++ b/app.py @@ -2,11 +2,12 @@ from flask import Flask from flask_restful import Resource, Api, reqparse from datetime import date, timedelta import configparser +# TODO Can we do it without pandas and numpy? import pandas as pd import numpy as np import ast -import kiss import glob +import json app = Flask(__name__) api = Api(app) @@ -29,6 +30,7 @@ def read_logs(log_folder): for file in file_list: file1 = pd.read_csv(file) list_stacked = pd.concat([list_stacked, file1]) + # TODO Can we do this without numpy? list_stacked.replace(np.nan, 0, inplace=True) #print(list_stacked.head()) @@ -50,7 +52,6 @@ class Packets(Resource): def get(self): data = read_logs(log_folder) # re-reads the log files every time data = data.to_dict(orient = 'records') # convert dataframe to dictionary - #data = data.to_json(orient='records') return {'data': data}, 200 # return data and 200 OK code # Read config diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..baf9fc7 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +flask +flask_restful +pandas +numpy