updated cli tools

This commit is contained in:
DJ2LS 2022-12-09 22:48:29 +01:00
parent f2dd278bce
commit cc75d351ab
2 changed files with 45 additions and 1 deletions

View file

@ -0,0 +1,43 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
enable --- python3.9 enable_disable_beacon.py --host 192.168.178.42 --interval 120 --enable
disable -- python3.9 enable_disable_beacon.py
@author: DJ2LS
"""
import argparse
import socket
import base64
import json
# --------------------------------------------GET PARAMETER INPUTS
parser = argparse.ArgumentParser(description='Simons TEST TNC')
parser.add_argument('--port', dest="socket_port", default=3000, help="Set socket listening port.", type=int)
parser.add_argument('--host', dest="socket_host", default='localhost', help="Set the host, the socket is listening on.", type=str)
parser.add_argument('--interval', dest="interval", default=120, help="Interval in seconds", type=int)
parser.add_argument("--enable",dest="enable",action="store_true",help="Enable beacon",)
args = parser.parse_args()
HOST, PORT = args.socket_host, args.socket_port
interval = args.interval
enable = args.enable
if enable:
# our command we are going to send
command = {"type": "broadcast", "command": "start_beacon", "parameter": str(interval)}
else:
command = {"type": "broadcast", "command": "stop_beacon"}
command = json.dumps(command)
command = bytes(command + "\n", 'utf-8')
# Create a socket (SOCK_STREAM means a TCP socket)
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
# Connect to server and send data
sock.connect((HOST, PORT))
sock.sendall(command)

View file

@ -26,10 +26,11 @@ split_char = b"\x00;"
# --------------------------------------------GET PARAMETER INPUTS
parser = argparse.ArgumentParser(description='Simons TEST TNC')
parser.add_argument('--port', dest="socket_port", default=3000, help="Set the port, the socket is listening on.", type=int)
parser.add_argument('--host', dest="socket_host", default='localhost', help="Set the host, the socket is listening on.", type=str)
args = parser.parse_args()
ip, port = "localhost", args.socket_port
ip, port = args.socket_host, args.socket_port
connected = True