Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
11 changes: 11 additions & 0 deletions postgresDB/dbApp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down