So I’ve spent a few hours now this evening getting my Linksys SPA3000 ‘talking’ to FreePBX. I’ve setup a phone connected to the phone port and I’ve connected my BT phone line to the PSTN port.
Before I involved FreePBX at all and was just trying to make sure the SPA3000 was working, I was able to test the device with a mobile phone - when I rang my landline number I was able to answer the call with the phone connected to the SPA3000. I could also dial out to my mobile.
I’ve had limited success registering the SPA3000 up to Asterisk. With a bit of trial and error, I got both ‘Line’ and ‘PSTN’ to show ‘REGISTERED’ and indeed I can see there is communication between the two servers by monitoring the CLI I can see phone calls coming in.
I can also see SIP messages back and forth between the Linksys device and Freepbx. They genuinely seem to be communicating.
However despite setting up a trunk and an inbound route, I can’t answer calls on the phone from my mobile and my log is filled with things like this:
[2019-03-23 23:37:50] ERROR res_pjsip.c: Unable to retrieve PJSIP transport 'udp,tcp,ws,wss'
also when I do “show peers” I get:
raspbx*CLI> sip show peers
Name/username Host Dyn Forcerport Comedia ACL Port Status Description
0 sip peers [Monitored: 0 online, 0 offline Unmonitored: 0 online, 0 offline]
raspbx*CLI> sip show registry
Host dnsmgr Username Refresh State Reg.Time
0 SIP registrations.
So I’m a bit confused, really! Weird that my SPA device shows “REGISTERED” x2 when FreePBX shows 0 SIP connections?
On a recent FreePBX, Asterisk has two SIP drivers. The classic one is called chan_sip but it now listens on port 5160 by default. The new one is pjsip and listens on port 5060 (the standard SIP port).
sip show registry
shows outbound registrations for chan_sip, e.g. to a VoIP provider. Assuming that you have not yet configured any VoIP providers, it’s normal and expected for it to show no registrations.
sip show peers
shows known chan_sip devices that have been configured. If you set up pjsip extension(s) or a pjsip trunk for your SPA, it’s also normal for it to show none.
The roughly equivalent commands for pjsip are pjsip show registrations
and pjsip show endpoints
pjsip has some quirks that make it difficult to use with FXO devices such as SPA3000, SPA3102, OBi110, OBi212, HT503 and HT813. I recommend setting up the PSTN port side as a chan_sip trunk.
If the FXS (Line 1) side is set up as a pjsip extension and working, it’s probably easiest to leave it alone. From an analogue phone connected to the Phone port, try dialing
*65 (speaks your extension number)
*60 (speaking clock) or
*43 (echo test).
If you have dial tone but these don’t work, check that the Line 1 dialplan allows the star codes and that they don’t conflict with any Vertical Service Activation Codes on the Regional tab of the SPA.
If you still have trouble, report your trunk settings and PSTN line settings, as well as any relevant logs.
Here are some settings taken from my SPA3102. These settings assume that your BT number is 02072345678, your PBX IP address is 192.168.101, the trunk is called BT-POTS with password abcd1234. Substitute your own values for them. Settings not mentioned should be left at defaults.
For the chan_sip trunk:
Trunk Name: BT-POTS
Outbound CallerID: 02072345678
Outgoing sip Settings:
Trunk Name: BT-POTS
On the PSTN Line tab of the SPA3000:
Line Enable: yes
Register Expires: 120
Display Name: BT-POTS
User ID: BT-POTS
Dial Plan 2: (<:02072345678>S0)
VoIP-To-PSTN Gateway Enable: yes
One Stage Dialing: yes
VoIP Caller Auth Method: none
VoIP Caller Default DP: 3
PSTN-To-VoIP Gateway Enable: yes
PSTN Caller Auth Method: none
PSTN Ring Thru Line 1: no
PSTN CID For VoIP CID: yes
PSTN Caller Default DP: 2
Off Hook While Calling VoIP: no
VoIP Answer Delay: 0
PSTN Answer Delay: 4
I may have missed some things; describe what goes wrong for both incoming and outgoing calls.
Thank you for this. I really appreciate your help.
So I’ve done as you suggested and I now have a much more active log when calls come in and out. I seem to be much closer.
Also the spa3000 still shows registered for both the pstn and the line1.
However for some reason the phone I have connected still doesn’t “answer” calls when I lift the receiver when I dial the number from my mobile. Something as I say, which was working when I didn’t have asterisk in the loop.
So clearly I have a bit more config to do…somewhere! No obvious errors in logs. Shall I post some output here if you still have a bit of time to help?
OK - so I’ve made a lot of progress @Stewart1 - but the problem I’m having is that my calls FROM the phone I have connected to the SPA3000 are not being picked up and dealt with by Asterisk. I think the ATA is just placing calls directly onto the PSTN without sending them to Asterisk. When I lift the receiver on the phone connected to the SPA3K there’s seemingly no awareness that the phone is off the hook in the Asterisk console log.
My dialplan in “Line 1” is (x.<:@gw0>) - I’d love to instead pass that to Asterisk. Any ideas??
That’s actually normal. In the usual setup, when you go off hook the SPA plays a dial tone locally and waits for the user to dial. Only when it determines that the number has been completely entered does it send the call to Asterisk.
For example, you could use a dial plan for Line 1 like: (999<:@gw0>|x.|*x.)
which would route 999 directly to the PSTN (in case the PBX is down) but send all other calls to Asterisk. This is a good way to start but it has some limitations, because it doesn’t tell the SPA how many digits to expect in various formats. When no more digits have been received for 3 seconds (or whatever you choose for Interdigit Short Timer), the call is sent.
There are two problems with using this timer: it adds 3 seconds to the setup time for all calls, and pausing longer than 3 seconds between digits will cause the call to fail. A more comprehensive dial plan would eliminate both issues for nearly all calls.
With the above dial plan, you should be able to reach *65, *60 and *43, as well as external numbers.
Once this is working, how do you plan to expand the PBX? With only one extension and one trunk, it couldn’t do much more than provide voicemail, filter spam and record calls.
Thank you very much - I’ll give this a try tonight - it’s curious but in none of the many guides I’ve been ransacking for help and information this weekend - none of them (unless I missed something major several times!) actually mentioned what, if anything, to put in the dial plan on the Line 1…
I’ll go and have another go in light of this useful tidbit. I’ve also found disparity in the guides about whether or not you have to put a :port in the proxy field after the IP - I found it simply didn’t work unless I did.
You asked about my plans for expansion. Obviously this isn’t the limit of what I have in mind, but I thought I’d sort the basics before jumping in with everything all at once. Simply more to cause confusion.
Connect a trunk to C*Net
Connect all my regular house phones to different extensions
Somehow come up with a dial plan which
allows the phones to work as they did before (local, mobile and national numbers go straight out onto the PSTN)
but also allow calling between the extensions within the house,
allow calling to my office at work (where I will have a PAP2T connected) via an ‘extension type’ number such as 250(?)
allow calling to CNet (where I hope the dial plan will recognise the old form UK number as non-standard for PSTN and magically route it to the virtual IP trunk
I have maaaany other mid and long term plans but I’d be happy if I could get this setup in the short term. I’ve been flummoxed (but not surprised) by how finnicky the settings are and how you need to fiddle and fiddle in order to get things to work. Asterisk is also taking ages to save changes and apply config at the moment. I’ll try a restart of the Pi at some point to see if it speeds things up - it wasn’t slow when I first started settings things up I don’t think.
I guess one other question I have is, the big red “apply confg” button - is that the same as a restart of Asterisk? Do I need to do either of the latter after creating a new trunk or extension? I saw you mention that was necessary in another post.
I’m still not convinced my settings for the SPA3000 are 100% happy. I’ve yet to see both of my clients recognised as active from the Asterisk CLI despite the SPA3000 saying they are registered. This is despite using both the PJSIP command and the SIP command to show peers.
Progress!! Thank you!! So I’m another big step on the way to a working setup…
I can now place calls from my test handset on the FXS port of the SPA3000 which Asterisk is handling. It’s playing me audio feedback messages like “your call could not be completed as dialled” and I was even able to dial for an echo test. The number for a lady to read out the time did not work. Nor did the number to read back my extension.
The problems which remain are that if I ring my number from the PSTN and lift the handset on the test phone, the call isn’t put through to that extension.
I also can’t dial out to any numbers. Everything returns ‘cannot be completed as dialed’. I guess I just need a UK dialplan. Is there something like this already put together somewhere? Something that basically replicates the UK’s dialplan which I could then add to over time to add in my CNet stuff?
Bizarrely when I look at my call logs, it does show the call coming in from the PSTN destined for the correct extension - but as I say - when I lift the handset - I just get a dialtone.
For the *65 and *60 codes, they may be conflicting with internal codes in the SPA. On the Regional tab, look for Vertical Service Activation Codes or similar. Blank out any you don’t want the SPA to handle internally (which may be all of them).
For the Outbound Route, delete all the patterns and enter a single pattern with prepend blank, prefix blank, match pattern X.
and CallerID blank. That will pass anything you dial to the trunk – dial same as you would from an analogue phone connected directly to the BT line.
For the incoming problem, at the Asterisk console, do both pjsip set logger on
and sip set debug on
which will cause the SIP transactions on both drivers to appear in the Asterisk log (along with the normal info). Call in from your mobile, answer the extension when it rings, view the log (Reports -> Asterisk Logfiles). Paste the relevant section at pastebin.freepbx.org and post a link here.
It looks like inbound calls from the PSTN WERE answerable I just have to wait for the words " PJSIP/4001-00000029 is ringing" to appear in my console output then I know Asterisk has transferred the call to the extension. I think I was picking up too soon. I can hear the call ringing on my mobile but I needed to wait for Asterisk to ‘deal with it’ I guess? I think the SPA3000 “PSTN answer delay” setting here is responsible for this? I think I read somewhere to set this to ‘4’ to avoid caller display problems.
So now I can get thinking about dialplans and my CNet trunk?!
UK caller ID is sent before the first ring, so setting PSTN Answer Delay to 1 or even 0 will probably work. Just experiment. If it’s too low, you’ll still get the call but it will just show the trunk name.
I’ll happily test and report back! Presumably the ‘999’ at beginning of the dialplan would never actually be used because the SPA wouldn’t send the ‘999’ to FreePBX anyway ((999<:@gw0>|x.|*x.)). I’m located in York, England, by the way.
Since local numbers in York are also 6 digits, no change is needed there.
For the SPA3K, you would adjust the dial plan so emergency calling uses the PSTN line directly. For other devices, e.g. ATAs that connect your other home phones, you will likely have to route 999, 112, etc. through the PBX.
For extension dialing, you might use 3-digit numbers from 160-199. There is always a risk that Ofcom will assign these codes; perhaps they have some documentation on what’s likely to be used in the near future.
I don’t see any way to overlay CNet directly, especially because their numbers start with the country code and new countries could be added at any time. So, you would need to dial a prefix before a CNet number. One possibility is 000 (no country code begins with 0 and IMO it’s very unlikely that would be assigned). Another is 04 or 06, though Ofcom might have plans for those.
You need to add one or more dial plan entries to accommodate any * codes you’ll be using. You could use a * code for the CNet prefix, which would be safe from Ofcom, but might be used for a future FreePBX feature.
As a single pattern with prepend blank, prefix blank, match pattern
(999S0|1[1-3]x|1xx|08001111|0845464x|000xxxxxx|01[2-9][02-9]xxxxxx|0[1-9]xxxxxxxxx|[2-9]xxxxx|00xxxxxxxx.) and caller ID blank
Unfortunately that meant ALL calls herald the return the American lady telling me my call could not be completed as dialled.
As soon as I reinstated plain old “X.” everything started working again?
Going to start a new thread on this a) to give you a break, b) in case anyone else is awake right now and might be able to help and c) because the issue has changed quite a lot since I started this thread, even though I’ve changed the title!