Combine Playback Group and Private

This commit is contained in:
Cort Buffington 2014-08-17 09:35:50 -05:00
parent 536dc73521
commit c04bbc1b84
2 changed files with 74 additions and 24 deletions

View File

@ -30,7 +30,9 @@ try:
except ImportError: except ImportError:
sys.exit('Configuration file not found or invalid') 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): class playbackIPSC(IPSC):
@ -42,26 +44,53 @@ class playbackIPSC(IPSC):
# CALLBACK FUNCTIONS FOR USER PACKET TYPES # CALLBACK FUNCTIONS FOR USER PACKET TYPES
#************************************************ #************************************************
# #
def group_voice(self, _network, _src_sub, _dst_sub, _ts, _end, _peerid, _data): if GROUP_REPEAT:
if HEX_TGID == _dst_sub and TS == _ts: def group_voice(self, _network, _src_sub, _dst_sub, _ts, _end, _peerid, _data):
if not _end: if HEX_TGID == _dst_sub and _ts in GROUP_TS:
if not self.CALL_DATA: if not _end:
logger.info('(%s) Receiving transmission to be played back from subscriber: %s', _network, int_id(_src_sub)) if not self.CALL_DATA:
_tmp_data = _data logger.info('(%s) Receiving transmission to be played back from subscriber: %s', _network, int_id(_src_sub))
#_tmp_data = dmr_nat(_data, _src_sub, NETWORK[_network]['LOCAL']['RADIO_ID']) _tmp_data = _data
self.CALL_DATA.append(_tmp_data) #_tmp_data = dmr_nat(_data, _src_sub, NETWORK[_network]['LOCAL']['RADIO_ID'])
if _end: self.CALL_DATA.append(_tmp_data)
self.CALL_DATA.append(_data) if _end:
time.sleep(2) self.CALL_DATA.append(_data)
logger.info('(%s) Playing back transmission from subscriber: %s', _network, int_id(_src_sub)) time.sleep(2)
for i in self.CALL_DATA: logger.info('(%s) Playing back transmission from subscriber: %s', _network, int_id(_src_sub))
_tmp_data = i for i in self.CALL_DATA:
_tmp_data = _tmp_data.replace(_peerid, NETWORK[_network]['LOCAL']['RADIO_ID']) _tmp_data = i
_tmp_data = self.hashed_packet(NETWORK[_network]['LOCAL']['AUTH_KEY'], _tmp_data) _tmp_data = _tmp_data.replace(_peerid, NETWORK[_network]['LOCAL']['RADIO_ID'])
# Send the packet to all peers in the target IPSC _tmp_data = self.hashed_packet(NETWORK[_network]['LOCAL']['AUTH_KEY'], _tmp_data)
send_to_ipsc(_network, _tmp_data) # Send the packet to all peers in the target IPSC
time.sleep(0.06) send_to_ipsc(_network, _tmp_data)
self.CALL_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__': if __name__ == '__main__':

View File

@ -1,7 +1,28 @@
#!/usr/bin/env python #!/usr/bin/env python
# #
# THESE ARE THE THINGS THAT YOU NEED TO CONFIGURE TO USE playback.py # 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 TO LISTEN FOR AND REPEAT ON
TGID = 10 # Integer for the Talkgroup ID
# TIMESLOT TO LISTEN FOR AND REPEAT ON TGID = 12345
TS = 0 # 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)