mirror of https://github.com/DJ2LS/FreeDATA.git
work on nack
parent
2eebd5b2dc
commit
dc6bb8ed01
|
|
@ -27,11 +27,21 @@ class NORMFrameHandler(frame_handler.FrameHandler):
|
|||
NormTransmissionIRS(self.ctx, frame)
|
||||
|
||||
elif frame['frame_type_int'] == FR.NORM_NACK.value:
|
||||
print(frame["id"])
|
||||
broadcast = DatabaseManagerBroadcasts(self.ctx).get_broadcast_per_id(frame["id"])
|
||||
if broadcast is not None:
|
||||
print(broadcast)
|
||||
NormTransmissionISS(self.ctx, broadcast.origin, broadcast.domain, broadcast.gridsquare, broadcast.data, priority=broadcast.priority, message_type=broadcast.message_type)
|
||||
try:
|
||||
print(str(frame["id"]))
|
||||
print(frame["id"].decode("utf-8"))
|
||||
broadcast = DatabaseManagerBroadcasts(self.ctx).get_broadcast_per_id(frame["id"].decode("utf-8"))
|
||||
if broadcast is not None:
|
||||
print(broadcast)
|
||||
print("oring", broadcast["origin"])
|
||||
print("domain", broadcast["domain"])
|
||||
print("gridsquare", broadcast["gridsquare"])
|
||||
print("payload_data", broadcast["payload_data"]["final"])
|
||||
print("priority", broadcast["priority"])
|
||||
print("message_type", broadcast["msg_type"])
|
||||
NormTransmissionISS(self.ctx, broadcast["origin"], broadcast["domain"], broadcast["gridsquare"], broadcast["payload_data"]["final"], priority=broadcast["priority"], message_type=broadcast["msg_type"], send_only_bursts=frame["missing_bursts"]).prepare_and_transmit()
|
||||
except Exception as e:
|
||||
print(e)
|
||||
else:
|
||||
self.logger.warning("DISCARDING FRAME", frame=frame)
|
||||
return
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class NORM_ISS_State(Enum):
|
|||
class NormTransmissionISS(NormTransmission):
|
||||
MAX_PAYLOAD_SIZE = 26
|
||||
|
||||
def __init__(self, ctx, origin, domain, gridsquare, data, priority=NORMMsgPriority.NORMAL, message_type=NORMMsgType.UNDEFINED):
|
||||
def __init__(self, ctx, origin, domain, gridsquare, data, priority=NORMMsgPriority.NORMAL, message_type=NORMMsgType.UNDEFINED, send_only_bursts=None):
|
||||
|
||||
super().__init__(ctx, origin, domain)
|
||||
self.ctx = ctx
|
||||
|
|
@ -36,6 +36,8 @@ class NormTransmissionISS(NormTransmission):
|
|||
self.message_type = message_type
|
||||
self.payload_size = len(data)
|
||||
|
||||
self.send_only_bursts = send_only_bursts
|
||||
|
||||
self.timestamp = int(time.time())
|
||||
|
||||
self.state = NORM_ISS_State.NEW
|
||||
|
|
@ -61,35 +63,66 @@ class NormTransmissionISS(NormTransmission):
|
|||
|
||||
|
||||
bursts = []
|
||||
if not self.send_only_bursts:
|
||||
for burst_number in range(1, total_bursts + 1):
|
||||
offset = (burst_number-1) * self.MAX_PAYLOAD_SIZE
|
||||
payload = full_data[offset: offset + self.MAX_PAYLOAD_SIZE]
|
||||
print("payload: ", len(payload))
|
||||
|
||||
for burst_number in range(1, total_bursts + 1):
|
||||
offset = (burst_number-1) * self.MAX_PAYLOAD_SIZE
|
||||
payload = full_data[offset: offset + self.MAX_PAYLOAD_SIZE]
|
||||
print("payload: ", len(payload))
|
||||
burst_info = self.encode_burst_info(burst_number, total_bursts)
|
||||
checksum = helpers.get_crc_24(full_data)
|
||||
# set flag for last burst
|
||||
is_last = (burst_number == total_bursts)
|
||||
flags = self.encode_flags(
|
||||
msg_type=self.message_type,
|
||||
priority=self.message_priority,
|
||||
is_last=is_last
|
||||
)
|
||||
|
||||
burst_info = self.encode_burst_info(burst_number, total_bursts)
|
||||
checksum = helpers.get_crc_24(full_data)
|
||||
# set flag for last burst
|
||||
is_last = (burst_number == total_bursts)
|
||||
flags = self.encode_flags(
|
||||
msg_type=self.message_type,
|
||||
priority=self.message_priority,
|
||||
is_last=is_last
|
||||
)
|
||||
burst_frame = self.frame_factory.build_norm_data(
|
||||
origin=self.origin,
|
||||
domain=self.domain,
|
||||
gridsquare=self.gridsquare,
|
||||
timestamp=self.timestamp,
|
||||
burst_info=burst_info,
|
||||
payload_size=len(full_data),
|
||||
payload_data=payload,
|
||||
flag=flags,
|
||||
checksum=checksum
|
||||
)
|
||||
print(burst_frame)
|
||||
bursts.append(burst_frame)
|
||||
|
||||
burst_frame = self.frame_factory.build_norm_data(
|
||||
origin=self.origin,
|
||||
domain=self.domain,
|
||||
gridsquare=self.gridsquare,
|
||||
timestamp=self.timestamp,
|
||||
burst_info=burst_info,
|
||||
payload_size=len(full_data),
|
||||
payload_data=payload,
|
||||
flag=flags,
|
||||
checksum=checksum
|
||||
)
|
||||
print(burst_frame)
|
||||
bursts.append(burst_frame)
|
||||
else:
|
||||
|
||||
for burst_number in self.send_only_bursts:
|
||||
offset = (burst_number - 1) * self.MAX_PAYLOAD_SIZE
|
||||
payload = full_data[offset: offset + self.MAX_PAYLOAD_SIZE]
|
||||
print("payload: ", len(payload))
|
||||
|
||||
burst_info = self.encode_burst_info(burst_number, total_bursts)
|
||||
checksum = helpers.get_crc_24(full_data)
|
||||
# set flag for last burst
|
||||
is_last = (burst_number == total_bursts)
|
||||
flags = self.encode_flags(
|
||||
msg_type=self.message_type,
|
||||
priority=self.message_priority,
|
||||
is_last=is_last
|
||||
)
|
||||
|
||||
burst_frame = self.frame_factory.build_norm_data(
|
||||
origin=self.origin,
|
||||
domain=self.domain,
|
||||
gridsquare=self.gridsquare,
|
||||
timestamp=self.timestamp,
|
||||
burst_info=burst_info,
|
||||
payload_size=len(full_data),
|
||||
payload_data=payload,
|
||||
flag=flags,
|
||||
checksum=checksum
|
||||
)
|
||||
print(burst_frame)
|
||||
bursts.append(burst_frame)
|
||||
|
||||
return bursts
|
||||
|
||||
|
|
@ -109,7 +142,9 @@ class NormTransmissionISS(NormTransmission):
|
|||
db = DatabaseManagerBroadcasts(self.ctx)
|
||||
self.timestamp_dt = datetime.fromtimestamp(self.timestamp, tz=timezone.utc)
|
||||
self.checksum = helpers.get_crc_24(self.data).hex()
|
||||
self.id = self.create_broadcast_id(self.timestamp, self.domain, self.checksum)
|
||||
self.id = self.create_broadcast_id(self.timestamp_dt, self.domain, self.checksum)
|
||||
print(self.create_broadcast_id(self.timestamp_dt, self.domain, self.checksum), self.create_broadcast_id(self.timestamp, self.domain, self.checksum))
|
||||
print(self.timestamp, self.timestamp_dt)
|
||||
|
||||
total_bursts = (len(self.data) + self.MAX_PAYLOAD_SIZE - 1) // self.MAX_PAYLOAD_SIZE
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue