The CISCO (or even Netgear) SPA-3102 was a Voice Gateway device, used to convert between the POTS (Plain Old Telephone System) and a VOIP server. The device is very much end-of-life, and although not sold new, is widely available and still very popular.

There are many online guides for using the SPA-3102, but since it can be used in many countries and with many different platforms, it can be quite different to get working. Even with a UK guide, I found it impossible to follow them to set up with recent versions of Asterisk, and even when they did work, the device could not pass on Caller ID. This guide is possibly also suitable for the SPA-112 and with Asterisk and other Asterisk-based PBX platforms.

This guide concentrates on the configuration and arrangement between SPA-3102 and FreePBX. It assumes your device is already configured for your LAN network and for the UK Telephone network. If this is not the case, reset your device or check the manual and the configuration below

What is working:

  • Making calls from a VOIP device or softphone, via FreePBX to the SPA-3102 as an outgoing trunk
  • Making calls from an attached analogue telephone to the SPA-3102 and using this as to make VOIP calls via FreePBX
  • Receiving incoming calls from the SPA-3102, and forwarding them to FreePBX, including using Ring Groups, Voicemail, and Caller ID
  • Sending and receiving faxes

What is not working:

  • Nothing known

 

Quick Tips

There’s a lot of misinformation online about what you should and shouldn’t do. To clear some of these up;

  • Do use a proper UK telephone cable, as short as possible and with all four wires connected (I have had problems with 2-wire and 3-wire extensions).
    To quickly see if things seem okay, whilst on-hook, in the Admin > Advanced > Voice > Info screen, the PSTN Hook State should be On (not Ringing!), and line voltage should be around 50V.
  • You do not need to use the WAN socket for your LAN as some advise. The VOIP ports are available on both. The device can even act as a NAT and DHCP server (only the right way around!).
    The only minor annoyance is that there’s no LED on the front for LAN, only for WAN.
  • Use PJSIP, and use the same username for both sides. Set FreePBX to Send Registration and Authenticate going Outbound.

 

Troubleshooting

To quickly check everything is in order; on the Admin > Advanced > Voice > Info screen, the PSTN Hook State should be On and the Line voltage should be around 50V.
If not, your cable is likely faulty or missing wires.

If your telephone is constantly showing that a message is waiting, under the Admin > Advanced > User 1 menu, under Supplementary Service Settings set Message Waiting to No.

We are authenticating the SPA-3102 using IP address for calls coming in from the Landline, rather than Auth ID. This is because the SPA-3102 will use the Caller ID as the Auth ID for incoming calls, and this causes authentication to fail. This should be solved with the Remote-Party-ID, but this doesn’t seem to allow auth with FreePBX.

If you see the error WARNING[14004] res_pjsip_registrar.c: AOR 'pstn_fxo' has no configured max_contacts. Endpoint 'pstn_fxo' unable to register, this appears to be only set in the Asterisk config in FreePBX when registration is being received. Asterisk requires max_contacts for registration with sending too, or this error occurs. I was not able to fix this with pjsip.aor_custom.conf as expected. As a temporary fix, adding the appropriate max_contacts array element ($conf['pjsip.aor.conf'][$tn]['max_contacts'] = 1;) into the other side of the conditional (for send/none, before the else) on line 63 of /var/www/html/admin/modules/core/functions.inc/drivers/PJSip.class.php will solve this.

 

SPA-3102 Configuration

Configuration is really straightforward here – we’re using the same username and port on both Line 1 and the PSTN Line;

Admin login > Advanced > Voice > Line 1:

  • Line Enable: Yes
  • SIP Transport: UDP
  • SIP Port: 5160
  • SIP Remote-Party-ID: Yes
  • Auth Invite: Yes
  • Proxy: [set to FreePBX IP]
  • Register: Yes
  • User ID: pstn_fxo
  • Auth ID: pstn_fxo
  • Use Auth ID: Yes
  • Password: password

So what we’ve done here is to set the Line 1 (i.e. the analogue telephone connected to the SPA-3102) to allow to register as a VOIP device to the FreePBX server. This lets you make calls from the telephone to the VOIP server.

Admin login > Advanced > Voice > PSTN Line:

  • Line Enable: Yes
  • SIP Transport: UDP
  • SIP Port: 5060
  • SIP Remote-Party-ID: Yes
  • Auth Invite: Yes
  • Proxy: [set to FreePBX IP]
  • Register: No
  • User ID: pstn_fxo
  • Auth ID: pstn_fxo
  • Use Auth ID: Yes
  • Password: password
  • Line 1 VoIP Caller DP: None
  • PSTN Caller Default DP: 1
  • Dial Plan 1: (S0<:pstn_fxo@192.168.0.181>)
    Including brackets – and where 192.168.0.181 is your FreePBX IP

Yes, both the same settings except for the SIP Port. It’s possible even that can be the same.

We are authenticating the SPA-3102 using IP address for calls coming in from the Landline, so registration is not needed. This is due to the Caller ID as above.

 

FreePBX Configuration

Create a new PJSIP Trunk

  • Trunk Name: pstn_fxo
  • Outbound Caller ID: Your landline telephone number
  • Maximum Channels: 1
  • Username: pstn_fxo
  • Password: password
  • Authentication: Outbound
  • Registration: Send
  • SIP Server: [set to IP address of SPA-3102]
  • SIP Server Port: 5060
  • Context: from-pstn

Inbound Route

  • Set up a default route with Destination as a Ring Group

Outbound Route

  • Route Name: POTS Outgoing
  • Route CID: Your landline telephone number
  • Trunk Sequence for Matched Routes: pstn_fxo
  • Dial Patterns: You can add any patterns you like here, whether with or without prefix=9 (which will be removed). Anything matched (which is not an extension) will be sent through the landline.

 

Complete!

Apply the settings and restart/reload Asterisk. Now monitor the asterisk.log file, and check the registration time in the SPA-3102.

The SPA-3102 should indicate:

  • Line 1
    • Hook State: On
    • Registration State: Registered
    • Next Registration In: 0 s
    • Message Waiting: No
  • PSTN Line Status
    • Hook State: On Line
    • Voltage: 49 (V)
    • Loop Current: 0.0 (mA)
    • Registration State: Not Registered

 

You should now be able to make calls from your softphone via the FreePBX Trunk and out through the PSTN line.
Any landline incoming calls should be redirected via the ring group, and all devices should ring.
You should also be able to make calls from an attached telephone to the SPA-3102, and it should act like a normal VOIP telephone.

If you have any problems, please do leave a comment below or get in contact!

 

Below I’ve put together some technical information on the exact configuration used;

 

FreePBX Configuration Files

If you are configuring Asterisk by hand, these may help:

pjsip.aor.conf

[pstn_fxo]
type=aor
qualify_frequency=60
contact=sip:pstn_fxo@192.168.0.180:5060
max_contacts=1

# Note - Replace 192.168.0.180 with IP Address of SPA-3102

pjsip.auth.conf

[pstn_fxo]
type=auth
auth_type=userpass
password=password
username=pstn_fxo
# Note - remember to set a secure password

pjsip.endpoint.conf

[pstn_fxo]
type=endpoint
transport=0.0.0.0-udp
context=from-pstn
disallow=all
allow=ulaw,alaw,gsm,g726,g722
aors=pstn_fxo
outbound_auth=pstn_fxo
send_rpid=yes
send_pai=yes
dtmf_mode=auto

pjsip.identify.conf

[pstn_fxo]
type=identify
endpoint=pstn_fxo
match=10.8.8.180

pjsip.registration.conf

[pstn_fxo]
type=registration
transport=0.0.0.0-udp
outbound_auth=pstn_fxo
line=yes
endpoint=pstn_fxo
server_uri=sip:192.168.0.180:5060
client_uri=sip:pstn_fxo@192.168.0.180:5060
# Note - Replace 192.168.0.180 with IP Address of SPA-3102

 

UK Telephone Configuration

With thanks to http://www.aoakley.com/articles/2008-01-08.php

Admin login > Advanced > Voice > Regional:

Dial tone: 350@-19,440@-22;10(*/0/1+2)
Ring back: 400@-20,450@-20;*(.4/.2/1+2,.4/2/1+2)
Busy tone: 400@-20;10(.375/.375/1)
Reorder tone: 400@-20;10(*/0/1)
SIT 1 tone: 950@-16,1400@-16,1800@-16;20(.330/0/1,.330/0/2,.330/0/3,0/1/0)
MWI dial tone: 350@-19,440@-22;10(.75/.75/1+2)
CWT1 cadence: 30(.1/2)
CWT2 cadence: 30(.25/.25,.25/.25,.25/5)
CWT frequency: 400@-10
Ring 1 cadence: 60(.4/.2,.4/2)
Ring 2 cadence: 60(1/2)
Ring 3 cadence: 60(.25/.25,.25/.25,.25/1.75)
Ring 4 cadence: 60(.4/.8)
Ring 5 cadence: 60(2/4)
Time Zone: GMT
FXS Port Impedance: 370+620||310nF (or 270+750||150nF )
Caller ID Method: ETSI FSK With PR(UK)
Daylight Saving Rule: start=3/-1/7/1:0:0;end=10/-1/7/2:0:0;save=1:0:0

Admin login > Advanced > Voice > PSTN Line:

PSTN Disconnect Detection

Detect CPC: yes
Detect Polarity Reversal: no
Detect PSTN Long Silence: no
PSTN Long Silence Duration: 30
PSTN Silence Threshold - High
Min CPC Duration: 0.09
Detect Disconnect Tone: yes
Disconnect Tone - 400@-30,400@-30; 2(3/0/1+2)

International Control

FXO Port Impedance: 270+750||150nF
OnHook Speed: 3ms (ETSI)
Current Limiting Enable: yes
Ring Validation Time: 256ms
Ring Indication Delay: 512ms
Ring Timeout: 640ms

Admin login > Advanced > Voice > Line 1:

Auto PSTN Fallback: Yes
Dial Plan:(x.<:@gw0>)
Emergency Number: 999