# Script to allow switching of DMR network using a hardware switch # connected to a gpio pin # by Roger Clark VK3KYY / G4KYF # Before using this script you need to make backup copies of your DMR Marc # and Brandmeister mmdvmhost setting files into /home/pi-star/configs # the script assumes the files are called marc and bm # # You need to make the configs folder # e.g. # rpi-rw # mkdir /home/pistar/configs # # # To create these files. Use the Pi-Star configuration screen to switch to # DMR Marc, then copy /etc/mmdvmhost to /home/pi # cp /etc/mmdvmhost /home/pistar/configs/marc # Then reconfigure to Brandmeister and save that config # cp /etc/mmdvmhost /home/pistar/configs/bm #--------- Script code starts here ---------------------------------------- gpio mode 7 in # Set the lastVal to a non binary value to force the script to copy the # config set by the switch when the script starts, in case the switch # was changed when the script was not running, e.g. if the Raspberry Pi was # not powered up etc lastVal=-1 #Loop indefinitely while : do b=$(gpio read 7) if [ $b != $lastVal ] then lastVal=$b #need to mount the file system as read write #as it defaults to read only mount -o remount,rw / if [ $b -eq 1 ] then echo "Brandmeister mode" cp /home/pi-star/configs/bm /etc/mmdvmhost else echo "DMR MARC mode" cp /home/pi-star/configs/marc /etc/mmdvmhost fi mount -o remount,ro / systemctl restart mmdvmhost.service fi sleep 1 done