From c3a33c7c859acb8949c963df6ce3cef8ebafcc79 Mon Sep 17 00:00:00 2001 From: Cort Buffington Date: Thu, 24 Apr 2014 21:32:23 -0500 Subject: [PATCH] NOW WORKING! This module records transmissions on an identified TGID and immediately plays them back on the same IPSC, TS and TGID. --- playback.py | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/playback.py b/playback.py index 7fb5a16..647bb16 100755 --- a/playback.py +++ b/playback.py @@ -10,13 +10,11 @@ # This is a sample application that "records" and replays transmissions for testing. -# THIS MODULE DOES NOT YET WORK!!!!! - from __future__ import print_function from twisted.internet import reactor from binascii import b2a_hex as h -import time +import sys, time from dmrlink import IPSC, UnauthIPSC, NETWORK, networks, logger, dmr_nat, int_id, send_to_ipsc __author__ = 'Cortney T. Buffington, N0MJS' @@ -28,6 +26,9 @@ __maintainer__ = 'Cort Buffington, N0MJS' __email__ = 'n0mjs@me.com' __status__ = 'pre-alpha' +# TGID to listen for and repeat on +TGID = '\x00\x00\x0A' + class playbackIPSC(IPSC): def __init__(self, *args, **kwargs): @@ -39,23 +40,25 @@ class playbackIPSC(IPSC): #************************************************ def group_voice(self, _network, _src_sub, _dst_sub, _ts, _end, _peerid, _data): - #_log = logger.debug - if not _end: - _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) - print() - print('Repeating Group Voice Call ', h(_src_sub), ' ', h(_dst_sub) ,' ', h(_peerid), ' ', h(NETWORK[_network]['LOCAL']['RADIO_ID'])) - for i in self.CALL_DATA: - _tmp_data = self.hashed_packet(NETWORK[_network]['LOCAL']['AUTH_KEY'], i) - # Send the packet to all peers in the target IPSC - send_to_ipsc(_network, _tmp_data) - print(_network, ' ', h(_tmp_data)) - time.sleep(0.05) - self.CALL_DATA = [] + if TGID == _dst_sub: + 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 = [] class playbackUnauthIPSC(playbackIPSC):