This was written for asterisk-11 compiled from source on ubuntu 12.04. In this example, I talk about faxing over SIP. This is not the ideal channel to receive faxes on because the failure rate can be high. But sometimes it can work, so if SIP is what you have (like me), it might be OK for testing with. Aside: we're talking about fax-to-email here. But if you're interested in receiving a faxes to a fax machine, you might be disappointed because this seems to be a deficiency of asterisk -- the hardware ecosystem available to asterisk does not seem capable of reliably supporting analog fax machines or modems. The goto solution is to attach an analog line direct to your fax/modem. Some manufacturers are working on this issue; Sangoma offers a sync cable to improve reliability when receiving a fax through a digital link that'll terminate to an analog station (on a different Sangoma card, of course). See: http://wiki.sangoma.com/t1e1analogfaxing. Does it work? hell if I know. Getting StartedTo receive a Fax in asterisk, we need to have a couple things. First, we need to have the RxFax application. To get this, we must have installed the libspandsp-dev package (in ubuntu) before configuring, making, then installing asterisk. Then when you configure asterisk, make sure the fax application is enabled. If you already have asterisk installed, but don't have this application, be sure to make uninstall and make clean before rebuilding and installing asterisk.If you're installing in a distribution downstream from RHEL (centos, clearos), chances are you'll need to download, ./configure, make && make install spandsp from source. Get it here: http://www.soft-switch.org/downloads/spandsp/. Next, in your sip.conf file (or the config file of whatever channel driver will be receiving faxes), we need to enable fax detection. This will enable asterisk to re-route inbound fax calls when it detects a fax tone. In your global section of sip.conf, add: faxdetect=yes. With this, when asterisk detects an incoming fax the call will be rerouted to the fax extension in the same context. Finally, in extensions.conf, in the context of your incoming calls, you need to have a couple things happen.
And that's the basics of fax receiving. Note that the ReceiveFax dialplan application used to be called RxFax. A tip to see what applications you have is to run the following command from the asterisk CLI: core show applications Convert the tiff file to pdfTo do this, we need the tiff2pdf application. In ubuntu, we can get is by running:
Then we just need to update our dialplan to make use of this utility. Let's replace our basic fax extension from above with the following:
easy, right! Yet again, asterisk is so awesome because it's so easy to extend the capabilities! Given that asterisk runs on linux, it has all the benefit of linux available to it. Send the PDF file somewhere through e-mailStart by installing a required toolkit
And change our fax extension by adding two lines just before the Hangup line. Very similar to the previous example; the new lines are in bold:
Handling errors -- a comprehensive example!If you don't respond to transmission errors, unexpected results can occur. Notably, asterisk might give up without cleaning up partial files, which can clutter your file system over time.
|