Re: ASL to DMR Bridge...changing talkgroups


Steve N4IRS
 

we are behind in documenting a LOT of what the different programs will do. mea culpa

Here is a shell script for changing TGs on the fly when using Analog_Bridge and MMDVM bridge connected to BM.

#!/bin/bash

# /*
#  * Copyright (C) 2018 N4IRR
#  *
#  * Permission to use, copy, modify, and/or distribute this software for any
#  * purpose with or without fee is hereby granted, provided that the above
#  * copyright notice and this permission notice appear in all copies.
#  *
#  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
#  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
#  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
#  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
#  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
#  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
#  * PERFORMANCE OF THIS SOFTWARE.
#  */

function tune() {
python - <<END
#!/usr/bin/env python

import sys
import socket
import struct

cmd = "txTg=$1"
_sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
cmd = struct.pack("BB", 0x05, len(cmd))[0:2] + cmd
# Set the second value below to match the rxPort in the [AMBE_AUDIO] stanza of Analog_Bridge.ini
_sock.sendto(cmd, ('127.0.0.1', 31100))
_sock.close()

END
}

tune $1

Don't forget to mark the script executable chmod +x tune.sh
Assuming the script is named tune.sh and the rxPort is set to 31100 in Analog_bridge.ini start the program with:
./tune.sh 1234
Where the desired TG is 1234
Send a quick PTT on the analog side and you will be tuned to TG 1234

There is quite a list of possible commands available. Some are dependent on the mode. Along with the other 1001 things we need to do we will try to get the info out.

Steve N4IRS

On 11/13/2018 5:08 PM, Michael Weaver wrote:
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.