Re: ASL to DMR Bridge...changing talkgroups


Michael Weaver - AC2VK
 

I didn't get Mike Z's code working out of the box and haven't had time to troubleshoot his yet.  My setup allows you to enter *8711 and then the talkgroup number you want to connect to.  the extenstions.conf will strip off the leading 1 and pass the variable into tg_connect.py.  The python script will read the ini, update txTg, write the ini file(side effect of removing all comments), and restart the analog bridge.  Backup your ini file first!

rpt.conf
871 = autopatchup,context=command_radio,noct=1,farenddisconnect=1,dialtime=20000,quiet=1

extensions.conf
[command_radio]
exten => _1X.,1,SayDigits(${EXTEN:1})
exten => _1X.,n,System(/scripts/tg_connect.py ${EXTEN:1})
exten => _1X.,n,Wait(2)
exten => _1X.,n,Hangup()

tg_connect.py
#!/usr/bin/env python
 
import sys
import socket
import struct
import os

#import parser
from ConfigParser import SafeConfigParser

#store cmd line arg
new_txTg = sys.argv[1]

#strip off first character
#new_txTg = new_txTg[1:]

#read config file
parser = SafeConfigParser()
parser.read('/opt/Analog_Bridge/Analog_Bridge.ini')
print "Existing talkgroup is: " + parser.get('AMBE_AUDIO', 'txTg')
print "Desired talkgroup is: " + new_txTg
 
#set config file
parser.set('AMBE_AUDIO', 'txTg', new_txTg)
 
#writing our configuration file to
with open('/opt/Analog_Bridge/Analog_Bridge.ini', 'wb') as configfile:
    parser.write(configfile)

#verify
parser.read('/opt/Analog_Bridge/Analog_Bridge.ini')
print "New talkgroup is: " + parser.get('AMBE_AUDIO', 'txTg')

#restart bridge
os.system('systemctl restart analog_bridge')

Join main@DVSwitch.groups.io to automatically receive all group messages.