Skip to content

Commit d5ccbc0

Browse files
authored
Merge pull request #87 from ISSUIUC/comb-fixes-ack
fix
2 parents 9f1251d + 5f3baee commit d5ccbc0

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

ground/gss_combiner/main.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,11 @@ def parse_params(arguments):
269269

270270
sustainer_commands, booster_commands = broadcast_thread.get_telem_cmds()
271271

272+
# Handle ack sending
273+
for thread in (telem_threads_booster + telem_threads_relay + telem_threads_sustainer):
274+
for packet in thread.get_ack_queue():
275+
broadcast_thread.send_raw(packet[0], packet[1])
276+
272277
# handle commands
273278
# print(sustainer_commands, booster_commands)
274279

ground/gss_combiner/util/mqtt.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ def __init__(self, com_port, log_stream: util.logger.LoggerStream) -> None:
3333

3434
self.__external_commands = []
3535

36+
self.__ack_queue = []
37+
3638

3739
def process_packet(self, packet_json):
3840
"""Append metadata to a packet to conform to GSS v1.1 packet structure"""
@@ -71,6 +73,11 @@ def __read_comport(self):
7173
else:
7274
return []
7375

76+
def get_ack_queue(self):
77+
q_copy = copy.deepcopy(self.__ack_queue)
78+
self.__ack_queue.clear()
79+
return q_copy
80+
7481
def add_combiner(self, combiner):
7582
"""Add a combiner data sink for this telemetry thread"""
7683
self.__combiners.append(combiner)
@@ -131,18 +138,23 @@ def run(self) -> None:
131138

132139
if packet_in['type'] == "command_success":
133140
self.__log.console_log("RX: Command good")
141+
self.__ack_queue.append([self.__combiners[0].get_mqtt_control_topic(), packet_in])
134142
continue
135143

144+
# This is jank but idc
136145
if packet_in['type'] == "bad_command":
137146
self.__log.console_log("RX: Command bad")
147+
self.__ack_queue.append([self.__combiners[0].get_mqtt_control_topic(), packet_in])
138148
continue
139149

140150
if packet_in['type'] == "command_acknowledge":
141151
self.__log.console_log("RX: Command ACK")
152+
self.__ack_queue.append([self.__combiners[0].get_mqtt_control_topic(), packet_in])
142153
continue
143154

144155
if packet_in['type'] == "command_sent":
145156
self.__log.console_log("RX: Command send confirmed")
157+
self.__ack_queue.append([self.__combiners[0].get_mqtt_control_topic(), packet_in])
146158
continue
147159

148160
# print(packet_in)
@@ -292,6 +304,11 @@ def publish(self, packet_list, topic) -> None:
292304
self.__log.fail()
293305
self.__log.waiting_delta(-1)
294306

307+
def send_raw(self, topic, data) -> None:
308+
"""Publish a set of packets to a `Data` topic"""
309+
self.__mqttclient.publish(topic, json.dumps(data).encode("utf-8"))
310+
self.__log.console_log(f"Published")
311+
295312
def run(self) -> None:
296313
self.__mqttclient.loop_start()
297314

0 commit comments

Comments
 (0)