3. Configuration

3.1. Asterisk modules

Make sure that the modules res_agi.so and format_sln.so are enabled on /etc/asterisk/modules.conf:

...
; Formats
load => format_sln.so
...
; Channels
load => res_agi.so
...

3.2. Groups permissions

Normally, Asterisk is run as asterisk user. Then, the phonepatch must also set its UID to asterisk, in other case it cannot be stopped and continued (using signals) from the asterisk process. As the phonepatch will load as asterisk user, we must assure that it has access to all hardware involved: soundcard, serial/parallel ports:

# ls /dev/dsp* /dev/ttyS* /dev/parport*
crw-rw----  1 root audio 14,  3 2006-07-04 09:33 /dev/dsp
crw-rw----  1 root dialout 4, 64 2006-07-04 11:32 /dev/ttyS0
crw-rw----  1 root lp 4, 64 2006-07-04 11:32 /dev/parport0

In that case, you should do:

usermod -G asterisk,audio,dialout,lp asterisk

3.3. Asterisk extensions

On the Asterisk extensions file configuration (/etc/asterisk/extensions.conf) we have to add all the radio stations for which we want to enable the phonepatch. Although not really necessary, it's recomendable that yout create a new context (for example: radio) for these special users.

On this example, we will asign extensions for PuertoSaija (151) and Munichis (152).

[radio]

; Phonepatch
exten => 151,1,Answer()
exten => 151,2,EAGI(phonepatch.agi|puertosaija)
exten => 151,3,Hangup

exten => 152,1,Answer()
exten => 152,2,EAGI(phonepatch.agi|munichis)
exten => 152,3,Hangup

This extensions are used in both ingoing and outgoing calls. If you plan to use anonymous calls (where the extension is only for ingoing calls), it's not necessary to add another extension. For simplicity, use the same context that you choose for the incoming calls:

[radio]

...

; Static outgoing extension
exten => 160,1,Answer()
exten => 160,2,EAGI(phonepatch.agi|outcall)
exten => 160,3,Hangup

3.4. Phonepatch configuration

Configuration file is place by default at /etc/asterisk/phonepatch. Global parameters and included in [general] section, options regarding a phonepatch (soundcard, PTT/Carrier) must be included in a [phonepatchname] section. Numeric sections are reserved to the phonepatch extensions.

When the phonepatch needs to get the value of a parameter, it searchs the configuration file in that order:

If you need to define more than one phonepatch, you have to specify another soundcard and PTT/Carrier interface. Example using 2 phonepatchs:

; Asterisk Phonepatch configuration

[phonepatch1]

soundcard_device=/dev/dsp
soundcard_samplerate=8000
soundcard_latency=0.01
ptt=off
carrier_detection=off
radio_control=serial[dtr,dsr,rts]:/dev/ttyUSB0
outcall_daemon=enabled

[phonepatch2]

outcall_daemon=off
soundcard_device=/dev/dsp1
soundcard_samplerate=8000
soundcard_latency=0.05
ptt=off
carrier_detection=off
radio_control=serial[dtr,dsr,rts]:/dev/ttyUSB1

[general]

language="es"
sounds_dir="/usr/share/asterisk-phonepatch/sounds/"
spool_dir="/var/spool/asterisk/outgoing/"

dtmf_noisy_mode_button=
dtmf_sensibility=1.0

festival_audio_gain=5.0
telephony_audio_gain=1.0
radio_audio_gain=1.0

carrier_polling_time=0.5
carrier_threshold_signal=0.1
carrier_tail_time=2
carrier_max_time=20
carrier_wait_time=5
full_duplex=off

ptt_threshold_signal=0.01
ptt_tail_time=2
ptt_max_time=30
ptt_wait_time=5
ptt_txdelay=0.5

ctcss_tx_amplitude=0.001

hangup_button=#
end_audio=php_endcall.ogg
call_limit=600

incall_report_audio=@%d
incall_report_audio_wait=5
incall_report_timeout=60
incall_report_timeout_audio=php_notanswered.ogg

incall_answer_mode=dtmf
incall_answer_button=*

outcall_channel = IAX2/guest:violin@localhost

outcall_context=metadistro
outcall_timeout=10
outcall_priority=1

askfortone_button="*"
tone_audio=php_tone.ogg
tone_audio_time=3
tone_timeout=20
tone_timeout_audio=php_timeoutcall.ogg
outcall_button="*"
clear_button="#"

ring_audio=php_ring.ogg
ring_audio_time=1
ring_audio_wait=3
ring_timeout_audio=php_ringtimeout.ogg

ctcss_tx=
ctcss_rx=
outcall=on
incall=on
name=default
phonepatch=phonepatch1

outcall_askfortone_mode=dtmf
outcall_dmtf_extension_mode=on

[puertosaija]
name="estacion puertosaija"
ctcss_tx=1Z
ctcss_tx_amplitude=0.02
outcall_dtmf_id=1
outcall_extension=151
incall_answer_mode=ctcss
phonepatch=phonepatch2

[munichis]
name="estacion munichis"
outcall_dtmf_id=2
outcall_extension=152
ctcss_rx=200.0
ctcss_tx_amplitude=0.02
ctcss_tx=150.0

As base configuration file, you can also use the example located at /usr/share/asterisk-phonepatch/phonepatch.conf.example. Copy it to /etc/asterisk/phonepatch.conf and costumize it. Take a look on the manual page (man phonepatch.conf) to see a detailed explanation of all the variables. Default values are good for most situations, but take care on the following ones: