mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
selective repeating
first try
This commit is contained in:
parent
f78d3fed15
commit
cbdbd30c39
|
@ -643,6 +643,7 @@ def arq_disconnect_received(data_in):
|
|||
|
||||
def transmit_ping(callsign):
|
||||
static.DXCALLSIGN = bytes(callsign, 'utf-8')
|
||||
static.DXCALLSIGN_CRC8 = helpers.get_crc_8(static.DXCALLSIGN)
|
||||
logging.info("PING ["+ str(static.MYCALLSIGN, 'utf-8') + "] >>> [" + str(static.DXCALLSIGN, 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||
|
||||
ping_frame = bytearray(14)
|
||||
|
@ -692,7 +693,7 @@ async def transmit_cq():
|
|||
|
||||
cq_frame = bytearray(14)
|
||||
cq_frame[:1] = bytes([200])
|
||||
cq_frame[1:2] = bytes(1) #b'\x00'
|
||||
cq_frame[1:2] = b'\x01' #b'\x00'
|
||||
cq_frame[2:3] = static.MYCALLSIGN_CRC8
|
||||
cq_frame[3:9] = static.MYCALLSIGN
|
||||
|
||||
|
@ -704,7 +705,8 @@ async def transmit_cq():
|
|||
time.sleep(0.1)
|
||||
|
||||
def received_cq(data_in):
|
||||
|
||||
static.DXCALLSIGN = b''
|
||||
static.DXCALLSIGN_CRC8 = b''
|
||||
logging.info("CQ [" + str(bytes(data_in[3:9]), 'utf-8') + "] [BER."+str(static.BER)+"]")
|
||||
|
||||
async def transmit_beacon():
|
||||
|
|
13
modem.py
13
modem.py
|
@ -337,8 +337,8 @@ class RF():
|
|||
stuck_in_sync_10_counter = 0
|
||||
#-----------------------------------
|
||||
|
||||
|
||||
if nbytes == bytes_per_frame:##########################################################FREEDV_DATA_BYTES_PER_FRAME
|
||||
# forward data only if broadcast or we are the receiver
|
||||
if nbytes == bytes_per_frame and bytes(bytes_out[1:2]) == static.MYCALLSIGN_CRC8 or bytes(bytes_out[1:2]) == b'\x01':
|
||||
self.calculate_ber(freedv)
|
||||
|
||||
# counter reset for stuck in sync counter
|
||||
|
@ -425,7 +425,7 @@ class RF():
|
|||
# ARQ CONNECT ACK / KEEP ALIVE
|
||||
elif frametype == 230:
|
||||
logging.debug("BEACON RECEIVED")
|
||||
|
||||
|
||||
else:
|
||||
logging.info("OTHER FRAME: " + str(bytes_out[:-2]))
|
||||
print(frametype)
|
||||
|
@ -435,7 +435,12 @@ class RF():
|
|||
logging.debug("LAST FRAME ---> UNSYNC")
|
||||
self.c_lib.freedv_set_sync(freedv, 0) #FORCE UNSYNC
|
||||
|
||||
|
||||
|
||||
# clear bytes_out buffer to be ready for next frames after successfull decoding
|
||||
|
||||
bytes_out = (ctypes.c_ubyte * bytes_per_frame)
|
||||
bytes_out = bytes_out() #get pointer to bytes_out
|
||||
|
||||
def calculate_ber(self,freedv):
|
||||
Tbits = self.c_lib.freedv_get_total_bits(freedv)
|
||||
Terrs = self.c_lib.freedv_get_total_bit_errors(freedv)
|
||||
|
|
16
sock.py
16
sock.py
|
@ -37,18 +37,14 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
|
||||
# SOCKETTEST ---------------------------------------------------
|
||||
if data == 'SOCKETTEST':
|
||||
cur_thread = threading.current_thread()
|
||||
#cur_thread = threading.current_thread()
|
||||
response = bytes("WELL DONE! YOU ARE ABLE TO COMMUNICATE WITH THE TNC", encoding)
|
||||
self.request.sendall(response)
|
||||
|
||||
# CQ CQ CQ -----------------------------------------------------
|
||||
if data == 'CQCQCQ':
|
||||
for i in range(0,3):
|
||||
asyncio.run(data_handler.transmit_cq())
|
||||
#self.request.sendall(bytes("CALLING CQ"))
|
||||
while static.ARQ_STATE == 'SENDING_SIGNALLING':
|
||||
time.sleep(0.1)
|
||||
pass
|
||||
asyncio.run(data_handler.transmit_cq())
|
||||
self.request.sendall(b'CALLING CQ')
|
||||
|
||||
|
||||
# PING ----------------------------------------------------------
|
||||
|
@ -141,9 +137,9 @@ class CMDTCPRequestHandler(socketserver.BaseRequestHandler):
|
|||
if data == 'GET:TNC_STATE':
|
||||
output = {
|
||||
"PTT_STATE": str(static.PTT_STATE),
|
||||
"CHANNEL_STATE": static.CHANNEL_STATE,
|
||||
"TNC_STATE": static.TNC_STATE,
|
||||
"ARQ_STATE": static.ARQ_STATE
|
||||
"CHANNEL_STATE": str(static.CHANNEL_STATE),
|
||||
"TNC_STATE": str(static.TNC_STATE),
|
||||
"ARQ_STATE": str(static.ARQ_STATE)
|
||||
}
|
||||
jsondata = json.dumps(output)
|
||||
self.request.sendall(bytes(jsondata, encoding))
|
||||
|
|
Loading…
Reference in a new issue