NOW WORKING!

This module records transmissions on an identified TGID and immediately
plays them back on the same IPSC, TS and TGID.
This commit is contained in:
Cort Buffington 2014-04-24 21:32:23 -05:00
parent 3e8177f80b
commit c3a33c7c85

View File

@ -10,13 +10,11 @@
# This is a sample application that "records" and replays transmissions for testing. # This is a sample application that "records" and replays transmissions for testing.
# THIS MODULE DOES NOT YET WORK!!!!!
from __future__ import print_function from __future__ import print_function
from twisted.internet import reactor from twisted.internet import reactor
from binascii import b2a_hex as h 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 from dmrlink import IPSC, UnauthIPSC, NETWORK, networks, logger, dmr_nat, int_id, send_to_ipsc
__author__ = 'Cortney T. Buffington, N0MJS' __author__ = 'Cortney T. Buffington, N0MJS'
@ -28,6 +26,9 @@ __maintainer__ = 'Cort Buffington, N0MJS'
__email__ = 'n0mjs@me.com' __email__ = 'n0mjs@me.com'
__status__ = 'pre-alpha' __status__ = 'pre-alpha'
# TGID to listen for and repeat on
TGID = '\x00\x00\x0A'
class playbackIPSC(IPSC): class playbackIPSC(IPSC):
def __init__(self, *args, **kwargs): 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): def group_voice(self, _network, _src_sub, _dst_sub, _ts, _end, _peerid, _data):
#_log = logger.debug if TGID == _dst_sub:
if not _end: if not _end:
_tmp_data = _data if not self.CALL_DATA:
#_tmp_data = dmr_nat(_data, _src_sub, NETWORK[_network]['LOCAL']['RADIO_ID']) logger.info('(%s) Receiving transmission to be played back from subscriber: %s', _network, int_id(_src_sub))
self.CALL_DATA.append(_tmp_data) _tmp_data = _data
if _end: #_tmp_data = dmr_nat(_data, _src_sub, NETWORK[_network]['LOCAL']['RADIO_ID'])
self.CALL_DATA.append(_data) self.CALL_DATA.append(_tmp_data)
time.sleep(2) if _end:
print() self.CALL_DATA.append(_data)
print('Repeating Group Voice Call ', h(_src_sub), ' ', h(_dst_sub) ,' ', h(_peerid), ' ', h(NETWORK[_network]['LOCAL']['RADIO_ID'])) 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 = self.hashed_packet(NETWORK[_network]['LOCAL']['AUTH_KEY'], i) for i in self.CALL_DATA:
# Send the packet to all peers in the target IPSC _tmp_data = i
send_to_ipsc(_network, _tmp_data) _tmp_data = _tmp_data.replace(_peerid, NETWORK[_network]['LOCAL']['RADIO_ID'])
print(_network, ' ', h(_tmp_data)) _tmp_data = self.hashed_packet(NETWORK[_network]['LOCAL']['AUTH_KEY'], _tmp_data)
time.sleep(0.05) # Send the packet to all peers in the target IPSC
self.CALL_DATA = [] send_to_ipsc(_network, _tmp_data)
time.sleep(0.06)
self.CALL_DATA = []
class playbackUnauthIPSC(playbackIPSC): class playbackUnauthIPSC(playbackIPSC):