Tuesday, May 4, 2010

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.

Wednesday, April 28, 2010

A Handy Macro

I left off the last post with this:
exten => 1000,1,Dial(${MILES},${DELAYTIME})
exten => 1000,n,GoToIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
exten => 1000,n(unavail),VoiceMail(1000@default,u)
exten => 1000,n,Hangup()
exten => 1000,n(busy),VoiceMail(1000@default,b)
exten => 1000,n,Hangup()
As the book points out, this is fine for small implementations of *, but as a system scales this becomes massively inefficient. I followed the book example to turn this into a macro and condense everything down to one line outside the macro's definition.

Macros are created in a pseudo-context prefaced with "macro-" ; I used
[macro-voicemail]
It also differentiates from pure contexts because each step uses the "s" extension. * has some handy built-in variables, including one to call the original extension ${MACRO_EXTEN}. Thus, our macro becomes
[macro-voicemail]
exten => s,1,Dial(${MILES},${DELAYTIME})
exten => s,n,GoToIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
exten => s,n(unavail),VoiceMail(${MACRO_EXTEN}@default,u)
exten => s,n,Hangup()
exten => s,n(busy),VoiceMail(${MACRO_EXTEN}@default,b)
exten => s,n,Hangup()
This is why I had the mailbox extensions the same as the SIP extensions.

The last thing to do was strip the last unique variable in the macro and add it back in as an argument. Since this happened to be my name, we can just put that in as the "n"th argument using the ${ARG n} variable built into the Macro() application. The macro becomes:
[macro-voicemail]
exten => s,1,Dial(${ARG1},${DELAYTIME})
exten => s,n,GoToIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
exten => s,n(unavail),VoiceMail(${MACRO_EXTEN}@default,u)
exten => s,n,Hangup()
exten => s,n(busy),VoiceMail(${MACRO_EXTEN}@default,b)
exten => s,n,Hangup()
And now instead of the messy, 6-line statement in the [internal] context in the dialplan we started out with, we can just write
exten => 1000,1,Macro(voicemail,${MILES})
Here you can see where the ${ARG1} variable gets its value (the first argument after "voicemail" in the Macro application).

Voicemail Details

The original /etc/asterisk/voicemail.conf had a lot of commented options, so I renamed it voicemail.conf.sample and made a new one. There are three contexts: [general] holds various global options, [zonemessages] are for timezones, and [default] (which can be renamed whatever you want) holds the mailbox information.

Currently, this is what each section looks like (with brief explanation):
[general]

format=wav49|gsm|wav
serveremail=asterisk
attach=yes
skipms=3000
maxsilence=10
silencethreshold=128
maxlogins=3
emaildateformat=%A, %B %d, %Y at %r
sendvoicemail=yes
As I said, these are all global options and most are self-explanatory. You can find technical definitions of each option here, along with a bunch of others I didn't include.
[zonemessages]

eastern=America/New_York|'vm-received' Q 'digits/at' IMp
central=America/Chicago|'vm-received' Q 'digits/at' IMp
central24=America/Chicago|'vm-received' q 'digits/at' H N 'hours'
military=Zulu|'vm-received' q 'digits/at' H N 'hours' 'phonetic/z_p'
european=Europe/Geneva|'vm-received' a d b 'digits/at' HM
These are just time zone settings. Full explanation of zonemessages is midway down the page here.
[default]

1000 => 9999,Miles K,email.removed.to.stop.spam@gmail.com
1001 => 9999,John M
....
Mailboxes are simple to set up. It's the extension followed by the passcode, Name (it knows that the last name is separated from the first name by a space!), and notification e-mail address. You can also add a pager e-mail address (pagers....hah!) and various overrides to the global options that are specified in [general].

The addition of voicemail necessitates changes to the dialplan (extensions.conf) which happened in a somewhat circular way as I followed the book's example. At first there was the no-brainer approach, taking this:
exten => 1000,1,Dial(${MILES},${DELAYTIME})
exten => 1000,n,Playback(vm-nobodyavail)
exten => 1000,n,Hangup()
into this:
exten => 1000,1,Dial(${MILES},${DELAYTIME})
exten => 1000,n,VoiceMail(1000@default,u)
exten => 1000,n,Playback(vm-nobodyavail)
exten => 1000,n,Hangup()
The VoiceMail() application takes two arguments: (mailboxNumber@mailboxContext, statusIdentifier). mailboxNumber and mailboxContext are what got entered into voicemail.conf. statusIdentifier can be either "u" (unavailable) or "b" (busy). The above is not very robust as it only has directions for an "unavailable" user and no instructions if the user is busy. The second incarnation is:
exten => 1000,1,Dial(${MILES},${DELAYTIME})
exten => 1000,n,GoToIf($["${DIALSTATUS}" = "BUSY"]?busy:unavail)
exten => 1000,n(unavail),VoiceMail(1000@default,u)
exten => 1000,n,Hangup()
exten => 1000,n(busy),VoiceMail(1000@default,b)
exten => 1000,n,Hangup()
This makes use of the DIALSTATUS variable to tell * what message to play in the unavailable/busy scenarios, kind of like a decision tree.