Tag Archives: home

Some recent projects for fun and work

I’ve had fun with a few personal and work-related VoIP projects lately. I’ll summarize them here, and if there’s any interest I’ll expand one or more of them into full how-to articles. 

speak2tweet
You may have heard about the Google/Twitter project called speak2tweet that was created over a weekend during the Egyptian protests, with the goal of allowing protesters whose Internet connectivity was cut to get their voices on to the web. Some folks on the PBX-in-a-Flash forum were talking about it and we realized it would not be hard to build, especially with the Tropo transcription service available to us.
Check out the first page of that thread for the dial-in numbers, and then try it out yourself. The code is posted on the forum for the first hack at it, which only does transcription. The current version includes links to the recordings, too, just like the original speak2tweet. I need to clean it up and post it. See and hear your spoken tweets at twitter.com/piafspeaktweet.
Fax
I have largely ignored fax over VoIP for a long time, because it’s not something I do. At PSU, we attach fax machines to analog lines; done. But recently, I was asked to assist with a quick-turnaround fax project: send a fax to 4,059 analog lines on campus, calls spaced one minute apart, and record the results, so that we can see how many fax machines are hooked up out there. Interesting. I tried Digium’s Free Fax for Asterisk module, but couldn’t get it to communicate. Next I built the soft-switch.org spandsp module, and told Asterisk to use it, and it worked right away. A Perl script using the excellent Asterisk::AMI module (referenced previously on this blog) drove the dialer, and standard Asterisk CDR with a few extra fields recorded the fax results. By the way, the faxes were sent in audio mode (not T.38) using SIP and G.711u over the Internet, and only 3 out of 4,059 calls failed.
FreeSWITCH revisited
Back when I wrote about using FreeSWITCH alongside Asterisk as a gateway to Google Voice, I determined that at some point I’d come back and dig into FreeSWITCH a little more just to understand it. I updated that article with a slightly better config, including lines that turn on comfort noise, which helps the FreeSWITCH-Asterisk bridge maintain synchronization on RTP. (See the FreeSWITCH wiki for more information on that.)

A brief review of the Grandstream HT-502 ATA

The used HT-502 2-FXS analog telephony adapter I bought from eBay arrived earlier this week, and I hoped that by this time I could write about two functional rotary dial phones happily dialing out through this device.

No such luck, but the HT-502 is not to blame. The Northern Electric 302 seems to be mis-wired, because the ATA isn’t detecting the pulse dialing at all. I’ll have to open it up and dig in this weekend. The Automatic Electric Monophone 40, on the other hand, is wired correctly but needs some adjustment: the upper digits (7 through 0) sometimes miss a click, resulting in mis-dialing.

Image from Grandstream.comThat said, I’m already prepared to give the Grandstream HT-502 ATA very positive reviews. In fact, I might like it even better than my trusty Cisco-Linksys-Sipura SPA3102.

You can read about the device on Grandstream’s web site. Here are the unmentioned features that I really like:

  • It accepts rotary/pulse dialing, without any special configuration or modification. This was the reason I bought it, and indeed, it works. The HT-503 (1 FXS and 1 FXO port) can accept pulse dialing on its FXS port, also.
  • On an active call, it accepts rotary-dialed input and converts to SIP DTMF codes. Thus you can navigate a menu tree with your rotary phone, as long as you don’t need “*” or “#”.
  • You can configure the device with a touch-tone phone (real touch-tone; “*” required), web browser, or telnet. You can also provision the device using TFTP like the “big guys” do.
  • It has an excellent debugger. In the Advanced menu, enter the IP address of your syslog server (prerequisite: set up a syslog server), and set the verbosity to DEBUG. The floodgates will open and you will be able to see every action the device performs or receives, including dialed digits from the analog ports. This is how I was able to see where my rotary dial was sticking.
  • The device can pull its own firmware upgrades over the Internet. Nice if used carefully.
  • It’s super easy to configure. I followed documentation to factory-reset the device, hooked up a laptop to the LAN port, and reconfigured it for my own network in about 5-10 minutes. 
  • Lastly–and this is a rather obscure bonus–it uses the same power supply specifications as the Cisco-Linksys SPA devices. This hardly matters except that I have one of these–a wireless bridge for Cisco SPA devices with pass-through power. I’m planning to make the HT-502 WiFi.

The HandyTone 502 has made a good first impression and I’m looking forward to getting my rotary phones fully working on it.

A new old phone and rotary dialing, revisited

During the holidays I received and lightly restored another beautiful telephone from the 1940s, this Automatic Electric Monophone model 40:

ae40.jpgAutomatic Electric was an independent supplier of telephone equipment throughout the 20th century, eventually being purchased by GTE, and in direct competition with the Bell empire (or Western Electric, Bell’s equipment division) throughout its existence. The community-written Wikipedia article tells more of the story.

Some details about this Monophone:

  • Manufactured from 1939 to the mid-fifties, but I can’t find a stamp on the inside or outside to date it.
  • The coiled handset cable would typically indicate a later model, but the nicked-up brass screws inside the handset where the cable is connected suggest that the coiled cable was an upgrade or repair at some point in this phone’s lifetime. So it may be an old phone body with a newer cable, or it may be a later model, all-original.
  • The dial plate seems to be uncommon. Browsing many pictures of AE model 40s on the web, I haven’t seen any others with white-numbered, black dial plates. Also, it has no alphabet markings, only digits.
  • It’s all Bakelite, and heavy. The Northern Electric 302, with a thermoplastic shell, is almost a full pound lighter. External data: someone weighed their own collection of phones.

The Northern Electric 302 and the Automatic Electric Monophone 40 ready to duel:
ne320-ae40.jpgThe AE40 works fine and will be a new addition to the analog remix, but I decided to do one more search for VoIP analog telephony adapters (ATAs) that will accept rotary/pulse dialing. Recently, a commenter suggested UTStarcom adapters, but others report of an ATA that is still in service and accepts rotary dialing: the Grandstream HT-502/503. I have a 502 coming from an eBay auction and will report back on how it works out.

Asterisk 1.8.0 RC3 and Google Voice

New features in Asterisk 1.8 may drag me out of the comfortable stability that is version 1.4.

Release candidate 3 of version 1.8.0 was announced last week, and it includes an updated chan_gtalk module that enables communications with the Gmail web client and its protocol/codecs. It’s neither standard SIP nor XMPP-Jingle, which I hope is yet to come, but the updated module is the last link necessary to allow directly placing and receiving calls through Google Voice. From the Google Voice web interface, you can specify Gmail Chat as one of your phones to ring on an incoming call. And this comment from the Asterisk code repository shows how to make outbound Google Voice calls in one line from the dialplan.

What else? Secure RTP, SIP over TCP, IPv6 (yes, I run IPv6 at home) are a few that showed up through the development of 1.6.x and I hope are considered stable in the 1.8 release. If anyone is running the release candidate or development code please let me know about your experience in stability and usability of new features.

More Asterisk and XMPP (Jabber) integration

Last month I wrote about how to send an XMPP (Jabber) message with Caller*ID information to one or more users when a call comes in to your Asterisk server. This is a simple, one-way notification and is easy to set up. What if we want to interact more fully with the Asterisk server over XMPP?

Please note that I am referring to administrative interaction, not call-level interaction. Asterisk 1.6 adds a JabberReceive command to the dial plan, which would allow some interactive instant messaging within the context of a call.

It turns out that the Asterisk Manager Interface (AMI) posts an event for every XMPP packet–both outgoing and incoming–so writing a Manager application to interface with XMPP is a good way to go.

Writing a daemon in Perl to listen on the Manager interface for XMPP messages, and then interact with Asterisk through the Manager, ends up being pretty straightforward, especially with the Asterisk::AMI module available on CPAN.

Here’s the general flow:

  1. Set up the AMI connection, with Events => ‘on’ so that we get events. The user this script logs in as must be in manager.conf and have permission to receive events and perform any actions you want to be able to perform (originate calls, write to the database, etc.).

  2. Read in a list of buddies from Asterisk’s jabber.conf from whom Asterisk should accept commands.

  3. Set up a simple event loop that filters out just the Jabber events. Mine looks like this:

    while (my $event = $ami->get_event) {
    if ($event->{'Event'} == 'JabberEvent' && defined($event->{'Packet'} )) {
    validateMessage($event->{'Packet'});
    }
    }

  4. Validate the XMPP message. Make sure it came from a valid buddy (step 2) and contains a command.

  5. Process the command, initiating any actions and sending results back to the XMPP buddy. So far in my script I’ve implemented a “call” command, where you can instruct Asterisk to originate a call to a certain number from an extension (or use the ring-all group as the default extension); a “dnc” command, that adds a number to the FreePBX blacklist (telemarketers), and help text.

How does it work? It’s simple–just add the Asterisk XMPP user (the one that sends you the call pop-ups from the previous posting) to your buddy list, and IM it your commands.

What’s left? I’d like to add some more useful interactive features.

  • When a call comes in and I get the Caller*ID pop-up, typing “cell” in the pop-up window will let me redirect the call to my cell phone. Or “vm” for voicemail or “zap” for Zapateller.
  • Missed/placed/received calls lists by pulling records from the CDR database.
  • Channel status, tech (sip/iax2) status, other statuses.

When is enough enough?

You could implement the entire Manager command set in this way, even implementing a very clunky attendant console or ACD supervision tool. That could be a bit much, but I see this being useful as a tool for common call-control tasks and simple administration tasks that would otherwise have to be performed at the command line (requires you to have an SSH session open to the server) or web interface.

If anyone’s interested in the Perl code in its current form, let me know.

VoIP providers for home use: 2010 update

Near the beginning of 2008, I published VoIP providers for home use, where I listed my favorite telephony service providers, some of which I have now abandoned because they no longer exist, are no longer cheap, or something better came along. Here are my current choices.

CallCentric – Last time, I said I was just starting to use CallCentric‘s services. As of this month, I’m just ending more than two years with them. I had a DID and used them for some incoming calls and redundant 911 service. I have no complaints; I’m canceling because I no longer need the services. CallCentric is pretty slick and has excellent technical support, fairly low rates for DID (but 2c/min. for outbound domestic calls, which is about double what many others offer), a nice incoming FAX option, super reliability and excellent sound quality. From my location, they often had the lowest latency of any provider I was using. Pay with credit card or PayPal. Oh, and here’s a neat trick: I found that CallCentric DIDs don’t seem to obey the privacy bit on incoming calls. So if someone sets the privacy bit to block their caller ID, you still get it. Probably a misconfiguration, but it could be helpful if you want or need that.

CallWithUs – My current favorite termination provider, to anywhere. I first looked into CallWithUs as a cheap provider for international calling and found that their domestic rates are excellent, too. Their web site speaks of their “keep it simple, stupid” business philosophy and I find that to be another great reason to work with them. Pay with credit card or PayPal, prepaid only. They also offer PBX hosting and VPN connections for low costs, neither of which I have used but would definitely try if I needed one of those services.

Sipgate – Sipgate’s One service offers a free DID in California with unlimited inbound. Front-end that with a Google Voice DID in your area and now you’ve got a free local DID on its own trunk for use however you like. Sipgate has one of the coolest web dashboards I have seen, FAX services (inbound free), and the ability to register multiple devices to their service, which could be useful. I haven’t used any of their paid services yet. My connection to Sipgate has roughly 120 ms latency but little if any jitter, so the quality is fine.

Gizmo5 – I’m still using the Gizmo5 connection with a Google Voice number routing over it, but you can’t sign up for a Gizmo5 account anymore, and web speculators think it’ll be rolled into a Google Voice+SIP offering at some point.

And there’s more…

Google Voice isn’t really a provider but has already received a few mentions above. I’ll have a post dedicated to GV soon. Stay tuned also for a post on XLink, which has been a valuable part of my home VoIP setup for a couple years now.

XMPP (Jabber) caller ID popups with Asterisk & FreePBX

Asterisk has had a Jabber module for a few years, officially supported since 1.4. The module enables two dialplan functions: JabberStatus, to get presence information, and JabberSend, to send a message. There’s more XMPP/Jabber functionality in Asterisk 1.6, but I’ve been sticking with the long-term support release at this point.

The two Jabber functions would be really useful in a call center where agents have some desktop with XMPP services. The presence function (JabberStatus) can be used in call routing logic, for example, and the JabberSend can be used for screen pops of caller information, perhaps bundled with external data from a CRM package.

Anyway, I wanted to implement caller ID popups on my home system that would IM that info to my wife and me when a call comes in. (She is a willing participant in my nerdy experiments.) Given the above two dialplan functions, the procedure is straightforward:

    1. Execute during the incoming call context
    2. See if buddies are online (and available)
    3. Send an IM to each available buddy with a message that includes the CALLERID variable

Since I am running FreePBX, I wanted to do it the FreePBX way, which means not to mess around with the [from-trunk] (incoming) context directly. Unfortunately there is no direct configuration of the XMPP module from within FreePBX so I have a 15%-FreePBX, 85%-config-files solution.

  1. Make sure the res_jabber.so module is loading. Review /etc/asterisk/modules.conf and verify either autoload=yes with no noload => res_jabber.so, or that without autoload, you are issuing a load => res_jabber.so.

  2. Configure an XMPP account (Gmail, Google Apps, jabber.org, local XMPP server, whatever you like) and set up the details in /etc/asterisk/jabber.conf. The config file is well-documented so I won’t go through it step by step. If you don’t have it, there’s a sample jabber.conf in the Asterisk source tar and a bit of info on the voip-info wiki. Be sure to add the buddies you want to be able to IM with buddy= lines.

  3. Restart Asterisk and use jabber show connected from the CLI to see that your user is now logged in. Review log files and fix until it successfully connects.

  4. Edit /etc/asterisk/extensions_custom.conf and start a new extension under the [from-internal-custom] context. This is going to be a bogus extension number that just issues the Jabber commands and ends. The idea is that it will later be a member of a default incoming calls ring group. I used extension 1099 as it fits in my dialplan and doesn’t interfere with anything else:

    [from-internal-custom]
    ...
    exten => 1099,1,JabberStatus(label,someuser@jabber.org,SOMEUSERSTATUS)
    exten => 1099,n,NoOp(Value of SOMEUSERSTATUS is ${SOMEUSERSTATUS})
    exten => 1099,n,JabberStatus(label,otheruser@jabber.org,OTHERUSERSTATUS)
    exten => 1099,n,NoOp(Value of OTHERUSERSTATUS is ${OTHERUSERSTATUS})
    exten => 1099,n,Execif($[${SOMEUSERSTATUS} < 6],JabberSend,label,someuser@jabber.org,Incoming call from ${CALLERID(all)})
    exten => 1099,n,Execif($[${OTHERUSERSTATUS} < 3],JabberSend,label,otheruser@jabber.org,Incoming call from ${CALLERID(all)})

    Replace label with the [label] set up in jabber.conf for your XMPP connection. Replace someuser@jabber.org with the user ID of a buddy you defined in jabber.conf, and the variable name SOMEUSERSTATUS with whatever you like. The ExecIf statement which checks SOMEUSERSTATUS < 6 sends a message to the buddy if he/she is online. You could use < 3 to IM the buddy only if he/she is in the Available or Chatty state. Do the same for any other users you want to IM on an incoming call.

  5. Reload the dialplan at the CLI with extensions reload and then pick up an extension and dial 1099 or whatever you set up, above. This will trigger the Jabber commands and if you are online, you should get a popup stating that there’s an incoming call from your extension. Experiment and tweak to your liking.

  6. Now to integrate this into FreePBX, we’re going to add 1099 to the list of extensions rung on an incoming call. On my system I ring all extensions when an external call comes in. So to ring all extensions and trigger the Jabber functions as well, I just added 1099# (must include the #) to the bottom of the Extension List on my default ring group.

  7. If you want, you can also add your new custom extension number to the Custom Extensions module in FreePBX, just for tracking purposes.

If you’ve got a more complicated setup with different ring groups per DID or something else, it’s easy to repeat the steps and make additional custom extensions that IM different people or send different messages, then integrate these custom extensions into your FreePBX ring groups. At this point you should be able to apply the config in FreePBX and then wait for an incoming call. As your phones begin to ring, you’ll get an IM if you’re online.

New phone guy meets Old Phone Guy

At a flea market earlier in the year, my mother picked up a Northern Electric (Western Electric’s Canadian counterpart) 302 telephone, manufactured in August 1948, for $20. She gave it to me during a recent visit and I set out to make it work on my home Asterisk setup.

The short of it is, it’s functional. I needed to replace the line and handset cords and give the thing a thorough cleaning, but it works. That is to say, it gets a dial tone from my analog telephone adapter and I can answer calls on it. The ringer is extremely weak as I think my ATA only supports about 2, maybe 2.5 REN and the 302 probably needs about that much current to ring the bells. I had thought that a 302 would be 1 REN but maybe this wasn’t standardized until the 500 set.

What to do about the rotary dial? I’ll buy a pulse-to-tone converter or wire up an inline keypad if I want to get creative–or find a Digium IAXy ATA, now discontinued–but until then, I have a workaround. Some time ago, a friend gave me an old Sharp organizer, the kind that stores a couple hundred names and phone numbers and plays touch tones into your handset for “speed dialing.” He found it in a drawer and gave it to me as a joke. Switch it to manual mode and I now have a dialer for my antique phone.

There are lots of resources on the web for people who want to fix up antique phones. I’m not an antiques person but I’m having fun with this little project and will keep my eyes open for more analog goodness in the future. Oldphoneguy is a great resource for restoring and wiring up old phones to work on modern lines. And Bell System Memorial, which I mentioned in an earlier blog post, has some great historical information.

VoIP providers for home use

Just wanted to mention a few VoIP providers that I use on my home Asterisk system.

  • VoiceStick / i2telecom – Using their Next2Nothing plan (pay-as-you-go) I have a DID number local to my parents. They dial a local number and I pay 1.2 cents per minute plus a couple dollars a month for “911 recovery fee” (for an incoming-only phone number!). Audio quality has been excellent. If it weren’t, my family members would surely tell me so.
  • FWD – every homebrew VoIP system should connect with FWD. Why? Well, because it’s free! I am connecting using both SIP and IAX2. I use it only to connect to toll-free numbers and to test connectivity using some of its test numbers.
  • Gizmo Project – here’s a clever way to get a free DID number thanks to Gizmo Project and Google’s Grand Central. Sign up for a free Gizmo account, set it up in Asterisk and make sure it works. Then sign up for Grand Central. (Need an account? Leave a comment and I’ll send you an invitation.) You can point your Grand Central number to your Gizmo account. Result: People call your Grand Central number (a regular phone number) and your VoIP system receives it.

    Cool, until you decide it’s annoying to respond to Grand Central’s “Press 1 to accept the call…” menu every time your phone rings. Instead, make Asterisk “press 1” for you when a call comes in and before delivering the call to your phone.

    Put a custom context in Gizmo’s peer definition, like this:

    context=custom-gizmo-in

    Then create that custom context in extensions_custom.conf (for FreePBX) or directly in extensions.conf if you’re hand-editing plain Asterisk:

    [custom-gizmo-in] exten => s,1,Answer exten => s,2,Wait(1) exten => s,3,SendDTMF(1) exten => s,4,Goto(from-pstn,s,1)

    (The goto in step 4 sends the call to the generic “incoming” context after the DTMF “1”; modify as necessary.)

  • ??? – I use a cheap termination service (outbound calling) whose terms of service state that “All customers … are specifically prohibited from disclosing to others that they use [the provider’s] service.” I leave it as a mystery for the reader. (However, I’m pretty sure I heard of this provider by word-of-mouth — contract-breacher!)
  • CallCentric – This one is on my radar. I am signed up for their free service and a single “Cheap DID” to test things out. So far I have been very impressed with their customer service (answering a non-trouble question ticket within two hours), the sound quality, pricing, and availability of DID numbers. It seems like they offer DIDs everywhere and can port (LNP) just about any number. I may port my listed home phone number (currently not connected to my VoIP setup) to this carrier.

No mention of the big guys: Vonage, Packet8, or AT&T or Verizon’s VoIP service, for three reasons. One, most don’t allow you to connect to them using a PBX (Asterisk). Two, they’re expensive. And three, if you’re home-brewing VoIP, you are probably a geek or trying to “stick it to the man.” I realize that some of the carriers that look like “little guys” really have big guys behind them, but many of them don’t. They’re just trying to make a little money reselling service from wholesale carriers and adding their own little features to make telephony a little cooler or more fun.

PBX in a flash?

I don’t have any updates at the moment on using Smokeping to monitor the quality of the VoIP network (though I am in the middle of debugging and setting it up, and it looks like it will work very well) but hope to have some graphs to show, soon.

In the meantime there has been some rustling in the VoIP blogs about a new “Asterisk-distribution-on-a-CD” called PBX In A Flash. Ward Mundy of the Nerd Vittles blog (linked on the sidebar of my site) is the man behind this distro, and it looks good. A long-time Asterisk@Home and then Trixbox user, he got tired of the limitations of the Trixbox distribution and decided to produce his own. I’ve downloaded it and plan to evaluate it. I think it will be decent because I like the various Asterisk hacks that have come from Nerd Vittles and I have the feeling this distro will be full of clever configurations and nice feature additions.

At home, I run a well-customized Trixbox, connected to the world with some cheap SIP trunking and connected to me via an analog adapter with cordless phones and softphones. To be honest, there’s no “in a flash” about it — setting up Asterisk, even with nice GUIs and self-installing CDs, is time consuming and requires a lot of research. But it’s rewarding to be able to set up a fairly powerful home PBX using free software, cheap hardware, and cheap connectivity, and have more for $10 or so a month than you could get from the phone company for $40 a month.