Implement OP25 commands
This commit is contained in:
@@ -12,6 +12,9 @@ class NodeCommands(str, Enum):
|
|||||||
JOIN = "join_server"
|
JOIN = "join_server"
|
||||||
LEAVE = "leave_server"
|
LEAVE = "leave_server"
|
||||||
STATUS = "get_status"
|
STATUS = "get_status"
|
||||||
|
OP25_START = "op25_start"
|
||||||
|
OP25_STOP = "op25_stop"
|
||||||
|
OP25_SET = "op25_set"
|
||||||
|
|
||||||
|
|
||||||
class TalkgroupTag:
|
class TalkgroupTag:
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ async def join(client_id):
|
|||||||
@nodes_bp.route("/<client_id>/leave", methods=['POST'])
|
@nodes_bp.route("/<client_id>/leave", methods=['POST'])
|
||||||
async def leave(client_id):
|
async def leave(client_id):
|
||||||
"""
|
"""
|
||||||
Send a leave command to the specific system specified
|
Send a leave command to the specific node
|
||||||
"""
|
"""
|
||||||
data = await request.get_json()
|
data = await request.get_json()
|
||||||
|
|
||||||
@@ -225,5 +225,81 @@ async def leave(client_id):
|
|||||||
|
|
||||||
return jsonify({"status": "command sent", "client_id": client_id, "command": NodeCommands.LEAVE}), 200
|
return jsonify({"status": "command sent", "client_id": client_id, "command": NodeCommands.LEAVE}), 200
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({"error": f"Failed to send command: {e}"}), 500
|
||||||
|
|
||||||
|
|
||||||
|
@nodes_bp.route("/<client_id>/op25_start", methods=['POST'])
|
||||||
|
async def op25_start(client_id):
|
||||||
|
"""
|
||||||
|
Send an OP25 start command to the specific node
|
||||||
|
"""
|
||||||
|
data = await request.get_json()
|
||||||
|
|
||||||
|
system_id = data.get("system_id")
|
||||||
|
|
||||||
|
# Check to make sure the client is online
|
||||||
|
if client_id not in current_app.active_clients:
|
||||||
|
return jsonify({"error": f"Client {client_id} not found, it might be offline"}), 404
|
||||||
|
|
||||||
|
if not system_id:
|
||||||
|
return jsonify({"error":"No System ID supplied"}), 400
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Send the command asynchronously
|
||||||
|
await send_command_to_client(client_id, NodeCommands.OP25_START)
|
||||||
|
|
||||||
|
return jsonify({"status": "command sent", "client_id": client_id, "command": NodeCommands.OP25_START}), 200
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({"error": f"Failed to send command: {e}"}), 500
|
||||||
|
|
||||||
|
|
||||||
|
@nodes_bp.route("/<client_id>/op25_stop", methods=['POST'])
|
||||||
|
async def op25_stop(client_id):
|
||||||
|
"""
|
||||||
|
Send an OP25 stop command to the specific node
|
||||||
|
"""
|
||||||
|
# Check to make sure the client is online
|
||||||
|
if client_id not in current_app.active_clients:
|
||||||
|
return jsonify({"error": f"Client {client_id} not found, it might be offline"}), 404
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Send the command asynchronously
|
||||||
|
await send_command_to_client(client_id, NodeCommands.OP25_START)
|
||||||
|
|
||||||
|
return jsonify({"status": "command sent", "client_id": client_id, "command": NodeCommands.OP25_STOP}), 200
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
return jsonify({"error": f"Failed to send command: {e}"}), 500
|
||||||
|
|
||||||
|
|
||||||
|
@nodes_bp.route("/<client_id>/op25_set", methods=['POST'])
|
||||||
|
async def op25_set(client_id):
|
||||||
|
"""
|
||||||
|
Send an OP25 set config command to the specific node
|
||||||
|
"""
|
||||||
|
data = await request.get_json()
|
||||||
|
|
||||||
|
system_id = data.get("system_id")
|
||||||
|
|
||||||
|
# Check to make sure the client is online
|
||||||
|
if client_id not in current_app.active_clients:
|
||||||
|
return jsonify({"error": f"Client {client_id} not found, it might be offline"}), 404
|
||||||
|
|
||||||
|
if not system_id:
|
||||||
|
return jsonify({"error":"No System ID supplied"}), 400
|
||||||
|
|
||||||
|
try:
|
||||||
|
args = [system_id]
|
||||||
|
|
||||||
|
if not isinstance(args, list):
|
||||||
|
return jsonify({"error": "'args' must be a list"}), 400
|
||||||
|
|
||||||
|
# Send the command asynchronously
|
||||||
|
await send_command_to_client(client_id, NodeCommands.OP25_START, *args)
|
||||||
|
|
||||||
|
return jsonify({"status": "command sent", "client_id": client_id, "command": NodeCommands.OP25_SET}), 200
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
return jsonify({"error": f"Failed to send command: {e}"}), 500
|
return jsonify({"error": f"Failed to send command: {e}"}), 500
|
||||||
Reference in New Issue
Block a user