diff --git a/EosGround/database/pipeline/pipelines/terminal_output_pipeline.py b/EosGround/database/pipeline/pipelines/terminal_output_pipeline.py index 2cc4242..83efcd2 100644 --- a/EosGround/database/pipeline/pipelines/terminal_output_pipeline.py +++ b/EosGround/database/pipeline/pipelines/terminal_output_pipeline.py @@ -28,7 +28,7 @@ def get_notify_channel() -> str | None: return None def extract(self, session: Session) -> Query: - commands = [Type.CUTDOWN, Type.PING, Type.VALVE] + commands = [Type.CUTDOWN, Type.PING, Type.VALVE, Type.DOWNLINK_COMMAND] return session.query(ReceivedPackets).filter(ReceivedPackets.packet_type.in_(commands), ReceivedPackets.processed == False)\ .order_by(ReceivedPackets.id) diff --git a/postgresDB/dbApp/views.py b/postgresDB/dbApp/views.py index c41c055..39a3969 100644 --- a/postgresDB/dbApp/views.py +++ b/postgresDB/dbApp/views.py @@ -17,6 +17,7 @@ from EosLib.format.definitions import Type from EosLib.format.formats.cutdown import CutDown from EosLib.format.formats.ping_format import Ping +from EosLib.format.formats.downlink_header_format import DownlinkCommandFormat, DownlinkCommand from EosLib.device import Device from EosLib.packet import Packet from EosLib.packet.data_header import DataHeader @@ -108,6 +109,16 @@ def transmitTableInsert(request): cursor.execute("NOTIFY update;") connection.commit() return Response({'message': 'Valve command sent ', 'ack': ack}, status=status.HTTP_200_OK) + elif command == "downlink": + downlink_body = DownlinkCommandFormat(0, 0, DownlinkCommand.START_REQUEST) + downlink_body_bytes = downlink_body.encode() + transmitTable.packet_type = Type.DOWNLINK_COMMAND + transmitTable.destination = Device.DOWNLINK + transmitTable.body = downlink_body_bytes + transmitTable.save() + cursor.execute("NOTIFY update;") + connection.commit() + return Response({'message': 'Downlink command sent ', 'ack': ack}, status=status.HTTP_200_OK) return Response({'message': 'Invalid input or method'}, status=status.HTTP_400_BAD_REQUEST)