Monday, May 17, 2010

Possible Success?

I've just now been able to make four consecutive calls to John's home number that have gone through to the answering machine, which is certainly a good sign.

Since calls used to wind up with the AT&T (or whatever) lady telling us nicely that
"We're sorry, your call cannot be completed as dialed. Please check the number and dial again." and that we could get some outgoing calls to go through and incoming calls work 100% of the time (as tested so far), I decided that the Asterisk server probably wasn't the problem. I asked on the Asterisk forums which are fairly quiet, but still have a couple people who know what they're talking about frequently giving helpful advice. One of them suggested that it was more than likely some sort of timing issue between the Linksys and the phone company.

Thankfully there aren't many relevant timing settings in the Linksys control panel, so I systematically adjusted one of the 4 or 5 that looked to be likely candidates to see what happened (They're all in the Admin -> Voice -> PSTN Line -> FXO Timer Values section). Neither VoIP Answer Delay or PSTN Answer Delay had any effect, which didn't surprise me because we weren't having issues with answering incoming calls (although I guess I've never tried answering an incoming VoIP call from the Linksys). The PIN timeout settings weren't relevant, and "Ring thru" was not something I'd seen mentioned in any of the guides/webpages I had skimmed researching the problem.

The problem seems to have been that PSTN Dialing Delay , previously set to 1, was not long enough. I don't know what kind of "handshaking" goes on behind the scenes when one tries to connect a PSTN call, but based on the terminology I'd guess that previously Asterisk didn't wait long enough to make the proper connection to the PSTN, perhaps truncating or otherwise corrupting the number in the process and leading to the "We're sorry" message. The setting that is working consistently at the moment is:
PSTN Dialing Delay: 2
Maybe you can try it on your end to see if things are working in Kansas like they are in Virginia?

Friday, May 14, 2010

Still Puzzled....

...as to why Asterisk-to-PSTN calls don't work 3/4 times or so. Haven't found anything conclusive after a couple days of digging.

Monday, May 10, 2010

Asterisk Configuration for SPA3102- Outgoing Calls

In sip.conf I added the "line1" user. Note that this could be whatever you want, but you'd have to change the Linksys configuration.
[line1]
type=friend
host=[IP addr of Linksys]
username=line1
secret=[password]
dtmfmode=rfc2833
context=outbound-local
insecure=port,invite
disallow=all
allow=ulaw
nat=yes
qualify=yes
port=5061
I mentioned a bit earlier that I was getting warnings and errors in the console about registering. The error message was pretty straightforward:
[May 10 19:36:08] NOTICE[23761]: chan_sip.c:21538 handle_request_register: Registration from 'line1 ' failed for '[Linksys IP]' - Peer is not supposed to register
[May 10 19:36:12] ERROR[23761]: chan_sip.c:13010 register_verify: Peer 'line1' is trying to register, but not configured as host=dynamic
Obviously the error was due to the "host" attribute not being dynamic. For some reason calling out didn't work if the host was dynamic and I'm not exactly sure why. To clean up the console I just turned off registration for this particular peer.

In extensions.conf I created a new context:
[outbound-local]
exten => _9XXXXXXX,1,Dial(SIP/${EXTEN:1}@line1,25)
This matches any 8-digit pattern in which the first digit is 9 (patterns are prefaced with an underscore). The ${EXTEN:1} variable passes the number dialed to the trunk, and the ":1" strips off the 9. Sadly this is what took me so long to figure out, and I'm still confused about the syntax of the above "Dial" application, which seems different from what's in the book. Maybe it's a version issue?

Linksys SPA3102 Modified Configuration- Outgoing Calls

I can't remember if I covered this in the post showing the config for the PSTN Line incoming calls, but this is all on the "Line 1" tab in the Linksys Advanced Admin Tab.

-> Line Enable: yes

-> NAT Settings
NAT Mapping Enable: no
NAT Keep Alive Enable: no
-> SIP Settings
SIP Transport: UDP
SIP Port: 5060
-> Proxy and Registration
Proxy: [IP address of Asterisk server]
Use Outbound Proxy: no
Register: no
Make Call Without Reg: yes
Ans Call Without Reg: yes
-> Subscriber Information
Display Name: line1 [ /whatever you want]
User ID: line1
Password: [choose a password]
-> Dial Plan
Dial Plan: (*xx|[3469]11|0|00|[2-9]xxxxxxxxxS0|1xxx[2-9]xxxxxxS0) [this is the default]

Local Calls Success

After several days of treading water, I finally was able to make a local call from XLite to John's house (I didn't leave a message, sorry). In theory I believe anyone should be able to make calls in your area code from XLite, and the dialplan won't recognize numbers longer than 7 digits.

To "dial out", preface the local number with "9" (this could be changed to whatever we want). In XLite (and apparently in most VoIP phones) the dial tone doesn't "pause" like it would on a touchtone phone... probably because there's no dial tone to begin with. The leading 9 is stripped off when Asterisk passes the string to the Linksys. So for example, if the local number was 1234567 you'd enter 91234567 in XLite.

Technical details will be coming soon, as soon as I can figure out exactly how many circles I went in to eliminate me writing the same thing multiple times.

EDIT #1: It takes a few seconds for the PSTN line to start ringing.

EDIT #2: For some reason a flurry of error messages pop up in the console because I had to assign a static IP for the outgoing line's host. Not sure how to get around this at the moment.

Edit #3: Now I get a "We're sorry, the call cannot be completed as dialed" message ...

Edit #4: ...but it connects when I call Sarah? Strange. Maybe you can try it out and let me know how it goes.

Tuesday, May 4, 2010

Dialing Out from Asterisk- Local Calls

I think I've set up the system so that one can dial out to a local phone number from XLite. Put "9" before the 7-digit number and see if it connects. The pattern-matching line I have in there now disallows numbers longer than 7 digits.

(911 should work too, but maybe don't test that one out)

edit: never mind, doesn't work.

Asterisk Configuration for SPA3102- Incoming Calls

Two files needed to be modified for the PSTN-to-Asterisk connection.

I added the user "pstn" to /etc/asterisk/sip.conf
[pstn]
type=friend
host=dynamic
secret=*******
dtmfmode=rfc2833
context=pstn
insecure=very
nat=yes
qualify=yes
To forward an incoming call to my Asterisk extension, I created a new "pstn" context in /etc/asterisk/extensions.conf
[pstn]
exten => 1000,1,Dial(SIP/1000)

Linksys SPA3102 Modified Configuration- Incoming Calls

Here are the settings for the Linksys SPA3102 that allow us to call the local 913 number assigned to the device and have it forward to an XLite softphone. You need to log into the Linksys and switch to admin mode, "advanced" configuration.

**Also note that this is the result of several contradicting directions, found here, here, and here.

These are the options I changed. If something isn't mentioned, the default setting should work.

Router

-> WAN Setup Tab
[Same as initial configuration]
-> LAN Setup Tab
Networking Service: Bridge
Enable DHCP Server: no
-> Application Tab
Enable DMZ: no
Voice

->SIP tab
->SIP Parameters
SIP TCP Port Min: 5060
SP TCP Port Max: 5060
->RTP Parameters
RTP Port Min: 16384
RTP Port Max: 16390
-> NAT Support Parameters
STUN Enable: yes
STUN Test Enable: yes
STUN Server: stun.ekiga.net
EXT IP: [IP address of the box]
->PSTN Line tab
-> Line Enable: yes
-> NAT Settings
NAT Mapping Enable: no
-> SIP Settings
SIP Port: 5061
EXT SIP Port: 5061
SIP Debug Option: full
-> Proxy and Registration
Proxy: [IP address of Asterisk Server]
Register: yes
Make Call Without Reg: no
Answer Call Without Reg: yes
-> Subscriber Information
Display Name: PSTN
User ID: pstn
Password: [whatever you specify]
-> Dial Plans
Dial Plan 1: S0<:1000@[IP addr of Asterisk Server]>

-> VoIP-To-PSTN Gateway Setup
VoIP-To-PSTN Gateway Enable: yes
Line 1 VoIP Caller DP: 1
VoIP Caller Default DP: 1

-> PSTN-To-VoIP Gateway Setup
PSTN-To-VoIP Gateway Enable: yes
PSTN Ring Thru Line 1: no
PSTN CID for VoIP CID: yes
PSTN Caller Default DP: 1
-> FXO Timer Values (sec)
VoIP Answer Delay: 0
PSTN Answer Delay: 2

Monday, May 3, 2010

Initial Configuration of Linksys SPA3102

Initial Confiuration of Linksys SPA3102

Here is what I have done so far ( I have omitted steps that lead to a dead end).

Unpacked and connected cables:
Network cable from my existing router went to “internet” port.
Placed a splitter in the dsl phone line, ran the data side back to the router.
Connected cable from the dsl splitter to the “line” port.
Connected an analog phone to the “phone” port.
Connected the power supply.

With the analog phone:
(had to disconnect the “line” port, evidently default config is to connect the analog phone to the line which messes up the IVR capability of the analog phone)
Dialed ****
Dialed 110# --> msg received: 192.168.1.117
Dialed 7932# 1# 1# --> msg recv: configuration saved (enabled web interface)

From PC connected to the same network:
Browse to 192.168.1.117
Click on Admin Logon
Tab to Wan Setup
Change configuration to:
Connection Type: Static
Static IP: 192.168.1.2
NetMask: 255.255.255.0
Gateway: 192.168.1.1
DNS 208.67.222.222, 208.67.220.220

Downloaded a firmware upgrade from http://www.cisco.com/en/US/products/ps10027/index.html
Upgraded from 3.x to 5.1

Reattached Browser to 192.168.1.2
set admin & user password to ***
Closed browser & reattached
Login OK, it only logs in as user and then allows upgrade to admin

Added SIP access from my router on this network.

PSTN-to-Asterisk Success

The current setup allows someone to call the number for the Linksys and have it ring to my Asterisk extension. However, it's going to take me a while to go back through and document everything I did.

The Linksys seems to take care of all the necessary conversion, turning the analog signal into a SIP trunk. I also haven't figured out how to dial out from XLite to the Linksys yet.

If you log into the server and enter the Asterisk CLI
# asterisk -vvvvvr
and then type
> sip show peers
you'll see the "pstn" peer and the ping. It seems to be holding steady at about 70 ms, which isn't too bad.

Mailboxes in sip.conf

I added the line:
mailbox=XXXX@default
to each user in sip.conf. This stops the annoying
[May 3 14:59:17] NOTICE[8147]: chan_sip.c:21369 handle_request_subscribe: Received SIP subscribe for peer without mailbox: 1000
message from popping up every 3 minutes when I'm in the Asterisk CLI.

Saturday, May 1, 2010

Weasels, Hello World

I forgot to note that I changed the weasels and Hello world extensions to 999 and 998, respectively. Sorry about that; I meant to write it down but didn't.