2023-04-13 17:16:16 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
"""
|
|
|
|
Send a test frame via TCP, then read & print KISS frames from a TCP Socket.
|
|
|
|
For use with programs like Dire Wolf.
|
|
|
|
From https://github.com/python-aprs/kiss3/blob/main/examples/tcp_send_recv.py
|
|
|
|
"""
|
|
|
|
import os
|
|
|
|
|
|
|
|
from ax253 import Frame
|
|
|
|
import kiss
|
|
|
|
|
|
|
|
|
|
|
|
MYCALL = os.environ.get("MYCALL", "W1CDN")
|
|
|
|
KISS_HOST = os.environ.get("KISS_HOST", "192.168.0.30")
|
|
|
|
KISS_PORT = os.environ.get("KISS_PORT", "8001")
|
|
|
|
|
|
|
|
|
|
|
|
def print_frame(frame):
|
|
|
|
print(Frame.from_bytes(frame))
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
ki = kiss.TCPKISS(host=KISS_HOST, port=int(KISS_PORT), strip_df_start=True)
|
|
|
|
ki.start()
|
|
|
|
# frame = Frame.ui(
|
|
|
|
# destination="PYKISS",
|
|
|
|
# source=MYCALL,
|
|
|
|
# path=["WIDE1-1"],
|
|
|
|
# info=">Hello World!",
|
|
|
|
# )
|
|
|
|
#ki.write(frame)
|
|
|
|
# Write received frame to terminal
|
|
|
|
ki.read(callback=print_frame, min_frames=None)
|
|
|
|
|
|
|
|
# put some database stuff here
|
2023-04-13 20:46:28 -05:00
|
|
|
print(Frame.from_bytes(frame))
|
|
|
|
conn = get_db_connection()
|
|
|
|
conn.execute('INSERT INTO frames (frame) VALUES (?)',
|
|
|
|
(Frame.from_bytes(frame)))
|
|
|
|
conn.commit()
|
|
|
|
conn.close()
|
2023-04-13 17:16:16 -05:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|