📜 ⬆️ ⬇️

Asterisk. Sending and receiving faxes

Hello. Today I want to write a note on how to set up sending / receiving faxes using the Asterisk software PBX (there are no physical faxes available). So.

Given:
1. There is an organization that deals with, say, sales (in fact, anything, because faxes are used a lot where). In this organization, there are users who sometimes / often send / receive faxes.
2. There is also Asterisk, with connected city lines (via SIP or via some kind of VOIP gateway - not important. The main thing is that these peers are registered in sip.conf).

Task:
Configure Asterisk so that each user can receive / send a fax by pressing a certain key combination on the phone.

Decision:
Everything described works on asterisk 1.8.27.0. Faxes sent by me are received without problems on faxes such as multifunction printers and on ordinary devices, such as those located in customs. Our PBX must be built / or the app_fax.so module installed. This module includes two commands SendFAX and ReceiveFAX, and we will use them.
')
Sip.conf file

[sipnet5] type = friend username = 004 secret =  allerid = "/sipnet.ru" host = 212.53.40.40 port = 5060 nat = yes fromuser =  fromdomain = sipnet.ru insecure=invite context = incoming_calls disallow = all ;allow = g729 ;allow = ulaw allow = alaw allow = gsm allow = g723 allow = g723.1 

As you can see this is a piece of my sip.conf file. Here is a feast that is registered on sipnet.ru. From him and him, I / I will call and I will send / receive faxes.
allow = alaw - preferred codec. It is alaw, because it is a native fax codec (will work both on fax machines in the form of multifunction printers and on iron hardware).

You also need to register in the sip.conf service number for example "5555". We will transfer a call to this number to receive a fax. This is done in order to explicitly specify a set of used codecs (here one codec is alaw).

 [5555] type = friend host = 192.168.4.1 port = 5060 username = 5555 secret =  qualify = yes videosupport = yes nat = yes context = office-1 host = dynamic insecure=port,invite dtmfmode = rfc2833 disallow = all allow = alaw call-limit = 0 callgroup = 1 pickupgroup = 1 

Further. We want the sending / receiving of a fax to occur when you press a certain key combination. Let it be a combination of * 3 for sending and * 4 for receiving a fax.

To do this, add the following to the features.conf file in the [applicationmap] section:

 [applicationmap] fax_rec => *4,callee,Goto(office-1,5555,1) fax_send => *3,callee,Macro(fax) 

As you can see, when you press * 3, the fax macro is launched, and when you press * 4, you are transferred to the office-1 context, extension 5555.

File extensions.conf:

 exten => _92XXXXXX,1,Set(DYNAMIC_FEATURES=fax_rec#fax_send) exten => _92XXXXXX,n,dial(sip/sipnet5/8863${EXTEN:1},,wWtT) 

Here we set the value of the variable DYNAMIC_FEATURES = fax_rec # fax_send.
fax_rec # fax_send - an enumeration of those “programs” and combinations that can be launched from this number, let's say. If the value of the variable is not set, then the PBX will not respond to combinations * 3 and * 4, at all.
Next comes the dialing pattern for Rostov-on-Don. 92932214 (the number is taken from the bald).

The sending algorithm is as follows:
0. The user converts a text file / document (in any way) into PDF format and copies it into the / var / spool / asterisk / fax folder.
1. The user dials the number 92932214.
2. ATS calls 88632932214 - Rostov-on-Don.
3. They pick up the phone, we say "take the fax", we are answered "start"
4. We wait while in the handset crackling and press * 3.

Now the fax send macro itself:

 [macro-fax] exten => s,1,answer() exten => s,n,NoOp(************** SENDING FAX... *****************) exten => s,n,System(/usr/bin/gs -dSAFER -dBATCH -dQUIET -sDEVICE=tiffg3 -sPAPERSIZE=a4 -r204x196 -dNOPAUSE -sOutputFile=/var/spool/asterisk/fax/fax.tiff /var/spool/asterisk/fax/fax.pdf) exten => s,n,Set(LOCALSTATIONID=+78632204352) exten => s,n,Set(LOCALHEADERINFO="OOO Roga i Kopita") exten => s,n,SendFAX(/var/spool/asterisk/fax/fax.tiff) exten => s,n,Hangup() 

With the help of / usr / bin / gs we convert PDF file to TIFF (format for sending faxes). LOCALSTATIONID - variable, where we set the number from which we send the fax.
LOCALHEADERINFO - specify the name of the organization. You can read more about these variables in the Asterisk documentation.
All settings are simple. They can be complicated by your wish.

Then we actually send the fax and after sending we hang up.

Receive a fax. This is a fragment of the file, where actions for incoming calls to our sip number are specified (incoming_calls context).

 exten => 0042081926,1,Set(DYNAMIC_FEATURES=fax_rec) 

The value of the variable DYNAMIC_FEATURES must be set.

1. We are called (our number is, say, 2204352, it is also registered in sip.conf as sipnet5).
2. We pick up the phone, talk, then we are told “take the fax”, we say “I will start”.
3. Click * 4.
4. The transition to extension 5555 to the first position.

A piece of file extensions.conf

 exten => 5555,1,answer() exten => 5555,n,Set(DYNAMIC_FEATURES=fax_rec) exten => 5555,n,receivefax(/var/spool/asterisk/fax/sss.tif) exten => 5555,n,System(/usr/bin/tiff2pdf /var/spool/asterisk/fax/sss.tif -o /var/spool/asterisk/fax/sss.pdf) exten => 5555,n,System(rm -f /var/spool/asterisk/fax/sss.tif) exten => 5555,n,hangup() 

1. We answer
2. receive fax
3. convert from tiff to pdf.
4. remove tiff

Look like that's it. If you forgot to write something or something is incomprehensible, I get rid of it beforehand. If this material was helpful very happy.

Source: https://habr.com/ru/post/245271/


All Articles