Interfacing to a PSTN

9.1 DIGIUM WILDCARD X100P FXO PCI CARD
This card allows you to connect a POTS (plain Old Telephone
System) line to your Asterisk@Home box (See Notes for Patch
information).

If this card is added after Asterisk has been configured, it may be
necessary to configure it by using the zaptel card auto-config utility
so the correct zaptel driver will be set up. To do that, enter the
following from the command line.

rebuild_zaptel (restart after each command)

genzaptelconf (see notes re command switch)

Next go into the AMP web interface to create a trunk and you will
notice that there is already a trunk called ZAP/g0. You need to edit
this.

  1. Enter the phone number for you pots line in the Caller ID field
  2. Enter 1 for Maximum channels
  3. Set a dial rule you want for this trunk
  4. Select an outbound dial prefix to select this trunk when dialing
  5. Set the Zap Identifier to 1 (the default is g0)

Once the card is configured, you must add a route for Incoming Calls or asterisk will not answer this line

Click on Incoming Calls in AMP and set up an incoming route. To
make outbound calls you will need to set an outbound route as well.

If you have this card installed, you will need to edit the
following files; zapata.conf, zaptel.conf and modules.conf for AAH 1.x
or modprobe.conf for AAH 2.x. The last 2 files live in the /etc
directory – use a text editor to edit them.

9.1.1 zapata.conf
Under [channels] edit the following lines:

[channels]

busydetect=yes

busycount=6

For my installation to function correctly, I have also changed the
following setting to obtain a good compromise on volume/echoing:

rxgain=10.0 (you may have to experiment a little with this setting)

txgain=8.0 (you may have to experiment a little with this setting)

Ensure the following exist in zapata.conf. It is located at the end of the file.

;Include AMP Configs

channel => 1

#include zapata_additional.conf

Leave the rest of the file as it is.

9.1.2 zaptel.conf
Change the loadzone and defaultzone to 'au'

# Global data

loadzone = au

defaultzone = au

9.1.3 modules.conf (modprobe.conf for AAH 2.x)
For AAH 1.x, locate the post-install wcfxo entry and edit it to reflect this:

post-install wcfxo /sbin/ztcfg opermode=AUSTRALIA

For AAH 2.x, add the line highlighted in Bold below:

.

alias char-major-196 torisa

options wcfxo opermode=AUSTRALIA ; add this line

install tor2 /sbin/modprobe --ignore-install tor2 && /sbin/ztcfg

.

9.2 DIGIUM TDM400P FXO/FXS CARD
Like the Digium Wildcard X100P, this card allows you to connect a
POTS (plain Old Telephone System) line to your Asterisk@Home box.
Unlike the X100P, this card has 4 module ports that can be loaded with
FXS or FXO modules. Channel 1 is the top RJ-45 on the back of the
TDM400P card.

If this card is installed after Asterisk has been loaded, you will
need to configure it just like the X100P by using the following command
on the command line:

genzaptelconf

9.2.1 zapata-auto.conf
Next, using config edit, look in the zapata-auto.conf file and you
will see a list of all your channels in your TDM400P. Set up the trunks
as trunks and the extensions as extensions in AMP.

When you open the zapata_auto.conf file, it will look something like the illustration below (see the red highlight)

zapata-auto.conf

; Span 1: WCTDM/0 'Wildcard TDM400P REV E/F Board 1'

signaling=fxo_ks

; Note - this is an extension. Create a ZAP extension in AMP for Channel 1

channel => 1 < - -this would have been defined already by the config

signaling=fxs_ks

;Note - this is a trunk. Create a ZAP trunk in AMP for Channel 2

context=from-pstnchannel => 2 < - -this would have been defined already by the config

If in the illustration it shows channel 1 is your Zap extension
then add a zap extension for channel 1 in AMP and if it shows your Zap
trunk is channel 2 you should create a zap trunk for channel 2 in AMP.

Once this is done, reboot your PC and when Asterisk starts, use AMP
to add a route for incoming calls or asterisk will not answer your
trunk. Similarly, to make outbound calls you will need an outbound
route. Set them up as per setting up routes in the earlier chapters of
this document.

If you have this card installed, you will need to edit the
following files; zapata.conf and zaptel.conf as per the X100P card in
the previous section.

9.2.2 modules.conf (modprobe.conf for AAH 2.x)
You will need to edit the modules.conf, or modprobe.conf to add the necessary option for usage in Australia.

The example below is for AAH 1.x. where you need to add the following line;

options wctdm opermode=AUSTRALIA fxshonormode=1 bootstringer=1

Your modules.conf (AAH 1.x) should look like the example below:

alias eth0 e100

alias sound-slot-0 es1370

post-install sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -L >/dev/null 2>&1 || :

pre-remove sound-slot-0 /bin/aumix-minimal -f /etc/.aumixrc -S >/dev/null 2>&1 || :

alias usb-controller usb-uhci

alias char-major-196 torisa

options wctdm opermode=AUSTRALIA fxshonormode=1 boostringer=1

options torisa base=0xd0000

post-install tor2 /sbin/ztcfg

post-install torisa /sbin/ztcfg

post-install wcusb /sbin/ztcfg

post-install wcfxo /sbin/ztcfg

post-install wctdm /sbin/ztcfg

post-install ztdynamic /sbin/ztcfg

You will only need to add the line in red. Do not change anything else.

Or, in AAH Ver.2.1, you may also do the following:

Locate the line 'install wctdm /sbin/ztcfg-- --ignore-install wctdm
&& /sbin/ztcfg' and edit it to reflect the following:

install wctdm opermode=AUSTRALIA fxshonormode=1 boostringer=1 /sbin/ztcfg-- --ignore-install wctdm && /sbin/ztcfg

Note: as of Zaptel
Drivers 1.2.4, by selecting opermode=AUSTRALIA the zaptel drivers
automatically add the 'boostringer=1 , fxshonormode=1'

Also see Appendix E.3 (Users Suggestions)

9.3 REBUILDING ZAPTEL DRIVER
Every time there is a kernel update with yum (which is the case
with Asterisk and CentOS), ZAP device support needs to be rebuilt using
the new kernel. Unfortunately, this will cause a slight problem as
RedHat bug caused the rebuilding process to fail.

The following is the fix - source Nerd Vittles http://nerdvittles.com/index.php?p=123

Log into your new server as root and issue the following commands:

cd /usr/src/kernels/2.6.9-34.EL-i686/ include/linux

mv spinlock.h spinlock.h.old

wget http://nerdvittles.com/aah27/spinlock.h

Once the file has been retrieved, reboot using the following command:

shutdown -r now

When the reboot completes, you can start rebuilding the support for
your ZAP devices or for that matter, ztdummy if you don’t have any ZAP
devices.

Log in as root and type the following command:

rebuild_zaptel

Then reboot your system:

shutdown -r now

Now log in as root again and enter the following command:

amportal stop

genzaptelconf

Reboot once again:

shutdown -r now

..and you're done.

(See also user Users’ Suggestions)

9.4 SIPURA SPA3000 AS A PSTN INTERFACE
To those new to the SPA3000, there is a simplified installation
and configuration instruction by JMG Technology. While it is directed
mainly at standalone ATA users, it gives a good insight of the Sipura
SPA3000’s capabilities.

I have come across a few people in the various forums wanting to
use their Sipura SPA-3000s as FXO front-end to their Asterisk@Home
boxes. To help them in their endeavours, I've put the following
together, as no one single source of information that I've found so far
has a config that would actually work for me.

9.4.1 Log in to SPA3000
Login to your SPA-3000 as admin/advanced.

Before you change anything, I'd suggest taking a snapshot (i.e.
just save the .html page) of your current SPA-3000 configuration, just
in case you ever need to refer back to your own customisations.

If you're not already running the latest SPA-3000 firmware, then
upgrade it to the latest version (at the time of writing, it's 3.1.5a).
Take another snapshot for good measure. Nothing should have changed in
your settings, except that you have a few extra options that you didn't
have before.

Now reset SPA-3000 back to factory defaults, because I'm only going
to list the minimum changes required to keep things simple. Take
another snapshot now too, in case you ever want to know what the
defaults were.

9.4.2 Change the settings
System tab

DHCP: No

Static IP: something on your local subnet e.g.; 192.168.1.200

NetMask: 255.255.255.0

Gateway: your router's IP address e.g.; 192.168.1.254

Primary DNS: your ISP's primary DNS address e.g.; 203.12.160.35

Secondary DNS: your ISP's secondary DNS address e.g.; 203.12.160.36

Regional tab

Dial Tone: 400@-19,425@-19;10(*/0/1+2)

Busy Tone: 425@-10;10(.4/.4/1)

Reorder Tone: 425@-10;10(.2/.2/1)

Ring Back Tone: 400@-19,425@-19,450@-19;*(.4/.2/1+2+3,.4/.2/1+2+3,0/2/0)

Ring 1 Cadence: 60(1.5/3.4)

Ring 3 Cadence:
60(1.5/3.4,.4/.2,.4/2,.4/.2,.4/2,.4/.2,.4/2,.4/.2,.4/2,.4/.2,.4/2,.4/.2,.4/2,.4/.2,.4/2,.4/.2,.4/2,.4/.2,.4/2,.4/.2,.4/2)

CWT8 Cadence: 30(.2/.2,.2/4.4)

Hook Flash Timer Min: .07

Hook Flash Timer Max: .13

Delete all the Vertical Service Activation Codes.

FXS Port Impedance: 220+820||120nF

Line 1 tab

Proxy: IP address of your Asterisk box e.g.; 192.168.1.234

Register Expires: 60

Display Name: Whatever

User ID: Asterisk extension number e.g.; 200

Password: password for that extension

Silence Threshold: medium

DTMF Tx Method: INFO

Hook Flash Tx Method: INFO

Dial Plan: (*xx|000|0011xxxxxxxxxxx.|0[23478]xxxxxxxx|09xxxxxx|1100
|122[135]|1222xxxxxxx|12510[12]|12554|1[38]00xxxxxx|13[1-9]xxx
|1747xxxxxxx|2xx|393xxxxxx|3xxxx. |[4689]xxxxxxx|7777|899060xxxxx.) for
example

(*xx.|x.) will work, but I like to do a bit of sanity checking, etc.

PSTN Line tab (method 1)

Proxy: IP address of your Asterisk box e.g.; 192.168.1.234

Register: no

Make Call Without Reg: yes

Ans Call Without Reg: yes

Display Name: No name

User ID: PSTN

Password: password

Silence Supp Enable: no

Echo Canc Enable: no

Echo Canc Adapt Enable: no

Echo Supp Enable: no

FAX CED Detect Enable: yes

FAX CNG Detect Enable: yes

FAX Passthru Codec: G711u

FAX Codec Symmetric: no

FAX Passthru Method: None

DTMF Tx Method: INFO

FAX Process NSE: no

Dial Plan 1: (S0<:T0298765432>) for example

VoIP Caller Default DP: none

PSTN Ring Thru Line 1: no

PSTN CID For VoIP CID: yes

PSTN Answer Delay: 2

PSTN Ring Thru Delay: 3

PSTN Ring Timeout: 4

PSTN Hook Flash Len: .1

Disconnect Tone: 425@-30,425@-30;1(.375/.375/1+2)

FXO Port Impedance: 220+820||120nF

On-Hook Speed: 26ms (Australia)

(Source reference: Colin Swan)

Or alternatively you may want to adopt the second method for the PSTN Line Tab, which I am currently using.

PSTN Line tab (method 2)

Proxy: IP address of your Asterisk box e.g.; 192.168.1.234

Register: no

Make Call Without Reg: yes

Ans Call Without Reg: yes

Display Name: No name

User ID: PSTN

Password: password

Silence Supp Enable: no

Echo Canc Enable: no

Echo Canc Adapt Enable: no

Echo Supp Enable: no

FAX CED Detect Enable: yes

FAX CNG Detect Enable: yes

FAX Passthru Codec: G711u

FAX Codec Symmetric: no

FAX Passthru Method: None

DTMF Tx Method: INFO

FAX Process NSE: no

Dial Plan 1: (S0<:s@YourAsteriskIP>) e.g. (S0<:s@192.168.0.101:5060>)or try w/o the port designation

VoIP Caller Default DP: none

PSTN Ring Thru Line 1: no

PSTN CID For VoIP CID: yes

PSTN Answer Delay: 2

PSTN Ring Thru Delay: 3

PSTN Ring Timeout: 4

PSTN Hook Flash Len: .1

Disconnect Tone: 425@-30,425@-30;1(.375/.375/1+2)

FXO Port Impedance: 220+820||120nF

On-Hook Speed: 26ms (Australia)

Using this alternative method, you will not need to create an
Inbound Route for this channel as the call is sent directly to your “s‿
extension as defined in your incoming call setting. You may also get
CLID if your Telco has activated incoming Caller ID on your phone.

User 1 tab

Default Ring: 3

Default CWT: 8

9.4.3 Add SIP Trunk
Then in AMP, add a SIP trunk.

Outbound Caller ID: <0298765432> (for example)

Maximum Channels: 1

Dial Rules: 0+NXXXXXXXX (for example)

0011+ZXXXXXXXXXX.

Trunk Name: telstra (for example)

Peer Details:

canreinvite=no

context=from-pstn

host=the IP address of your SPA-3000 (for example; 192.168.1.200)

insecure=very

nat=no

port=5061 (for example)

qualify=yes

secret=password

type=peer

username=PSTN

User Context: telstra-incoming (for example)

User Details:

canreinvite=no

context=from-pstn

host=the IP address of your SPA-3000 (for example; 192.168.1.200)

insecure=very

nat=no

port=5061 for example

secret=password

type=user

username=PSTN

Leave "Register String" empty

Then add a DID Route of T0298765432 (for example), which goes to your chosen Destination. (Source reference: Colin Swan)

See the alternative configuration that I am currently using for the PSTN Tab in Notes

Also see Eliminating echo problems in Appendix E.4 in Sipura SPA-3000