BaroqueW

and his side-kick nikkitaa

Archive for the ‘Tech >> Computer’ Category

Asterisk at home

leave a comment »

I do not know why but a few weeks back I decided to look for a simple FXO/FXS Digium card to play a bit with my home server. Maybe it is the perspective to play tricks or at least get rid of telemarketers, or just the neat idea of playing with Asterisk once again. Anyway, I got my hands on TDM400p and started looking into this baby.

Installing the hardware

Open your PC, find an empty PCI slot and plug the card. Make sure to note where each module is (green is for FXS — you connect your landline there, red is for FXO — you connect your phone there).TDM400p

First big change since I made my last installation of a Digium card on a system, Zaptel is now called Dahdi. Not a big change but well, you gotta change your reflexes and look for dahdi files now. First let’s install what we need (note I am running Ubuntu 10.04.2).

sudo apt-get install dahdi asterisk asterisk-doc

During the install, you will be asked to type in your phone country prefix (46 for Sweden).

Then of course the big question is, is your card recognized?

xyz@xyz:~$ lspci
00:1f.3 SMBus: Intel Corporation N10/ICH 7 Family SMBus Controller (rev 01)
01:00.0 Network controller: Tiger Jet Network Inc. Tiger3XX Modem/ISDN interface <--- bingo!
01:02.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL-8139/8139C/8139C+ (rev 10)

Then try running the commands from the dahdi package to generate the appropriate configuration file and look at the result:

dahdi_genconf
vim /etc/init.d/dahdi/system.conf

At the first attempt, my system.conf file only had a dahdi dummy device. Other tools at your disposal from the dahdi package are dahdi_hardware and dahdi_scan:

xyz@xyz:~$ dahdi_scan
[1]
active=yes
alarms=UNCONFIGURED
description=DAHDI_DUMMY/1 (source: HRtimer) 1
name=DAHDI_DUMMY/1
manufacturer=
devicetype=DAHDI Dummy Timing
location=
basechan=1
totchans=0
irq=0
xyz@xyz:~$ dahdi_hardware
driver should be 'wctdm' but is actually 'netjet'
pci:0000:01:00.0     wctdm+       e159:0001 Wildcard TDM400P REV I

OK. So dahdi_scan only sees a dummy but dahdi_hardware sees the card. That’s at least something. Googling a bit we find that the issue is indeed that another driver is loaded instead of wctdm that dahdi would like to use. Let’s black list this netjet module as recommended in the link above and restart the computer.

xyz@xyz:~$ sudo dahdi_hardware
pci:0000:01:00.0     wctdm+       e159:0001 Wildcard TDM400P REV I
xyz@xyz:~$ sudo dahdi_scan
[1]
active=yes
alarms=OK
description=Wildcard TDM400P REV I Board 5
name=WCTDM/4
manufacturer=Digium
devicetype=Wildcard TDM400P REV I
location=PCI Bus 01 Slot 01
basechan=1
totchans=4
irq=17
type=analog
port=1,FXS FAILED
port=2,none
port=3,none
port=4,FXO
[2]
active=yes
alarms=UNCONFIGURED
description=DAHDI_DUMMY/1 (source: HRtimer) 1
name=DAHDI_DUMMY/1
manufacturer=
devicetype=DAHDI Dummy Timing
location=
basechan=5
totchans=0
irq=0

Presto, now the card is recognized. We can now run the configuration tool again.

dahdi_genconf
vim /etc/init.d/dahdi/system.conf

Now my system.conf looks like this:

# Autogenerated by /usr/sbin/dahdi_genconf on Sat Mar  5 22:56:01 2011
# If you edit this file and execute /usr/sbin/dahdi_genconf again,
# your manual changes will be LOST.
# Dahdi Configuration File
#
# This file is parsed by the Dahdi Configurator, dahdi_cfg
#
# Span 1: WCTDM/4 "Wildcard TDM400P REV I Board 5" (MASTER)
# channel 1, WCTDM/4/0, no module.
# channel 2, WCTDM/4/1, no module.
# channel 3, WCTDM/4/2, no module.
fxsks=4
echocanceller=oslec,4
# Span 2: DAHDI_DUMMY/1 "DAHDI_DUMMY/1 (source: HRtimer) 1"
# Global data
loadzone    = se
defaultzone    = se

just cheated to have “se” instead of “us” for the zone parameters. Note that the FXS port is failed. I had simply forgotten to connect the power cable to the Digium card. if you see a similar message. Run dmesg and you should see something like this in the last lines:

[   14.425128] Module 0: Not installed
[   14.425256] Module 1: Not installed
[   14.933016] ProSLIC on module 2 failed to powerup within 504 ms (0 mV only)
[   14.933017]
[   14.933018]  -- DID YOU REMEMBER TO PLUG IN THE HD POWER CABLE TO THE TDM400P??
[   14.933022] Unable to do INITIAL ProSLIC powerup on module 2
[   15.441020] Unable to do INITIAL ProSLIC powerup on module 2
[   15.441025] Module 2: FAILED FXS (FCC)
[   15.641341] Module 3: Installed -- AUTO FXO (FCC mode)
[   15.648015] Found a Wildcard TDM: Wildcard TDM400P REV I (1 modules)

The solution is of course to stop your computer once again, plug the power cable (a simple one like those that go to the CD-drive) and restart the computer and rerun the commands above. Remember when you do a change to the configuration file, restart dahdi:

xyz@xyz:~$ sudo /etc/init.d/dahdi restart
Unloading DAHDI hardware modules: done
Loading DAHDI hardware modules:
 dahdi: done   dahdi_dummy: done   dahdi_transcode: done   wctdm: done
Running dahdi_cfg: done.

More to read about Dahdi here. Some old tutorial for the combo zaptel/asterisk here.

Configuring asterisk

Now, let’s move on to asterisk and verify that what we have is working fine.

xyz@xyz:~$ sudo asterisk -r
Asterisk 1.6.2.5-0ubuntu1.3, Copyright (C) 1999 - 2009 Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 1.6.2.5-0ubuntu1.3 currently running on barouterw (pid = 7646)
Core debug is at least 9
xyz*CLI> dahdi show
cadences  channel   channels  status    version  
xyz*CLI> dahdi show status
Description                              Alarms  IRQ    bpviol CRC4   Fra Codi Options  LBO
Wildcard TDM400P REV I Board 5           OK      0      0      0      CAS Unk  YEL      0 db (CSU)/0-133 feet (DSX-1)
xyz*CLI> dahdi show ch
channels  channel  
xyz*CLI> dahdi show channels
 Chan Extension  Context         Language   MOH Interpret        Blocked    State    
 pseudo            default                    default                         In Service
 3            from-internal   en         default                         In Service
 4            from-pstn       en         default                         In Service

If you only see the pseudo channel in “dahdi show channels”, then you should include the following at the end of chan_dahdi.conf:

#include dahdi_channels.conf

Now that your hardware is recognized properly, we need to define a dial-plan. In my case, my phone is connected to port 3, the FXS port, and my landline/modem is connected to port 4, the FXO port.

In my case, I want two extensions 2001, 2002 that can access the setup via SIP, and I want my regular phone to be able to call these two extensions or the outside. Below is a very simple example of dial-plan for that:

[from-pstn]
exten => s,1,Set(CALLERID(num)=${CALLERID(num)})
exten => s,n,Dial(DAHDI/3)
exten => s,n,Hangup()

[from-sip]
exten =>s, Answer()
exten =>s, WaitExten()

exten =>_XX.,1,Dial(DAHDI/4/${EXTEN})
exten =>_XX.,n,Hangup()

exten =>200X,1,Dial(SIP/${EXTEM})
exten =>200X,n,Hangup()

[from-internal]
exten =>s, Answer()
exten =>s, WaitExten()

exten =>_XX.,1,Dial(DAHDI/4/${EXTEN})
exten =>_XX.,n,Hangup()

exten =>200X,1,Dial(SIP/${EXTEM})
exten =>200X,n,Hangup()

You need to edit your sip.conf accordingly:

[2001]
type=friend
secret=xyz
qualify=200
nat=yes
host=dynamic
directmedia=yes
callerid="Alice" <2001>
context=from-sip

[2002]
type=friend
secret=xtz
qualify=200
nat=yes
host=dynamic
directmedia=yes
callerid="Bob" <2002>
context=from-sip

The last part of the job before you have a working setup (albeit a simple one) is to edit further you chan_dahdi.conf to match your country and telecom operator’s settings. In my case in Sweden with Bredbandsbolaget:

usecallerid=yes
cidsignalling=dtmf
cidstart=polarity
busydetect=yes
busycount=6
busypattern=500,500
answeronpolarityswitch=yes
hanguponpolarityswitch=no
tonezone = 16

So this concludes this article on my little setup with Asterisk at home. I still need to implement voice mail, decide if the SIP server should be public or not, and start having fun with those telemarketers. There seem to be already plenty of links with silly ideas about that out there :)

Written by baroquew

March 12, 2011 at 14:45

5 minutes from DSL-modem break-down to playing on the PSN using an iPhone

leave a comment »

A few days ago, our DSL modem gave up and stopped synching. It started intermittently but eventually it stopped working altogether. One phone call later, I had to find a replacement solution to play Battle Field: Bad Company 2 – Vietnam (by the way, what’s with the ranking servers lately? Can’t seem to get my proper rank displayed on more than 50% of the games…).

Equipment:

- iPhone 3GS with unlimited data plan
- USB-dock cable
- a Mac computer with Wifi running (Snow) Leopard

On the iPhone, under System Preferences, Network, Internet Tethering, turn the switch to on. If it asks you, USB only is fine. Using 3G and Bluetooth would drain your battery way too fast. Connect the iPhone to your Mac and wait for iTunes to be done synchronizing the phone (it seems every time you restart iTunes — for an update for instance — the phone will interrupt the Tethering).

USB Tethering

Turn it on!

Open the Mac’s System Preferences. Under Network, find the “iPhone USB” connection and verify you have an IP address there (by default something like 172.10.20.2).

iPhone USB connection

Now verify that you have Internet on your Mac. Still in System Preferences, under Network, Airport, connect to a new network. Give it some name. By default, it will have the hostname of your computer and have no security. You should probably change this to avoid your neighbors stealing your already limited bandwidth. Then under advanced, TCP/IP, give yourself a manual IP address (192.168.1.1, netmask 255.255.255.0, router 192.168.1.1) as shown below.

Adhoc network and manual IP

Finally, and still in System Preferences, under Sharing, Internet sharing, select Share your connection from “iPhone USB” and To computers using “AirPort” and in AirPort Options, select your newly created SSID. Then enable Internet sharing.

Internet sharing

Now on the Playstation 3, go under Settings, Network settings. Pass on the message and select the Custom way. Pick wireless, enter manually the name of your computer in the SSID name field or scan for it. Enter the security settings for the connection if you need any. Then for the IP address settings, select manual and enter an IP of 192.168.1.x (1<x<255), netmask 255.255.255.0 and your router IP is 192.168.1.1 (the computer with the iPhone tethering). You can keep the other parameters to their default values in the next screens, except the DNS settings. You can use 8.8.8.8 (Google’s own DNS server) or whichever DNS server your ISP recommends.  You can also refer to the online guide from Sony which is quite detailed.

If you have further devices to connect, go ahead. We are running an iPad, an iPod, a laptop and a PS3 here all with success. Also, I had no need to use static IP addresses on other devices. Just on the PS3 we had to give a manual IP address for some reason.

PS: a big thanks to the WordPress app for iPad which allowed me to type the entire twice because it’s unable to synchronize properly the draft. Thanks…

Written by baroquew

January 16, 2011 at 14:05

Follow

Get every new post delivered to your Inbox.

Join 36 other followers