Merge pull request #183 from DJ2LS/issue173_fix

Implements TODO from #173 .
This commit is contained in:
DJ2LS 2022-05-01 17:45:09 +02:00 committed by GitHub
commit e375cee792
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -289,7 +289,7 @@ class DATA():
# SESSION CLOSE
elif frametype == 223:
structlog.get_logger("structlog").debug("CLOSE ARQ SESSION RECEIVED....")
self.received_session_close()
self.received_session_close(bytes_out[:-2])
# ARQ FILE TRANSFER RECEIVED!
elif frametype == 225 or frametype == 227:
@ -1128,14 +1128,19 @@ class DATA():
# wait while transmitting
while static.TRANSMITTING:
time.sleep(0.01)
def received_session_close(self):
""" """
# TODO: we need to check for dx stations crc as well so we are only accept frames from a station we are connected to
if static.ARQ_SESSION:
def received_session_close(self, data_in:bytes):
"""
Closes the session when a close session frame is received and
the DXCALLSIGN_CRC matches the remote station participating in the session.
Args:
data_in:bytes:
Returns:
"""
# Close the session if the DXCALLSIGN_CRC matches the station in static.
if helpers.check_callsign(static.DXCALLSIGN, bytes(data_in[4:7])):
static.ARQ_SESSION_STATE = 'disconnected'
helpers.add_to_heard_stations(static.DXCALLSIGN,static.DXGRID, 'DATA-CHANNEL', static.SNR, static.FREQ_OFFSET, static.HAMLIB_FREQUENCY)
structlog.get_logger("structlog").info("SESSION [" + str(self.mycallsign, 'utf-8') + "]<<X>>[" + str(static.DXCALLSIGN, 'utf-8') + "]", state=static.ARQ_SESSION_STATE)
@ -1145,7 +1150,6 @@ class DATA():
static.ARQ_SESSION = False
self.arq_cleanup()
def transmit_session_heartbeat(self):
""" """
@ -1182,8 +1186,8 @@ class DATA():
"""
# TODO: we need to check for dx stations crc as well so we are only accept frames from a station we are connected to
if static.ARQ_SESSION:
# Accept session data if the DXCALLSIGN_CRC matches the station in static.
if helpers.check_callsign(static.DXCALLSIGN, bytes(data_in[4:7])):
structlog.get_logger("structlog").debug("received session heartbeat")
helpers.add_to_heard_stations(static.DXCALLSIGN, static.DXGRID, 'SESSION-HB', static.SNR, static.FREQ_OFFSET, static.HAMLIB_FREQUENCY)