The Arrowhead Website

It has begun.  I installed the template today.  I got the top menu mostly done, and started on the side menu when I ran out of bandwidth.  I also bought a laser printer for the students, fixed the phone system (I hope) and did something else that I cannot remember.  We got snow today.  I bet we had eight or nine inches.  Yeah, that is all I have to say.

Psalm 73:22-25 So foolish was I, and ingnorant: I was as a beast before thee. Nevertheless I am continually with thee: thou has holden me by my right hand. Thou shalt guide me with thy counsel, and afterward receive me into glory. Whom have I in heaven but thee? And there is none upon earth that I desire beside thee.

John 2:24-25 But Jesus did not commit himself unto them, because he knew all men, and needed not that any should testify of man: for he knew what was in man.

I Love Weekends

I have not much to say.  I’m glad the week is done.  I’ve had a really good day, and there is a lot I like in Psalm 71.

Psalm 71:1 In thee, O Lord, do I put my trust: let me never be put to confusion.

71:3 Be thou my strong habitation, whereunto I may continually resort: thou hast given commandment to save me; for thou art my rock and fortress.

71:6 By thee have I been holden up from the womb: thou art he that took me out of my mother’s bowels: my praise shall be continually of thee.

71:20-23 Thou, which hast shewed me great and sore troubles, shalt quicken me again, and shalt bring up again from the depths of the earth. Thou shalt increase my greatness, and comfort me on every side. I will also praise thee with the psaltery, even thy truth, O my God: unto thee will I sing with the harp O thou Holy One of Israel. My lips shall greatly rejoice when I sing unto thee; and my soul, which thou hast redeemed.

Moving On

I have to say it’s wonderful not to have anything to say about the phone system, other than it is running mostly smoothly.  I’ve been moving on to other projects.  We are re-doing the Arrowhead website (still, but we’ve finally got a clear direction to take it), and I’ve been documenting my job.  We had decided a while back to get a second sattelite Internet account.  At first we were only going to use it at night, so I had to figure out how to switch from one modem to the other.  It took some work, but I got it.  Today I find out they want me to set it up so we use both accounts at the same time.  Dang.  Now I have to redo everything.  Literally.  I’m running IPCop on our router, and it wont do multiple simultaneous Internet connections.  I’ve got to install and learn a totally new system by the end of this month.  Yeah… ok.  It’ll be interesting.  I’m planning on using pfsense, so we’ll see how that goes.  I caught another cold, but it really hasn’t been that bad.  A cough and a bit of a stuffed nose, but other than that I’ve felt great.

Ok, totally different topic.  Just for the record last weekend was horribly wonderful.  I took a half day on Friday, and went hiking with a couple of the students.  Long story short, we (ok I) got my car stuck, got it unstuck (with some help), went hiking through waste deep snow, and then drove back to camp on very muddy/slippery roads.  The office chair has not been good to me, I almost died.  Then Saturday afternoon we went hiking again, followed by a bike ride on Sunday.  I had more physical activity last weekend than I’ve had in the past three or four months combined.  End of story.  This blog has gotten rather long and rambling.

 

Psalm 70:5 But I am poor and needy: make haste unto me, O God: thou art my help and my deliverer; O Lord, make no tarrying.

Proverbs 30:32 If thou hast done foolishly in lifting up thyself, or if thou hast thought evil, lay thine hand upon thy mouth.

Basically (Eric’s paraphrase) shut up.

Ecclesiastes 12:12 And further, by these, my son, be admonished: of making many books there is no end; and much study is a weariness of the flesh.

I read this and thought of the college students.

12:13-14 Let us hear the conclusion of the whole matter: Fear God, and keep his commandments: for this is the whole duty of man. For God shall bring every work into judgment, with every secret thing, whether it be good, or whether it be evil.

 

Freeswitch Howto: Configuration

In this section I’m going to focus exclusively on calling in and out over the POTS lines.  I’m doing this for two reasons.  One, this was the part I had the most trouble with, and two, the other dialplan options are (or seem to me to be) better documented.  I would suggest buying the Freeswitch book.  It’s been very helpful to me, though some if the information is outdated.

When setting up in-bound and out-bound analog calling (using the freetdm mod which was enabled on install) we deal with these files(these are all in the default install locations, if you installed some where else you’ll have to adjust accordingly):

/usr/local/freeswitch/conf/freetdm.conf
/usr/local/freeswitch/conf/autoload_configs/freetdm.conf.xml
/usr/local/freeswitch/conf/dialplan/default.xml
/usr/local/freeswitch/conf/dialplan/public/00_inbound_did.xml

I’ll post these, and go through the ones I know.

/usr/local/freeswitch/conf/freetdm.conf

[span wanpipe FXS]
name => freetdm
trunk_type => fxs
group => grp1
fxs-channel => 1:7

trunk_type => fxs
group => grp1
fxs-channel => 1:8

[span wanpipe FXO]

name => freetdm
trunk_type => fxo
group => grp2
fxo-channel => 1:1

trunk_type => fxo
group => grp2
fxo-channel => 1:2

trunk_type => fxo
group => grp2
fxo-channel => 1:3

trunk_type => fxo
group => grp2
fxo-channel => 1:4

trunk_type => fxo
group => grp2
fxo-channel => 1:5

trunk_type => fxo
group => grp2
fxo-channel => 1:6

Now to be honest I didn’t actually configure this file, or freetdm.conf.xml.  When /usr/sbin/wancfg_fs was run it automatically set both of these files up.  I didn’t have to change either of them.

/usr/local/freeswitch/conf/autoload_configs/freetdm.conf.xml

<analog_spans>
<span name=”FXO”>
<!–<param name=”hold-music” value=”$${moh_uri}”/>–>
<param name=”dialplan” value=”XML”/>
<param name=”context” value=”public”/>
<!– regex to stop dialing when it matches –>
<!–<param name=”dial-regex” value=”5555″/>–>
<!– regex to stop dialing when it does not match –>
<!–<param name=”fail-dial-regex” value=”^5″/>–>
</span>

<span name=”FXS”>
<!–<param name=”hold-music” value=”$${moh_uri}”/>–>
<param name=”dialplan” value=”XML”/>
<param name=”context” value=”default”/>
<!– regex to stop dialing when it matches –>
<!–<param name=”dial-regex” value=”5555″/>–>
<!– regex to stop dialing when it does not match –>
<!–<param name=”fail-dial-regex” value=”^5″/>–>
</span>
</analog_spans>

 

Now we get to the good stuff.  I took this from my default dial plan.  It only shows one of our five lines, but it should be enough to get you headed in the right direction.

/usr/local/freeswitch/conf/dialplan/default.xml

<extension name=”Call out business hours(Staff)” continue=”true”>
<condition field=”ani” expression=”^(1014|1015)” break=”on-true”/>
<condition wday=”2-6″ hour=”9-18″/>
<!– The call out prefix is 7 –>
<condition field=”destination_number” expression=”^7(.+)$”>
<action application=”set” data=”hangup_after_bridge=true”/>
<action application=”set” data=”continue_on_fail=true”/>
<action application=”bridge” data=”freetdm/FXO/2/$1″/>
<action application=”bridge” data=”freetdm/FXO/3/$1″/>
<action application=”bridge” data=”freetdm/FXO/4/$1″/>
<action application=”bridge” data=”freetdm/FXO/5/$1″/>
<action application=”bridge” data=”freetdm/FXO/1/$1″/>
<action application=”playback” data=”phrase:oh_gee”/>
</condition>
</extension>

The break down:

<extension name=”Call out business hours(Staff)” continue=”true”>

This is simply the extension name. I have continue set to true. I didn’t think I needed it but it wouldn’t work without it.

 

<condition field=”ani” expression=”^(1014|1015)” break=”on-true”/>

I have two phones that I don’t want dialing out on this extension. If phones 1014 or 1015 are dialing the number they won’t go out through this extension.

 

<condition wday=”2-6″ hour=”9-18″/>

This extension only works Monday through Friday between nine in the morning and six at night.

 

<condition field=”destination_number” expression=”^7(.+)$”>

Our “call out” number is seven. If seven is dialed before the number it is an external call and will be run through this extension.

 

<action application=”set” data=”hangup_after_bridge=true”/>

I’m not sure why this is important but I needed it.

 

<action application=”set” data=”continue_on_fail=true”/>

If you remember we have five outgoing phone lines (POTS). If one of them is busy (it fails to connect) I want to try the next phone line.

 

<action application=”bridge” data=”freetdm/FXO/2/$1″/>

This is the good part. This actually does the calling. The “freetdm/FXO/2” references freetdm.conf.xml. Span FXO, line 2. The “$1” is the number the person is calling. If line 2 is busy it “continue_on_fail=true” so it tries the next one (and so on and so forth).

 

<action application=”playback” data=”phrase:oh_gee”/>

This last line is simply a message, I recorded. If all the phone lines are in use this message gets played and the call ends.

 

Incoming Calls

This was by far the hardest part for me. Thanks to Steve on the Freeswitch mailing list for explaining it to me.

First let me explain what I was trying to do. Like I said earlier, we have five POTS lines. I needed to direct incoming calls from each line individually to different phones (and or groups) on campus. Where the calls get directed depends on the time of day and the particular phone line in question (I hope that isn’t to confusing).

/usr/local/freeswitch/conf/dialplan/public/00_inbound_did.xml

<!– LINE1 328-6825–>
<!– during work hours will ring the “Administration” phones –>
<extension name=”Line 1(6825) work” continue=”true”>
<condition field=”source” expression=”mod_freetdm”/>
<condition wday=”2-6″ hour=”9-18″/>
<condition field=”${channel_name}” expression=”^(FreeTDM/2:1/)$”>
<action application=”set” data=”domain_name=$${domain}”/>
<action application=”set” data=”transfer_ringback=$${us-ring}”/>
<action application=”transfer” data=”2020 XML default”/>
</condition>
</extension>

<!– During off hours goes to everyone except Kitchen and Guests –>
<extension name=”Line 1(6825) not work” continue=”true”>
<condition field=”source” expression=”mod_freetdm”/>
<condition field=”${channel_name}” expression=”^(FreeTDM/2:1/)$”>
<action application=”set” data=”domain_name=$${domain}”/>
<action application=”set” data=”transfer_ringback=$${us-ring}”/>
<action application=”transfer” data=”2035 XML default”/>
</condition> </extension>
<!– LINE1 DONE–>

Again, line by line:

<extension name=”Line 1(6825) work” continue=”true”>

This is simply the extension name. I have continue set to true. I’m pretty sure I need it, and it works with it enabled.

 

<condition field=”source” expression=”mod_freetdm”/>

This tells Freeswitch the source of the inbound call (pretty self explanatory).

 

<condition wday=”2-6″ hour=”9-18″/>

This extension only works Monday through Friday between nine in the morning and six at night.

 

<condition field=”${channel_name}” expression=”^(FreeTDM/2:1/)$”>

This tests to see what line is calling from the “mod_freetdm” source. My FXO ports are in the second span of my freetdm.conf,  so “FreeTDM/2:1/” is span two line 1. This is the part I got from Steve, and I couldn’t find this information any where.

 

<action application=”set” data=”domain_name=$${domain}”/>

I have no idea what this does but I know I need it.

 

<action application=”set” data=”transfer_ringback=$${us-ring}”/>

I’m assuming this changes depending on the country you live in.

 

<action application=”transfer” data=”2020 XML default”/>

This transfers the incoming call to (in my case) group 2020 in the default dial plan. It can be replaced with any valid extension number.

The second extension (again this is just for one of our phone lines.  Each line will need an extension) is for off hours and weekends.

 

Faxing

We have an analog fax machine, which is why I needed the FXS modules on my Sagnoma card.  Here are the relevant dialplan parts I used to send and receive faxes.

 

Receiving a Fax

This gets set up in the public dialplan.  On our install /usr/local/freeswitch/dialplan/public/00_inbound_did.xml.

<!– LINE3 328-6982–>
<!– Always directed to the fax machine –>
<extension name=”Line 3(6982)” continue=”true”>
<condition field=”source” expression=”mod_freetdm”/>
<condition field=”${channel_name}” expression=”^(FreeTDM/2:3/)$”>
<action application=”set” data=”domain_name=$${domain}”/>
<action application=”set” data=”transfer_ringback=$${us-ring}”/>
<action application=”bridge” data=”freetdm/2/3|freetdm/1/1″/>
</condition>
</extension>
<!– LINE3 DONE–>

<action application=”bridge” data=”freetdm/2/3|freetdm/1/1″/>

This is the important one.  It takes the incoming call from span 2 line 3 and transfers it to span 1 line 1.

 

Sending a Fax

This gets set up in the default dialplan.  On our install /usr/local/freeswitch/conf/dialplan/default.xml.

<extension name=”bridge-FXS-to-FXO” continue=”true”>
<condition field=”destination_number” expression=”^7(.+)$”/>
<condition field=”channel_name” expression=”FreeTDM/1:1/”>
<action application=”bridge” data=”freetdm/1/1/${destination_number}|freetdm/2/3/${destination_number}”/>   </condition>
</extension>

<condition field=”channel_name” expression=”FreeTDM/1:1/”>
<action application=”bridge” data=”freetdm/1/1/${destination_number}|freetdm/2/3/${destination_number}”/>   </condition>

These are the two lines that work the magic.  I got this off the Freeswitch wiki.  Direct span 1 line 1 to span 2 line 3 and dial the number.  Presto the fax goes out.

Freeswitch Howto: Installation

I’m not going to cover the installation of CentOS 5.5, nor will I cover how to setup a software RAID.  There are plenty of other tutorials already done that explain those things.  Here is what I did, though, step by step to get Freeswitch and the wanpipe drivers installed on our system (I’m assuming a basic working knowledge of the Linux command line).

Note: All of the following commands should be run as root.

yum list updates

yum update

yum install unixODBC-devel gnutls-devel libtiff-devel autoconf automake awk* bison core-devel curl-devel expat-devel flex gcc* gettext-devel gnutls gnutls-devel kernel-devel-$(uname -r) libjpeg-devel libtiff libtiff-devel libtool libX11-devel libzrtpmake ncurses-devel openssl patch python-devel unixODBC-devel zlib zlib-devel

The above commands should install all the dependencies needed for git, the Sangoma drivers, and freeswitch.

Install Git

Make sure /usr/local/lib is in your ld.so.conf, this is required for git-http-push to correctly link up to the Curl version you are installing.

vi /etc/ld.so.conf

Insert the following:
/usr/local/lib

Save the file, then run:
ldconfig

Now download and install Git:
cd /usr/local/src
wget http://www.codemonkey.org.uk/projects/git-snapshots/git/git-latest.tar.gz
tar xzvf git-latest.tar.gz
cd git-{date}
autoconf
./configure –with-curl=/usr/local
make
make install

Install Sangoma Drivers

cd /usr/local/src
wget ftp://ftp.sangoma.com/linux/current_wanpipe/wanpipe-latest.tgz
tar xfz wanpipe-latest.tgz
cd wanpipe-.tgz
make freetdm
make install

Install Freeswitch

cd /usr/local/src
git clone git://git.freeswitch.org/freeswitch.git
cd freeswitch
./bootstrap.sh

Edit modules.conf remove the “#” from the freetdm and flite modules:
vi /usr/local/src/freeswitch/modules.conf

When your done editing save and continue with the installation:
./configure
make
make install
make all cd-sounds-install cd-moh-install
The last command will download about 300Mb of sound files.  These are for the voice mail/IVR system and the music on hold.

Run this command to configure the Sangoma hardware. When I set this up I had to turn off hardware DTMF. When it was on using calling cards was almost impossible. Calling cards work just fine with the software DTMF.

/usr/sbin/wancfg_fs

This will start freeswitch. To start it as a daemon freeswitch -nc.
cd /usr/local/freeswitch/bin
./freeswitch

This will start the freeswitch command line when the command “fs_cli” is run.
ln -s /usr/local/freeswitch/bin/fs_cli /usr/local/bin/fs_cli

That’s it.  I would suggest starting Freeswitch with the -nc option, unless your having problems and need to trouble shoot.

Freeswitch Howto

As promised here is my Freeswitch howto.  A few things first.  The reason I’m doing this is to get more documentation out there.  I have to admit I have never been so disappointed with Google.  I had one heck of a time trying to find the information I needed, so I’m writing this in hopes that the next poor sap wont have such a hard time.  I offer no guarantees that any of this will work for you, nor do I guarantee that it wont completely destroy your system if you try it.  A lot of this information can be found on the Internet, some of it I got through the Freeswitch mailing list, the Freeswitch wiki, and the Sangoma wiki.  That being said here goes.

 

Background

I work at Beartooth Mountain Christian Ranch.  We run 10 weeks of camp in the summer, and a one year Bible college during the off season.  We have buildings spread across our campus, and wanted a phone system that worked in all of them.  Up until now we’ve had a system in the main office, but no way of transferring calls to the other buildings.  When our office phone system broke they told me to look into an actual campus wide PBX, and Freeswitch was what I came up with.  We’ve got five POTS lines that come into camp, 17 phones, one fax, and two soft phones to share them with.   We needed to be able to (obviously) send and receive phone calls and faxes, but we also wanted to be able to transfer phone calls and get every one a voice mail box.

 

The Hardware

Mother board: Asus M2N68-AM Plus

CPU: AMD Athlon X2 Black Edition 2.8GHz

RAM: 2Gb PC6400 Crucial

HDD: 2 500Gb WD in a software RAID 1 setup

Telephony Card: Sangoma A200 PCI-e with hardware echo cancelation – 1 Remora addon with 3 FXO modules, 1 FXS module, and a back pane connector.

Wired IP Phones: 15 Grandstream GXP280

Wireless IP Phones: 2 Cisco WIP310

The Software

I’m using CentOS as the operating system.  Freeswitch git version c7abfa7 (I downloaded it March 6, 2011).  Wanpipe driver version 3.5.18.

 

Installation

 

Configuration

 

The Phone System is Done (I Think)

I went live with it last night, and things are good so far.  I discovered the problems I was having with sending double DTMF tones was because both my software (Freeswitch) and my hardware driver (wanpipe) were both sending the signals.  Once I got that reconfigured, and changed some settings on our phones everything worked.  So it was a good day.  I also had to redo my voice mail web page because the Freeswitch guys changed some things around in that part as well.  I’ll be documenting the whole thing tomorrow morning in the tech section of this blog.

Proverbs 28:13 He that covereth his sins shall not prosper: but whoso confesseth and forsaketh them shall have mercy.

It is sad how opposite this is to how I actually live.

A Long Week Last Week

So after my oops on Tuesday during the day I made another one that night.  In my attempt to fix the phone system I decided to update the software.  The update went fine, but I couldn’t start the program.  So in one day I single handedly took out the entire network, and the phone system.  I was up till 1:00 a.m. trying to fix it.  At that point I called it quits and set the old system back up, but I didn’t get done with that till 2:00.  Then I got sick.  Basically last week was not fun at all.  The phone system is finally starting to come back together, but I’ve still got a ways to go.  I’m feeling much better though I’ve got a bit of a cough.  I also spent almost no time with God last week and I’ve missed Him, so I’m trying to remedy that.

Psalm 67:1 God be merciful unto us, and bless us; and cause his face to shine upon us; Selah.

67:5-7 Let the people praise thee, O God; let all the people praise thee. Then shall the earth yield her increase; and God, even our own God shall bless us. God shall bless us; and all the ends of the earth shall fear him.

Proverbs 27:1-2 Boast not thyself of tomorrow; for thou knowest not what a day may bring forth. Let another man praise thee, and not thine own mouth; a stranger, and not thine own lips.

Ecclesiastes 9:18 Wisdom is better than weapons of war: but one sinner destroyeth much good.

Oops

It was a very eventful day.  I was working on our router today and some how manged to accidentally  turned off our dhcp server.  For those of you who don’t know that is what gives all the computers on the network an address.  So in the middle of my job performance review, the network completely died.  No printing, no file server, no phones, and no Internet.  The good news is they didn’t fire me, my review went fine, and I fixed the problem (but not till after lunch).  The new phone system is installed and mostly working.  I’ve been getting some really weird problems when people call out using their phone cards.  It seems to randomly send extra DTMF tones.  What is stranger is that only our hardware phones do it.  The softphone on my computer works just fine.  No problems at all.  I’m going to do a bit of Googling tomorrow to see if I can fix it.  If Google doesn’t have the answer I’ll go back the the Freeswitch mailing list.  They really are helpful.

Psalm 65:1  O thou that hearest prayer, unto thee shall all flesh come.

Proverbs 25:9  Debate thy cause with thy neighbour himself; and discover not a secret to another:

25:27 It is not good to eat much honey: so for men to search their own glory is not glory.

Ecclesiastes 7:3-4  Sorrow is better than laughter: for by the sadness of the countenance the heart is made better. The heart of the wise is in the house of mourning; but the heart of fools is in the house of mirth.

7:8  Better is the end of a thing than the beginning thereof: and the patient in spirit is better than the proud in spirit.

7:14  In the day of prosperity be joyful, but in the day of adversity consider: God also hath set the one over against the other, to the end that man should find nothing after him.

7:20  For there is not a just man upon earth, that doeth good, and sinneth not.