. mombe.org
home of the mad cow
  Not A Blog
 

Sunday, April 22, 2007

Asterisk and the D-Link DVG-1104TH

This weekend I had a go at getting Asterisk to talk to a D-Link DVG-1104TH FXO voice gateway that we've had lying around for a couple of years. My starting point was knowing nothing about either Asterisk or the voice gateway — I'd never used either before.

The first thing I did was install Asterisk from FreeBSD ports. This is trivial. I then hacked around with the sample configs to create my first, working two-extension PBX.

The DVG-1104TH was a bigger problem. Google didn't know much about it, and it isn't listed on D-Link's website any more. Fortunately for me, David had played with the DVG-1104TH before. By taking it apart he discovered it was actually a re-branded WellTech 3804. This was the first useful step. The DVG-1104TH talks H.323, but the 3804 can be made to talk SIP. David re-flashed the firmware on the DVG-1104TH with WellTech's firmware and got us an FXO that could talk SIP. Firmware and instructions are on WellTech's website, as is the manual for the box. We're running firmware version 106.

Google found me this document which, although it refers to a different firmware version, was very helpful. I'll document what I did here, because it's slightly different.

The first thing I did was create a new SIP user in Asterisk to handle the FXO. In sip.conf I have:

[dlink-fxo]
type=friend
username=dlink-fxo      ; to match FXO line username
secret=1234             ; password
host=dynamic            ; force registration
context=external_in     ; what to do with incoming calls.  see below
canreinvite=no
dtmfmode=rfc2833
relaxdtmf=yes

One of the more important things is the external_in context. This tells Asterisk what to do with incoming calls, and allows us to handle them specially. In extensions.conf we have

[external_in]
exten => 9,1,Answer                     ; Answer the line
exten => 9,n,Wait(1)                    ; Wait a second for the line[B
exten => 9,n,Set(TIMEOUT(digit)=5)      ; Set Digit Timeout to 5 seconds
exten => 9,n,Set(TIMEOUT(response)=20)  ; Set Response Timeout to 10 secs
exten => 9,n(instruct),BackGround(vm-enter-num-to-call) ; Instructions
exten => 9,n,WaitExten                  ; Wait for extension to be dialled.
exten => 9,n,HangUp
;
; Invalid Extension
exten => i,1,Playback(invalid)          ; Invalid Extension message
exten => i,n,Goto(9,5)                 ; Go back to the instructions
;
; Timeout
exten => t,1,Wait(1)
exten => t,n,Playback(extra/jedi-extension-trick)
exten => t,n,Playback(extra/hangup-try-again)
exten => t,n,HangUp
;
; Now include our normal user extension context
include => user-stations

This creates extension "9" that'll be used by the FXO. It asks users to enter an extension and then connects the call. The choice of 9 is arbitrary; make it fit your dial-plan. Because it is a separate context, it isn't dialable by normal users, so it shouldn't be too problematic to be a free number — it can overlap with other services in other contexts. We have to include normal user extensions (and anything else people might need to connect to) though, or WaitExten won't be able to connect them.

The above entry handles incoming calls. If you want to handle outgoing calls with the FSO you need some extra things in your extensions.conf. For example, to redirect anything that begins with a zero to the FSO you could do the following:

exten => _0.,1,Dial(SIP/${EXTEN}@192.168.0.2) ; FXO gateway IP
It must, of course, be in the right context for users making outgoing calls.

And that's the Asterisk config ... Now the FXO.

Our FXO config is:

# point the FXO box at Asterisk's IP
sip -px 192.168.0.1
# set the Asterisk SIP extension associated with each line
# making them all the same means only one entry in sip.conf
sip -line1 dlink-fxo
sip -line2 dlink-fxo
sip -line3 dlink-fxo
sip -line4 dlink-fxo
# set the usernames for the lines.  must be same as above
security -line 1 -name dlink-fxo -pwd 1234
security -line 2 -name dlink-fxo -pwd 1234
security -line 3 -name dlink-fxo -pwd 1234
security -line 4 -name dlink-fxo -pwd 1234
# make the lines automatically dial 9 on the SIP proxy on an FX call
line -config 1 hotline 9
line -config 2 hotline 9
line -config 3 hotline 9
line -config 4 hotline 9
# make DTMF work.  Make sure you use RFC2833 everywhere
sysconf -keypad 1
pt -rfc2833 101 -fax 96
# enable caller ID detection (1 = US FSK, 2 = ETSI)
sysconf -callerid 2
sysconf -rba 2
# disable internal IVR
sysconf -ivr 0
# disable silence detection (annoying clicks)
sysconf -silence 0
# save and reboot (have to do this :()
commit
reboot

Note the line -config 1 hotline 9. The "9" corresponds to the number we defined in Asterisk's dial-plan to handle the menu. So when a PSTN call arrives on the FX port, the FXO gateway calls "9" on Asterisk, and asterisk responds with a voice menu. The user then uses DTFM to choose an Asterisk extension to connect to.

The D-Link/WellTech FXO gateway makes a reasonably cheap way to get PSTN into Asterisk. It takes four standard, analogue lines so it is ideal for SOHO type things. Of for playing with, like we're doing :)

posted by guy at: 16:10 SAST | path: /systems | permanent link

Tuesday, April 10, 2007

APC Brickbats

So APC make some nice products. We particularly like their 19" enclosures and have ordered several of them over the last few years.

Unfortunately APC EMEA seem to have serious problems delivering their products. We've ordered things and had them take weeks or months to arrive. At first we thought the problem was the local re-seller, so we've tried changing re-sellers. Same problems.

The record thus far is 22 weeks for some blanking panels. These are bits of plastic; no moving parts, no assembly, just some injection moulding.

Looking at it cynically from the African point of view, it seems that APC simply don't care about their non-American market. They've got serious delivery problems in Africa, and from what I can tell, in Europe too. They don't seem to be doing anything about it either — this problem's existed for at least six months, if not a year.

posted by guy at: 15:10 SAST | path: /systems | permanent link

Bloxsom Powered

© 2002-2005, webmaster@mombe.org
 
 
RSS Valid XHTML 1.0!

Creative Commons License