Add reread_subscribers remote control command
This commit is contained in:
parent
90da9014ea
commit
2092f2a1e5
|
@ -16,8 +16,9 @@ from bitstring import BitArray
|
||||||
|
|
||||||
import sys, socket, ConfigParser, thread, traceback
|
import sys, socket, ConfigParser, thread, traceback
|
||||||
import cPickle as pickle
|
import cPickle as pickle
|
||||||
from dmrlink import IPSC, NETWORK, networks, logger, int_id, hex_str_3, get_info, talkgroup_ids, subscriber_ids, peer_ids
|
from dmrlink import IPSC, NETWORK, networks, logger, int_id, hex_str_3, get_info, talkgroup_ids, subscriber_ids, peer_ids, PATH
|
||||||
from time import time
|
from time import time
|
||||||
|
import csv
|
||||||
|
|
||||||
__author__ = 'Cortney T. Buffington, N0MJS'
|
__author__ = 'Cortney T. Buffington, N0MJS'
|
||||||
__copyright__ = 'Copyright (c) 2015 Cortney T. Buffington, N0MJS and the K0USY Group'
|
__copyright__ = 'Copyright (c) 2015 Cortney T. Buffington, N0MJS and the K0USY Group'
|
||||||
|
@ -84,7 +85,6 @@ class ambeIPSC(IPSC):
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
print( "Error: unable to start thread" )
|
print( "Error: unable to start thread" )
|
||||||
|
|
||||||
|
|
||||||
# Utility function to convert bytes to string of hex values (for debug)
|
# Utility function to convert bytes to string of hex values (for debug)
|
||||||
def ByteToHex( self, byteStr ):
|
def ByteToHex( self, byteStr ):
|
||||||
return ''.join( [ "%02X " % ord(x) for x in byteStr ] ).strip()
|
return ''.join( [ "%02X " % ord(x) for x in byteStr ] ).strip()
|
||||||
|
@ -176,11 +176,21 @@ class ambeIPSC(IPSC):
|
||||||
self._sock.sendto(_ambe_frame3.tobytes(), (self._gateway, self._gateway_port))
|
self._sock.sendto(_ambe_frame3.tobytes(), (self._gateway, self._gateway_port))
|
||||||
|
|
||||||
|
|
||||||
|
def reread_subscribers(self):
|
||||||
|
try:
|
||||||
|
with open(PATH+'subscriber_ids.csv', 'rU') as subscriber_ids_csv:
|
||||||
|
subscribers = csv.reader(subscriber_ids_csv, dialect='excel', delimiter=',')
|
||||||
|
subscriber_ids = {}
|
||||||
|
for row in subscribers:
|
||||||
|
subscriber_ids[int(row[0])] = (row[1])
|
||||||
|
print('Subscriber file has been updated')
|
||||||
|
except ImportError:
|
||||||
|
logger.warning('subscriber_ids.csv not found: Subscriber aliases will not be available')
|
||||||
|
|
||||||
#
|
#
|
||||||
# Define a function for the thread
|
# Define a function for the thread
|
||||||
# Use netcat to dynamically change the TGs that are forwarded to Allstar
|
# Use netcat to dynamically change the TGs that are forwarded to Allstar
|
||||||
# echo "x,y,z" | nc 127.0.0.1 1235
|
# echo -n "x,y,z" | nc 127.0.0.1 1235
|
||||||
#
|
#
|
||||||
def remote_control(self, port):
|
def remote_control(self, port):
|
||||||
s = socket.socket() # Create a socket object
|
s = socket.socket() # Create a socket object
|
||||||
|
@ -193,13 +203,16 @@ class ambeIPSC(IPSC):
|
||||||
c, addr = s.accept() # Establish connection with client.
|
c, addr = s.accept() # Establish connection with client.
|
||||||
print( 'Got connection from', addr )
|
print( 'Got connection from', addr )
|
||||||
tgs = c.recv(1024)
|
tgs = c.recv(1024)
|
||||||
|
print('Command:"{}"'.format(tgs))
|
||||||
if tgs:
|
if tgs:
|
||||||
self._tg_filter = map(int, tgs.split(','))
|
if tgs == 'reread_subscribers':
|
||||||
print( 'New TGs=', self._tg_filter )
|
self.reread_subscribers()
|
||||||
|
else:
|
||||||
|
self._tg_filter = map(int, tgs.split(','))
|
||||||
|
print( 'New TGs=', self._tg_filter )
|
||||||
c.close() # Close the connection
|
c.close() # Close the connection
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
logger.info('DMRlink \'ambe_audio.py\' (c) 2015 N0MJS & the K0USY Group - SYSTEM STARTING...')
|
logger.info('DMRlink \'ambe_audio.py\' (c) 2015 N0MJS & the K0USY Group - SYSTEM STARTING...')
|
||||||
for ipsc_network in NETWORK:
|
for ipsc_network in NETWORK:
|
||||||
|
|
Loading…
Reference in New Issue