diff --git a/freedata_server/p2p_connection.py b/freedata_server/p2p_connection.py index 4179c3a6..b01f8709 100644 --- a/freedata_server/p2p_connection.py +++ b/freedata_server/p2p_connection.py @@ -326,16 +326,12 @@ class P2PConnection: def transmit_heartbeat_ack(self): print("transmit heartbeat ack") - if self.p2p_data_tx_queue.empty(): - self.flag_buffer_empty = True - - + self.flag_buffer_empty = self.p2p_data_tx_queue.empty() self.last_data_timestamp = time.time() heartbeat_ack = self.frame_factory.build_p2p_connection_heartbeat_ack(self.session_id, flag_buffer_empty=self.flag_buffer_empty,flag_announce_arq=self.flag_announce_arq) print(heartbeat_ack) self.launch_twr_irs(heartbeat_ack, self.ENTIRE_CONNECTION_TIMEOUT, mode=FREEDV_MODE.signalling) - def received_heartbeat(self, frame): print("received heartbeat...") self.last_data_timestamp = time.time() @@ -363,9 +359,13 @@ class P2PConnection: print("received heartbeat ack from IRS...") buffer_empty_flag = frame.get('flag', {}).get('BUFFER_EMPTY', False) announce_arq_flag = frame.get('flag', {}).get('ANNOUNCE_ARQ', False) + if buffer_empty_flag: print("other stations buffer is empty. We can become data master now") self.is_Master = True + else: + print("other station has data to be sent...") + self.is_Master = False if announce_arq_flag: print("other station announced arq, changing state")