This is an old revision of the document!
Here is what I did, to get started..
SSH pi@192.168.0.xx
Windows users can use putty.exe for SSH. Password is raspberry.
raspi-config
and adjust GPU memory to 16mb, this is found under the advanced settings.
sudo su
to enable root, then change root password with
passwd
follow the prompts and set the password to your preference.
reboot
SSH root@192.168.0.xx
The password will be what you created int step 8.
lsusb
and you should see something like this listed.
Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter
nano /etc/network/interfaces
and make it look something like this.
auto lo
iface lo inet loopback
iface eth0 inet dhcp
allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "SSID"
wpa-psk "WPA-PSK"
ifup wlan0
then do
ifconfig wlan0
In the ifconfig report you will see the IP of your wifi interface as the inet address. Do
reboot
pull the Cat5 cable and SSH to Pi on wifi IP. That done we can move onto the next step..
We need some additional software.. Now is the time to install it.
apt-get update && apt-get upgrade
to update the Pi to the latest version.
apt-get install mpg123
to install the mpg123 player that the scripts use to play the news files.
apt-get install mp3gain
to install mp3gain used to normalise file levels.
apt-get install ssmpt
to install the email software.
I have used a 8gb USB drive to store files on rather than using the SD card. Probably for no good reason.
nano /etc/fstab
/dev/sda1 /media/USB ext4 defaults
mount -a
I have 3 scripts doing the work. One gets the files and prepares them, the next puts the repeater into broadcast mode and the third plays the files.
getnews.sh
<code>#!/bin/bash
# Set directory
NEWS="/media/USB"
LOG=$NEWS/log/getlog.txt
# Set date for file naming
DATE=`date +"%Y-%m-%d"`
# WIA file name
WIAFILENAME="wianews-`date +"%Y-%m-%d"`.mp3"
# Change directory
cd $NEWS
writelog ()
{
MESSAGE="`date '+%b %d %Y %T'` "$@
echo $MESSAGE >> $LOG
}
# Get WIA file
/usr/bin/wget http://www.wia-files.com/podcast/$WIAFILENAME && writelog "Got WIA file OK" || writelog "Download WIA file failed!"
cp $WIAFILENAME $NEWS/archive/wianews-$DATE.mp3 && writelog "Archived WIA file OK" || writelog "Archive WIA file failed!"
rm wianews.mp3 && writelog "Removed last weeks WIA file OK" || writelog "Remove last weeks WIA file failed!"
mv $WIAFILENAME wianews.mp3 && writelog "Rename WIA file to generic name OK, file prepared :)" || writelog "Rename WIA file to generic name failed!"
# Get VK7 file
/usr/bin/wget http://www2.vk7ax.id.au/wianews/VK7Regional.mp3 && writelog "Got VK7 file OK" || writelog "Download VK7 file failed!"
cp VK7Regional.mp3 $NEWS/archive/tasnews-$DATE.mp3 && writelog "Archived WIA file OK" || writelog "Archive WIA file failed!"
rm tasnews.mp3 && writelog "Removed last weeks VK7 file OK" || writelog "Remove last weeks VK7 file failed!"
mv VK7Regional.mp3 tasnews.mp3 && writelog "Rename VK7 file to generic name OK, file prepared :)" || writelog "Rename VK7 file to generic name failed!"
exit 0
</code>
bcmode.sh
This gets played about 10 mins before start time
<code>#!/bin/bash
# Set news directory
NEWS="/media/USB"
# Set pause time value
pause=1
# Change directory
cd $NEWS
# Set up GPIO 17 and set to PTT output
echo "17" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio17/direction
# Set up GPIO 18 and set to COR input
echo "18" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio18/direction
# Broadcast mode function
bcmode()
{
# PTT up
echo "1" > /sys/class/gpio/gpio17/value
# Wait a while
sleep $pause
# Play VK7DB
mpg123 $NEWS/VK7DB.mp3
# Wait a while
sleep $pause
# Play timeout disable
mpg123 $NEWS/bcmode.mp3
# Wait a while
sleep $pause
# PTT down
echo "0" > /sys/class/gpio/gpio17/value
# Goto end
end
}
# End function
end()
{
# Clean up
echo "17" > /sys/class/gpio/unexport
echo "18" > /sys/class/gpio/unexport
exit 0
}
# Main loop
while :
do
value=`cat /sys/class/gpio/gpio18/value`
if [ $value -eq 0 ]; then
bcmode
fi
done
# Goto end
end
</code>
playnews.sh
<code>
#!/bin/bash
# Set directory
NEWS="/media/USB"
LOG=$NEWS/log/playlog.txt
writelog ()
{
MESSAGE="`date '+%b %d %Y %T'` "$@
echo $MESSAGE >> $LOG
}
# Set pause time value
pause=1
thirty=30
# Change directory
cd $NEWS
# Set up GPIO 17 and set to output
echo "17" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio17/direction
# Wait 30 seconds
sleep $thirty
# PTT up
echo "1" > /sys/class/gpio/gpio17/value && writelog "PTT up" || writelog "PTT fail!"
# Wait a 30 seconds
sleep $thirty
# Play WIA news
writelog "Play WIA news start"
mpg123 $NEWS/wianews.mp3 && writelog "WIA play finished" || writelog "WIA play fail!"
# Play Tas news
writelog "Play VK7 news start"
mpg123 $NEWS/tasnews.mp3 && writelog "VK7 play finished" || writelog "WIA play fail!"
# Wait a while
sleep $pause
# Play timeout enable
writelog "Enable timeout start"
mpg123 $NEWS/26501.mp3 && writelog "Enable timeout done" || writelog "Enable timeout fail!"
# Wait a while
sleep $pause
# Play VK7DB
writelog "Play VK7DB start"
mpg123 $NEWS/VK7DB.mp3 && writelog "Play VK7DB done" || writelog "Play VK7DB fail!"
# PTT down
echo "0" > /sys/class/gpio/gpio17/value && writelog "PTT down" || writelog "PTT down fail!"
# Clean up GPIO
echo "17" > /sys/class/gpio/unexport
exit 0
</code>
getraotc.sh
I have also written a script to get the RAOTC file, should Winston not be able to run it.
<code>#!/bin/bash
# Set directories
NEWS="/media/USB"
LOG=$NEWS/log/getlog.txt
# Set date for file naming
DATE=`date +"%Y-%m-%d"`
# Set file naming
RAOTC=`date +%B%Y`.wma
RAOTC=${RAOTC,,} # convert to lower case
# Change directory
cd $NEWS
writelog ()
{
MESSAGE="`date '+%b %d %Y %T'` "$@
echo $MESSAGE >> $LOG
}
# Get RAOTC file
/usr/bin/wget http://www.raotc.org.au/Audio_files/$RAOTC && writelog "Got RAOTC file OK" || writelog "Download RAOTC file failed!"
cp $RAOTC $NEWS/archive/raotc-$DATE.wma && writelog "Archived RAOTC file OK" || writelog "Archive RAOTC file failed!"
rm raotc.wma && writelog "Removed last weeks RAOTC file OK" || writelog "Remove last weeks RAOTC file failed!"
mv $RAOTC raotc.wma && writelog "Rename RAOTC file to generic name OK, file prepared :)" || writelog "Rename RAOTC file to generic name failed!"
exit 0
</code>
playraotc.sh
<code>
#!/bin/bash
# Set news directory
NEWS="/media/USB"
# Set pause time value
pause=1
# Change directory
cd $NEWS
# Set up GPIO 17 and set to output
echo "17" > /sys/class/gpio/export
echo "out" > /sys/class/gpio/gpio17/direction
# PTT up
echo "1" > /sys/class/gpio/gpio17/value
# Play WIA news
mplayer $NEWS/raotc.wma
# Wait a while
sleep $pause
# Timeout enable
mpg123 $NEWS/26501.mp3
# Wait a while
sleep $pause
# Play VK7DB
mpg123 $NEWS/VK7DB.mp3
# PTT down
echo "0" > /sys/class/gpio/gpio17/value
# Clean up GPIO
echo "17" > /sys/class/gpio/unexport
exit 0
</code>
These scripts are scheduled with cron
<code># m h dom mon dow command @reboot /usr/bin/amixer set PCM 4dB unmute >/dev/null 2>&1 0 05 * * 0 /media/USB/getnews.sh >/dev/null 2>&1 50 08 * * 0 /media/USB/bcmode.sh >/dev/null 2>&1 59 08 * * 0 /media/USB/playnews.sh >/dev/null 2>&1 50 19 * * 2 /media/USB/bcmode.sh >/dev/null 2>&1 59 19 * * 2 /media/USB/playnews.sh >/dev/null 2>&1 </code>
Just for something to do, I made another script log repeater usage to a file and echo it to the screen.
<code>#!/bin/bash
NEWS=/media/USB
LOGDIR=$NEWS/log
CORLOG=corlog.txt
# Set up GPIO 18 and set to COR input
echo "18" > /sys/class/gpio/unexport
echo "18" > /sys/class/gpio/export
echo "in" > /sys/class/gpio/gpio18/direction
writeopen ()
{
echo; echo
echo "Mute opened at `date`"
echo "Mute opened at `date`" >> $LOGDIR/$CORLOG
}
writeclosed ()
{
echo "Mute closed at `date`"
echo "Mute closed at `date`" >> $LOGDIR/$CORLOG
echo >> $LOGDIR/$CORLOG
loop
}
loop ()
{
while :
do
cor=`cat /sys/class/gpio/gpio18/value`
if [ $cor -eq 1 ]; then
writeopen
while :
do
cor=`cat /sys/class/gpio/gpio18/value`
if [ $cor -eq 0 ]; then
writeclosed
fi
done
fi
done
}
loop
</code>
+==Footnote==+ I set the audio output of the Pi to 100% on startup and adjust level inside the modified PRM8010. This is done in cron
@reboot /usr/bin/amixer set PCM 4dB unmute >/dev/null 2>&1
GPIO 18 is used as an input, it looks at the output of the CTCSS decoder in the receiver of the PRM8010.. When the repeater user stops transmission, the repeater tone encoder stops. Monitoring of the repeater mute allows the bcmode script to be polite if the repeater is in use.
The next trick will be to write errors to a separate error log file and email me the error log only if it exists.. If something has failed I can fix it, otherwise I don't need to know about it..
Special mention must be made of Matt VK3VS for thanks for his ideas and scripting assistance with this project.
Since I'm new to all of this, if someone can see a better or different way to do things, I'd be happy to know.
Dion.