Hack45.Forward Your Home Calls to Your Cell Phone


Hack 45. Forward Your Home Calls to Your Cell Phone

Using Asterisk, you can create a simple call forwarder, so calls to your home can follow you whenever you go.

Asterisk is a programmable platform in the same way that the Apache Web Server is. There are many ways to program Asterisk, but all of them connect in some way to the core of Asterisk's functionalityits so-called "dial plan." The dial plan begins (and usually ends) in /etc/asterisk/extensions.conf. Using the dial plan, you can program how your softPBX should behave, which phones should ring when different digits are dialed, how long they should ring, and what to do if nobody answers when they ring.

So, it's actually pretty straightforward to program the dial plan to forward all incoming calls from a certain line to another phone number via a second line. There are many uses for this, including having your phone calls follow you wherever you go, as well as using the Asterisk server as a screen so that you don't have to give people the number you are forwarding to. This is a great way to keep your cell phone or parents' home phone number private. The Asterisk server will dial the cell phone on the second line and then bridge (or conference) the two lines together for the duration of the call.

The hardest part about setting up this configuration is connecting two lines (or two SIP peers acting as lines [Hack #43] to the Asterisk server. Once that's done, the forwarding part is simple. But before we get to that, let's check out the configuration for the two lines.

Let's assume that two SIP peers are connected to the Asterisk server, vis-à-vis a media gateway with two SIP clients, like the Clipcomm used earlier [Hack #43]. The sip.conf configuration for these peers would look something like this:

 [7711] caller <200> canreinvite=no context=incoming dtmfmode=rfc2833 host=dynamic port=5060 type=friend username=7711 [7712] caller <201> canreinvite=no context=default dtmfmode=rfc2833 host=dynamic port=5060 type=friend username=7712 

Line 1 is SIP peer 7711, and line 2 is SIP peer 7712. Let's say that the line we're going to receive calls on is line 1, and the line we're going to use to call the cell phone is line 2. Note context=incoming. This creates a context within Asterisk for incoming calls to arrive. Now, open up extensions.conf so that you can create a dial plana set of instructions that tell Asterisk what to do in this incoming contextto correspond to peer 7711's incoming context setting:

 [incoming] exten => s,1,Dial(SIP/7712/${CELL_PHONE},30) exten => s,2,Playback(abandon-all-hope) exten => s,3,Hangup 

Since sip.conf indicates that all incoming calls from SIP peer 7711 should enter the incoming context, we've created that context in the dial plan (as shown in the previous code snippet). Using the special s extension, whose purpose is to incorporate into the context incoming calls that haven't been triggered by a user dialing an extension number (calls like those incoming from the outside world), we can specify three steps to deal with the call:

  1. Dial the cell phone number on the second SIP peer (7712). You can specify the numberfor instance, 1-440-864-8604instead of using the ${CELL_PHONE} variable, since we haven't really covered variables yet. The 30 specified in the first command says to attempt to bridge (conference) the call on the two lines for up to 30 seconds before giving up.

  2. If the call isn't bridged because the Dial command times out, the Playback command will play a greeting. In this case, I've specified a greeting called abandon-all-hope.

  3. If either of the previous steps cannot be completed, the caller will be disconnected.

So, when an incoming call from SIP peer 7711 hits the server, SIP peer 7712 (the "second line") will be directed to call your cell phone and attempt to bridge the call.

I know what you're thinking: "Why wouldn't I just use my phone line's built-in call-forwarding service to do this?" My answer is "Selectively Forward Calls" [Hack #46].




VoIP Hacks
VoIP Hacks: Tips & Tools for Internet Telephony
ISBN: 0596101333
EAN: 2147483647
Year: 2005
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net