Enhancements/Scripts
This page includes some enhancements and scripts that extend the functionality of an Asterisk/app_rpt based repeater.
Streaming NOAA
The following steps will provide a way to stream NOAA weather on the repeater using an MP3 audo stream, accessible via autopatch, for your area.
Tested with: Asterisk 1.4.20, app_rpt rev. 166566, madplay 0.15.1
Additional software: wget, madplay
First, locate an audio stream for the city closest to your location from here: http://www.nws.noaa.gov/nwr/streamaudio.htm
Next, click on the name of the city (in the following examples, we're going to use Erie, PA). You'll be taken to a page the contains a URL like the following:
http://audioplayer.wunderground.com/dmcarter/Eriepa.mp3.m3u
The page may generate a popup to download/save the stream, just close it. Thake the above URL and remove the ending .m3u; we're only interested in that actual MP3 stream, which in this example is:
http://audioplayer.wunderground.com/dmcarter/Eriepa.mp3
Now, login to your Asterisk/app_rpt box via SSH and perform the following commands:
# cd /etc/asterisk
# nano noaa-erie.sh
(contents of noaa-erie.sh; use the stream URL you found above)
#!/bin/bash
/usr/bin/wget -q -O - http://audioplayer.wunderground.com:80/dmcarter/Eriepa.mp3 | \
/usr/bin/madplay -Q -z -o raw:- --mono -R 8000 -A -10 -
Save the file and run the following:
# chmod +x noaa-erie.sh
Now edit the musiconhold.conf file and add the following:
[noaa-erie]
mode=custom
directory=/var/lib/asterisk/mohmp3-noaa-erie
application=/etc/asterisk/noaa-erie.sh
Save the file. Let's create the MOH directory and emtpy file for our stream:
# mkdir /var/lib/asterisk/mohmp3-noaa-erie
# touch /var/lib/asterisk/mohmp3-noaa-erie/0.mp3
Finally, we need to modify our dialplan to stream the NOAA broadcast over the air. Edit the extension.conf file:
# nano extensions.conf
Add the following in the context that is set in rpt.conf for autopatch calls, in this case it's 'radio':
; NOAA Broadcast
; erie
exten => 998,1,wait(1)
exten => 998,n,setmusiconhold(noaa-erie)
exten => 998,n,waitmusiconhold(3600)
exten => 998,n,playback(goodbye)
exten => 998,n,hangup
The extension (998) can be anything you want. Save the file. The above will start the MOH audio stream and continue playing for 60 minutes. Now, reload Asterisk's dialplan and MOH, or completely restart Asterisk:
# asterisk -rx "dialplan reload"
# asterisk -rx "moh reload"
How to make it work... Start by dialing your access code for making an autopatch. Now dial 998 (or whatever extension you used in extensions.conf above. The NOAA broadcast will start playing over the repeater. When you want to drop the playback, just dial the autopatch dump code.
If the audio amplitude is too low or high, you can adjust it by editing the following in noaa-erie.sh:
/usr/bin/madplay -Q -z -o raw:- --mono -R 8000 -A -10 -
Change the '-10' after the '-A' flag to adjust the audio, ie.:
/usr/bin/madplay -Q -z -o raw:- --mono -R 8000 -A -20 -
will decrease the streaming audio amplitude.
This feature can be extended to any number of streams; now that you know the steps for one, you can figure out the rest.
- Eric NO3M