CAPI Channel

Support of CAPI 2.0 based ISDN Boards and ISDN Routers (w/RCAPI).

Credits:

Copyright (C) 2005-2006 Cytronics & Melware Armin Schindler
Reworked, but based on the work of Copyright (C) 2002-2005 Junghanns.NET GmbH
Klaus-Peter Junghanns
Reworked for AsteriskWin32 by Patrick DERUEL
Added Remote CAPI devices support (hacked by myself).

Features:
Version: 1.0.0

Dialing parameters

Dial(CAPI/g<group>/[<callerid>:]<destination>[/<params>])
Dial(CAPI/contr<controller>/[<callerid>:]<destination>[/<params>])
Dial(CAPI/<interface-name>/[<callerid>:]<destination>[/<params>])

'group' can be a value, comma separated list of values or a range using '-'.
The according interface is found by searching a match with the 'group' specified in the capi.conf for each interface.

The optional 'callerid' followed by an ':' can be used to set a callerid for this dial() command, without changing the original channel's callerid.

'params' is an optional part to set special settings for this call.
The string consists of a list of characters with the following meaning:
    'b' : early B3 always.
    'B' : early B3 on successful calls only.
    'd' : use the default caller id which is set by defaultcid= in capi.conf
    'o' : use overlap sending of number.
(Useful if additional digits shall be send afterwards or together with 'b' to get dialtone and then send the number, e.g. if otherwise no progress tones are available)

CAPI Commands applications

chan_capi provides an additional Asterisk application:
capicommand()
With this application, special capi commands and features can be used.

Using CLIR

CLIP/CLIR uses the calling presentation of the calling channel, which can be modified using the CallingPres() application. The CallerID is also taken from the calling channel.

Use the SetCallerPres() application before you dial:
       exten => _X.,1,SetCallerPres(prohib_not_screened)
       exten => _X.,2,Dial(CAPI/contr1/${EXTEN})

Early B3 connect (inband call progress, tones and announcements)

Early B3 is configurable in the dialstring parameters. If you set a 'b', early B3 will always be used, also if the call fails, because the number is unprovisioned, etc ...
If you set a 'B', early B3 will only be used on successful calls, giving you ring indication,etc...

Don't use indications in the Dial command, your local exchange will do that for you:

      exten => _X.,1,Dial(CAPI/contr1/${EXTEN}/B,30))              (early B3 on success)
       exten => _X.,1,Dial(CAPI/contr1/${EXTEN}/b,30))              (always early B3)
       exten => _X.,1,Dial(CAPI/contr1/${EXTEN},30,r))               (no early B3, fake ring indication)

       exten => _X.,1,Dial(CAPI/contr1/${EXTEN}/b,30,r)             (always early B3, fake indicatons if the exchange does not give us indications)
       exten => _X.,1,Dial(CAPI/contr1/${EXTEN}/B,30,r)              (early B3 on success, fake indicatons if the exchange does not give us indications)

For normal PBX use you would use the "b" option, always early B3.

Overlap sending (a.k.a. real dialtone)

When you dial an empty number, and have early B3 enabled, with:
       Dial(CAPI/g1/b)
The channel will come up at once and give you the dialtone it gets from the local exchange.
At this point the channel is like a legacy phone, now you can send DTMF digits to dial.

Example context for incoming calls on MSN 12345678:

[capi-in]
exten => 12345678,1,Dial(SIP/phone1)
exten => 12345678,2,Hangup

HOWTO of capicommand(receivefax...) and capicommand(sendfax...):

For those of you who have a CAPI card with an on-board DSP (like some Eicon and DIVA Server), this allows you to receive/send faxes.

capicommand(receivefax|<filename>[|<stationid>|<headline>]):
If you want to answer a channel in fax mode, use capicommand(receivefax|...) instead of Answer()
If you use Answer(), you will be in voice mode. If the hardware DSP detects fax tone, you can switch from voice to fax mode by calling capicommand(receivefax|...).
The parameter <filename> is mandatory and the parameters <stationid> and <headline> are optional.
To enable fax tone detection and redirect to extension 'fax', use config variable 'faxdetect' in capi.conf.

Example of use :
       line number 123, play something, if a fax tone is detected, handle it
       line number 124, answer directly in fax mode
      [incoming]
       exten => 123,1,Answer()
       exten => 123,2,BackGround(jpop)
       exten => 124,1,Goto(handle_fax,s,1)
       exten => fax,1,Goto(handle_fax,s,1)
      [handle_fax]
       exten => s,1,capicommand(receivefax|/tmp/${UNIQUEID}[|<stationid>|<headline>])
       exten => s,2,Hangup()
       exten => h,1,deadagi,fax.php // Run sfftobmp and mail it.

The output of capicommand(receivefax|...) is a SFF file.
Use sfftobmp to convert it.
With a DIVA Server, following features are provided:
       - fax up to 33600
       - high resolution
       - Color Fax
       - JPEG Compression is disabled (not tested yet)

capicommand(sendfax|<filename>[|<stationid>|<headline>]):
To send a fax, you can use the same mechanism like with receivefax.
Just replace the <filename> with the path to the .SFF file to send.

After disconnect of a fax connection, the following variables will be set for that channel:
       FAXSTATUS : 0 = OK, 1 = Error.
       FAXREASON : Value of B3 disconnect reason.
       FAXREASONTEXT : Decoded text of FAXREASON value.
       FAXRATE : The baud rate of the fax connection.
       FAXRESOLUTION : 0 = standard, 1 = high.
       FAXFORMAT : 0 = SFF.
       FAXPAGES : Number of pages received.
       FAXID : The ID of the remote fax maschine.

Asterisk variables used/set by chan_capi:

BCHANNELINFO
      On incomming call, this variable is set with the B-channel information value:
      '0' : B-channel is used (default)
      '1' : D-channel is used (not implemented yet)
      '2' : neither B nor D channel is used (e.g. call waiting)
      Call-Waiting: an incoming call with BCHANNELINFO not '0' cannot be accepted.
      Another connection must be dropped before accepting or use
      capicommand(deflect|<number>) to initiate call deflection to another destination.

CALLEDTON
      The 'type of number' value of the called number is saved in this variable on incomming call.
_CALLERHOLDID
      If a call is put on hold (ISDN-HOLD), the reference id is saved in this variable.
      This variable is inherited as CALLERHOLDID to the dialed channel and will be used
      if e.g. capicommand(ect) is used to transfer the held call.

CALLINGSUBADDRESS
      If set on dial(), the calling subaddress will be set to the content.
CALLEDSUBADDRESS
      If set on dial(), the called subaddress will be set to the content.
CONNECTEDNUMBER
      Can be set before answering and if set, the content is used for IE 'Connected Number' on answering.
FAXEXTEN
      If chan_capi sends the call to extensions 'fax', the original extension number is saved in this variable.
PRI_CAUSE
      If set, this value will be used as hangup cause on hangup.
REDIRECTINGNUMBER
      On incoming call, if the call was redirected to you by someone, the number of the redirecting party is saved in this variable.
      RDNIS is set as well.

REDIRECTREASON
      If the incoming call was redirected to you, this variable is set with the reason value.



 

..