IP04 Adventures - Day 3

I've read through the Asterisk book, and feel ready to try my hand at configuring the IP04. The first thing I want to do is configure the device to answer my telephone, and transfer incoming calls to which ever extension picks up first. Simple, yes? Not so fast...

OK, this does look simple. According to the book, I have to do two things:

  1. configure the FXO port to use a different dialplan from all the FXS ports. This way, I can write logic to intercept and redistribute incoming calls without disrupting the configuration of all the extensions, and I can give incoming calls a different (and possibly more restricted) set of capabilities (wrt extensions, etc.) than the internal phones have, and
  2. configure a dialplan specific to incoming calls.

First, the FXO configuration. The /etc/asterisk/zapata.conf configuration file assigns the default dialplans for each of the four physical devices. Originally, the file contained code that looked like:

[channels]
context=default
...

signalling = fxs_ks
channel => 1
signalling = fxo_ks
channel => 2,3,4

I have to modify this so that channel 1 (the FXO) gets a different context than channels 2, 3, and 4 (the 3 FXS channels). The default context (defined in /etc/asterisk/extensions.conf) gives the channel a lot of power and does things that I don't want the incoming PSTN calls to do. So, I change this file to now contain:

[channels]
context=default
...

; 1 x FXO connected to the incoming PSTN telephone line
context = incoming
signalling = fxs_ks
channel => 1

; 3 x FXS connected to the local extension phones
context = default
signalling = fxo_ks
channel => 2,3,4

That should do it; any calls coming in over the PSTN will use the incoming context and not the default context.

I now alter the /etc/asterisk/extensions.conf to include an incoming context. The context will pick up the PSTN line, and distribute the call to all three of the attached extension phones. If none of the extensions pick up, the context will play a little audio blurb telling the caller that no one can answer the call, and then it will hang up the phone. And, if all the extensions are busy, the context will play an audio busy signal, and hang up the phone.


[incoming]
exten => s,1,Answer()
exten => s,2,Dial(ZAP/2&ZAP/3&ZAP/4,5,r)
exten => s,3,Playback(vm-nobodyavail)
exten => s,4,Hangup
exten => s,103,Playback(tt-allbusy)
exten => s,104,Hangup

Both changes made, we shutdown and restart Asterisk and test this sucker. With the FXO port plugged into the wall jack, and an extension phone plugged into one of the FXS ports, I call my home phone number from my cell. The house phones ring, and I can see from the LED on the IP04 that the FXO port detects the ring. But the IP04 doesn't answer the phone.

OK, something is wrong. Perhaps I have to do more than just restart Asterisk to get my changes to take. So, I power cycle the IP04 and try again. And again the IP04 refuses to answer the phone.

I go back to zapata.conf and find that my carefully crafted change that gives the FXO port a different context than the FXS ports has been clobbered. So, something is rebuilding zapata.conf as I go. I reimplement my changes, change the file to read-only, and reboot the machine. Again, the file reverts back to a half-configured state.

Long story short, the /etc/rc.d/S40zaptel script (aka /etc/init.d/zaptel) invokes a utility called zapscan which rebuilds the zapata.conf each time the script is run. I comment out this utility, and my zapata.conf configuration no longer changes.

But, the IP04 still does not answer the phone!

Using the Asterisk console, I find that Asterisk still won't use my new incoming context for the Zap/1 (FXO) channel. Instead, on all four channels, it uses a context called numberplan-local. I didn't expect this, so now I have to go searching for the configuration file that overrides my assignment with numberplan-local.

grep finds that the /etc/asterisk/users.conf file contains settings for each of the ports, assigning them all to numberplan-local. I comment out the entire [6001] stanza that controls port 1 (the FXO port), and reboot the machine.

Now my test works! I call my home phone from my cell. After one ring, the IP04 picks up the call, and rings all my attached extension phones. If I don't answer one of the extensions, I hear (on my cell) a lovely voice telling me that "no one is available to take my call", and then the phone hangs up. Marvellous! That's exactly what I wanted!

Now, I can go back to the books, and plan my extensions and features. Next instalment, I'll try a few embellishments, and perhaps even add a VoIP channel or two.


Addendum:

I "Searched The Fine Web", and "Read The Fine Manual", and found out a bit about the users.conf file. Support for this file was added to Asterisk, in order to streamline the operation of the "Asterisk GUI". The contents of users.conf overrides and augments the settings in all the other configuration files; users.conf is meant to be the "central" configuration file used by the GUI, and it's contents override the other files. From my reading, Asterisk should run fine without this file, falling back to the settings found in the various other config files. So, I might just temporarily remove users.conf from the IP04 configuration, and hand-configure the rest of the system to my liking. When I get as far as trying the "Asterisk GUI", I'll see what I can do with the users.conf file.