diff --git a/playback.py b/playback.py index 35a8ea0..e44a021 100755 --- a/playback.py +++ b/playback.py @@ -30,7 +30,9 @@ try: except ImportError: sys.exit('Configuration file not found or invalid') -HEX_TGID = hex_str_3(TGID) +HEX_TGID = hex_str_3(TGID) +HEX_SUB = hex_str_3(SUB) +BOGUS_SUB = '\xFF\xFF\xFF' class playbackIPSC(IPSC): @@ -42,26 +44,53 @@ class playbackIPSC(IPSC): # CALLBACK FUNCTIONS FOR USER PACKET TYPES #************************************************ # - def group_voice(self, _network, _src_sub, _dst_sub, _ts, _end, _peerid, _data): - if HEX_TGID == _dst_sub and TS == _ts: - if not _end: - if not self.CALL_DATA: - logger.info('(%s) Receiving transmission to be played back from subscriber: %s', _network, int_id(_src_sub)) - _tmp_data = _data - #_tmp_data = dmr_nat(_data, _src_sub, NETWORK[_network]['LOCAL']['RADIO_ID']) - self.CALL_DATA.append(_tmp_data) - if _end: - self.CALL_DATA.append(_data) - time.sleep(2) - logger.info('(%s) Playing back transmission from subscriber: %s', _network, int_id(_src_sub)) - for i in self.CALL_DATA: - _tmp_data = i - _tmp_data = _tmp_data.replace(_peerid, NETWORK[_network]['LOCAL']['RADIO_ID']) - _tmp_data = self.hashed_packet(NETWORK[_network]['LOCAL']['AUTH_KEY'], _tmp_data) - # Send the packet to all peers in the target IPSC - send_to_ipsc(_network, _tmp_data) - time.sleep(0.06) - self.CALL_DATA = [] + if GROUP_REPEAT: + def group_voice(self, _network, _src_sub, _dst_sub, _ts, _end, _peerid, _data): + if HEX_TGID == _dst_sub and _ts in GROUP_TS: + if not _end: + if not self.CALL_DATA: + logger.info('(%s) Receiving transmission to be played back from subscriber: %s', _network, int_id(_src_sub)) + _tmp_data = _data + #_tmp_data = dmr_nat(_data, _src_sub, NETWORK[_network]['LOCAL']['RADIO_ID']) + self.CALL_DATA.append(_tmp_data) + if _end: + self.CALL_DATA.append(_data) + time.sleep(2) + logger.info('(%s) Playing back transmission from subscriber: %s', _network, int_id(_src_sub)) + for i in self.CALL_DATA: + _tmp_data = i + _tmp_data = _tmp_data.replace(_peerid, NETWORK[_network]['LOCAL']['RADIO_ID']) + _tmp_data = self.hashed_packet(NETWORK[_network]['LOCAL']['AUTH_KEY'], _tmp_data) + # Send the packet to all peers in the target IPSC + send_to_ipsc(_network, _tmp_data) + time.sleep(0.06) + self.CALL_DATA = [] + + if PRIVATE_REPEAT: + def private_voice(self, _network, _src_sub, _dst_sub, _ts, _end, _peerid, _data): + if HEX_SUB == _dst_sub and _ts in PRIVATE_TS: + if not _end: + if not self.CALL_DATA: + logger.info('(%s) Receiving transmission to be played back from subscriber: %s, to subscriber: %s', _network, int_id(_src_sub), int_id(_dst_sub)) + _tmp_data = _data + self.CALL_DATA.append(_tmp_data) + if _end: + self.CALL_DATA.append(_data) + time.sleep(1) + logger.info('(%s) Playing back transmission from subscriber: %s, to subscriber %s', _network, int_id(_src_sub), int_id(_dst_sub)) + _orig_src = _src_sub + _orig_dst = _dst_sub + for i in self.CALL_DATA: + _tmp_data = i + _tmp_data = _tmp_data.replace(_peerid, NETWORK[_network]['LOCAL']['RADIO_ID']) + _tmp_data = _tmp_data.replace(_dst_sub, BOGUS_SUB) + _tmp_data = _tmp_data.replace(_src_sub, _orig_dst) + _tmp_data = _tmp_data.replace(BOGUS_SUB, _orig_src) + _tmp_data = self.hashed_packet(NETWORK[_network]['LOCAL']['AUTH_KEY'], _tmp_data) + # Send the packet to all peers in the target IPSC + send_to_ipsc(_network, _tmp_data) + time.sleep(0.06) + self.CALL_DATA = [] if __name__ == '__main__': diff --git a/playback_config_SAMPLE.py b/playback_config_SAMPLE.py index 9edfa61..f7c4190 100755 --- a/playback_config_SAMPLE.py +++ b/playback_config_SAMPLE.py @@ -1,7 +1,28 @@ #!/usr/bin/env python # # THESE ARE THE THINGS THAT YOU NEED TO CONFIGURE TO USE playback.py + +# ENABLE GROUP VOICE PLAYBACK? +# Values may be True or False +GROUP_REPEAT = True # TGID TO LISTEN FOR AND REPEAT ON -TGID = 10 -# TIMESLOT TO LISTEN FOR AND REPEAT ON -TS = 0 +# Integer for the Talkgroup ID +TGID = 12345 +# TIMESLOT TO LISTEN FOR GROUP VOICE AND REPEAT +# This is a tuple of timeslots to listen to. Note, if there's only +# one, you still have to use the parenthesis and comma. Just +# deal with it, or make it better. TS1 = 0, TS2 = 1. +GROUP_TS = (1,) + + +# ENABLE PRIVATE VOICE PLAYBACK? +# Values may be True or False +PRIVATE_REPEAT = True +# SUBSCRIBER ID TO LISTEN FOR AND REPEAT ON +# Integer for the Subscriber (Radio) ID +SUB = 12345 +# TIMESLOT TO LISTEN FOR PRIVATE VOICE AND REPEAT +# This is a tuple of timeslots to listen to. Note, if there's only +# one, you still have to use the parenthesis and comma. Just +# deal with it, or make it better. TS1 = 0, TS2 = 1. +PRIVATE_TS = (0,1)