How to Asterisk PBX with ISDN and FritzCard PCI on Linux

How to Asterisk PBX with ISDN and FritzCard PCI on Linux

This article shows how you can use Asterisk PBX with ISDN and FritzCard PCI on Linux Ubuntu Server / OpenSuse on a Easybox 904-S0 / Y-Cable. Have fun!

Setup FritzCard ISDN driver

Opensuse leap 15.2

# Setup repository lp152-19 oldkernel!

# Add 15.2 Leap Repository if not present:
zypper clean -a
zypper ar -f -c http://download.opensuse.org/distribution/leap/15.2/repo/oss/ OLDKERNEL-FRITZ-ISDN-15.2

## Install Kernel / Initram and reboot system:
# Search kernel .*lp152.19.2
# zypper se -su -r $ISDN_REPO  'kernel-def*' | grep -i lp152.19.2

# Add oldkernel to /etc/zypp/zypp.conf for preventing purge next time!
# multiversion.kernels = latest,oldest,running

# Install 
zypper install --oldpackage kernel-default-5.3.18-lp152.19.2

## FCPCI driver install
# Import rpm key
rpm --import https://fkn-systems.de/_repos/FKN-Repo_-_fcpci_opensuse_leap.15.2/repodata/repomd.xml.key

# If some armored erros:
# wget http://www.fkn-systems.de/_repos/FKN-Repo_-_fcpci/repodata/repomd.xml.key -O - | sed -e '$a\' > repomd.xml.key
# rpm --import repomd.xml.key
# rpm --query --all "gpg-pubkey*"

# Remove old repositories
zypper lr -u && zypper rr FKN-Systems_-_Repo_-_fcpci*

# Add FKNS Repository:
REPO='FKN-Repo_-_fcpci_opensuse_leap.15.2'
zypper ar -f -c http://www.fkn-systems.de/_repos/${REPO}/ Fritzcard_Repo 

# Get some info an cleanup
zypper clean -a && zypper ref

# Install (Reinstall: - reinstall) fcpci driver
zypper in fcpci

# Install ISDN Tools (capiutils - i4l (isdn)) (Optional ant-phone minicom)
zypper in capisuite capi4linux libcapi20-3 i4l-base i4l-isdnlog

## Setup driver blacklist / udev
cat << EOF >>/etc/udev/rules.d/46-FKN_isdn_capi.rules
# Symlink (capi20 -> capi) zu
# Kompatibilitaetszwecken erstellen
KERNEL=="capi", SYMLINK="capi20"
EOF

cat << EOF >>/etc/modprobe.d/50-blacklist.conf
#blacklist fcpci
blacklist avmfritz
blacklist mISDNipac
EOF

# Reload force udev rules
udevadm control --reload-rules && udevadm trigger

# Get Capitools start info (See some B Channels there?)
capiinit start && capiinfo

# check
# uname -srvpio ; rpm -qa | grep fcpci ; sha1sum -b /lib/modules/*-desktop/kernel/extras/fcpci.ko ; lsmod | grep -i capi ; lspci | grep -i avm
RPM.key Optional fix
cat << EOF > isdn.key
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.0 (GNU/Linux)

mQGiBD0CGoURBACbPeVey+bTyTTmic5fThXbqCqU/fUa3fpElcxdRoXsXq+wTGZP
JbOMY+G1IFXo904UqmrVdl/ClMcfNsGRUjQ8PrcPqFJ3KG7g1dMjJJel0Uu7Jkng
b+cHMJia/Zbda/CZun3kC9QfJdm44/rX8g0ld4ikjIn8vRvGhSqlYPoEOwCgxpRO
4sFQQCBQMV0tCOWTu05XojsD/RVgBq1921d+Peu/1ANCrq4wHxt5WwTtt9LJi9Hq
TSQtnQnbIK7Jd0uqBsG8taz5M4lDQrfXTJDJXOIftRBSf8aib3MuHX/pwC8mtx4k
AAb8mrf7MFHi9Bw2hI4cA4s8sRLReMjjvcADsnrndq0GFPM8cnSQxChm0cNXZGlH
FfxVA/9ZEgq2eWeI+RggJkodHLaNnLd2KscEv4ikvmvjdEYoWyeQQ0Ldmd3Zj8I6
wlX6jnRmz/pbeVeoKkHEhQhyQWSQdh5QEBg4RQVN63pgHt75CpGx3M0FBLA5VbMt
RY7QDAdfAJuqJWhIKg9YRLoub+d1uxRMNm72xX89LL1E7/B+j7QwRnJhbmsgTmFn
ZWwgKDIwMDItMDYtMDgpIDxmbmFnZWxAZmtuLXN5c3RlbXMuZGU+iFwEExECABwE
CwcDAgMVAgMDFgIBAh4BAheAAhkBBQI9AhqGAAoJEC64JlGaPPcln2IAn3hmeriR
dNaX3CSL0gW5l0sDaRVQAJ9k1qEXW66bojgtl9bQp/pe6UWWQIhGBBMRAgAGBQI9
OUKXAAoJ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JFOthy
iDEw62/gH3c8k1x2yLprt3ZX4csrWB39CWbs839FkWyoVq8qkYhGBBgRAgAGBQI9
AhrhAAoJEC64JlGaPPclYI4An2lwxslQzB5l8S4XWL5zdR9+87gBAJ9aqPza1pbQ
ht63Bavm7nrQi5cWjbkBCwQ9AiS+AQgAvn1MIS55yTAw7A3Ac2ApkqHn6Z/AZgRz
adKUcDy3bAfk7z6eQ7n5GFNW//ATVuYliPi1W+us6h1G039KtgaMGYYk/cWAGWrL
GXa0scncQT7qyd5VqiCzRCo3L0V6C0NN0urfLdx8PAeDa9yr+/hvPszlMDE3uCWG
1xay86skyBlGXTBkCxT4zfhxOJUNFhUqqbPYP96Xw6d5FcJwJ68jn8158CsryWa7
3Ino1lOzmq04cfbTMLqmjZ74r7WYDbGqjMtKo7sR5A3GtrFqnNt00UaEgkSCfVZ6
IXbQHHLGMpPfiEhghej8fZAFV9k+Bewo4wTTPybsg5xe1Y4hdPYu9QAGKYhJBBgR
AgAJBQI9AiS+AhsMAAoJEC64JlGaPPclkKMAnivIL0c1ZUrRLqbN9ViUKKwcrMtE
AJwI7mtkVGV0xoE5w3NjuLmat++MDA==
=cqHb
-----END PGP PUBLIC KEY BLOCK-----
EOF

rpm --import isdn.key

Extra stuff: Loading ant-phone / ISDN Pipe issus

# AT ISDN errors create-devices
mknod /dev/ippp0 c 45 128
mknod /dev/isdnctrl0 c 45 64
mknod /dev/isdn0 c 45 0
mknod /dev/isdninfo c 45 255

#
# Loading GTK ant-phone with sudo user
su - <normaluser> or exit
xhost +local:root
sudo su
export DISPLAY=:0.0

Ubuntu Server 14.04 LTS

## Install tools and driver
# Copy the following line and paste it into a terminal.
# URL: https://belug.de/~lutz/pub/fcpci/

wget -O install.sh https://belug.de/~lutz/pub/fcpci/install3100.sh ; chmod +x install.sh ; sudo ./install.sh 

modprobe -rf fcpci
modprobe -rf avmfritz
modprobe -v fcpci

## setup driver blacklist / udev
echo "blacklist avmfritz" > /etc/modprobe.d/blacklist-avmfritz.conf

sed 's/#fcpci/fcpci/g' -i /etc/isdn/capi.conf

cat << EOF >> /etc/modules:
# Fritz!Card
capidrv
capi
fcpci
EOF

## Install additional software
apt update && apt install capiutils ant-phone isdnutils-base isdnlog

capiinit start && capiinfo

First test with capifax

capifax -c <MSN> <PHONENUMBER> <(echo "hello world")

Setup Asterisk with chan-capi module

Install asterisk software

# Setup asterisk on system -> example 15.3 repo asterisk 13

zypper ar -f -c https://download.opensuse.org/repositories/home:/vicidial:/asterisk-13/openSUSE_Leap_15.3/ Asterisk_13_repo

zypper install asterisk

Install and compile chan-capi module

# Setup asterisk on system

# FritzBox Capi-over-TCP actvation with: #96*3*

# Compile
# apt install patch asterisk13-devel build-essentials
zypper install patch asterisk13-devel build-essentials

git clone https://github.com/MelwareDE/chan-capi ; cd chan-capi
# 64bit os :: MODULES_DIR=$(INSTALL_PREFIX)/usr/lib64/asterisk/modules

./create_config.sh /usr/include/
make -j2
make install
make install_config

# Set on modules.conf 
echo "load => chan_capi.so" >> /etc/asterisk/modules.conf

# On /etc/asterisk/capi.conf set:
[isdn-in]
include => from-pstn
Capi-OVER-TCP: https://web.archive.org/web/20171121071016/https://www.wehavemorefun.de/fritzbox/CAPI-over-TCP

Start asterisk / Create desktop shortcut

asterisk -vvvvvvvc

# detached by service
systemctl restart asterisk && asterisk -vvvvvvvr

## Adding desktop icon shortcut:

cat << EOF > /home/user/asteriskstart.desktop
[Desktop Entry]
Comment[de_DE]=
Comment=
Exec=konsole -e "/home/user/start_asterisk_pbx.sh"
GenericName[de_DE]=
GenericName=
Icon=plasma-mobile-phone
MimeType=
Name[de_DE]=Start PBX
Name=Start-Asterisk_pbx
Path=/home/user/SCRIPTS/
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=
EOF

start_asterisk_pbx.sh

#!/bin/bash

echo "Starting Asterisk"
echo
sleep 3
echo "-- ADDING FCPCI module"
sudo modprobe -v fcpci

sleep 2
systemctl stop SuSEfirewall2
#systemctl restart asterisk.service

echo
echo "and go asterisk remote to service -- else -r"
echo
echo "---------------------------------------------"
echo
sleep 2

sudo asterisk -vvvvvvvc

#exit 0

Asterisk configure Files

asterisk.conf

# hs

modules.conf

[modules]
autoload=yes
noload => pbx_gtkconsole.so
load => res_musiconhold.so
noload => chan_alsa.so
noload => chan_console.so

noload => res_hep.so
noload => res_hep_pjsip.so
noload => res_hep_rtcp.so

capi.conf

[general]
nationalprefix = 0
internationalprefix = 49
txgain = 1.0
rxgain = 1.0
use_smoother = yes
max_bchans=2

language=de      ;set default language

[rcapi]


[ISDN1]          ;this example interface gets name 'ISDN1' and may be any
                 ;name not starting with 'g' or 'contr'.
ntmode=no      ;if isdn card operates in nt mode, set this to yes
isdnmode=msn     ;'MSN' (point-to-multipoint) or 'DID' (direct inward dial)
                 ;when using NT-mode, 'DID' should be set in any case
incomingmsn=*
defaultcid=*  ;set a default caller id to that interface for dial-out,
                 ;this caller id will be used when dial option 'd' is set.
controller=1     ;capi controller number to use
group=1          ;dialout group
softdtmf=on      ;enable/disable software dtmf detection, recommended for AVM cards
relaxdtmf=on     ;in addition to softdtmf, you can use relaxed dtmf detection
accountcode=     ;Asterisk accountcode to use in CDRs
context=capiisdnin  ;context for incoming calls
                 ;set to 'local' (default value), no hold is done and Asterisk may
                 ;play MOH.
immediate=yes   ;DID: immediate start of pbx with extension 's' if no digits were
                 ;     received on incoming call (no destination number yet)
                 ;MSN: start pbx on CONNECT_IND and don't wait for SETUP/SENDING-COMPLETE.
                 ;     info like REDIRECTINGNUMBER may be lost, but this is necessary for
                 ;     drivers/pbx/telco which does not send SETUP or SENDING-COMPLETE.
                 ;(possible values: 'no', 'yes', 'force', 'g164', 'g165')
echocancelold=yes;use facility selector 6 instead of correct 8 (necessary for older eicon drivers)
bridge=no      ;native bridging (CAPI line interconnect) if available
devices=2        ;number of concurrent calls on this controller
                 ;(2 makes sense for single BRI, 30 for PRI)

sip.conf

[general]
port=5566                                                                                                       ; Port des SIP-Servers
bindport=5566
bindaddr=0.0.0.0                                                                                                ; Bei Multihost (Host hat mehrere IP-Adressen) angeben
;externip=123.123.123.123                                                                                       ; Externe IP-Adresse (für NAT)
localnet=192.16.0.0                                                                                           ; lookupskales Subnetz (wichtig bei NAT)
localmask=255.255.255.0

context=main                                                                                                            ; Eingehende Anrufe kommen in den Kontext [main]

disallow=all                                                                                                    ; Erst alle Codecs ausschlissen, dann
;allow=all
allow=ulaw                                                                                                      ; Codecs in der folgenden Reihenfolge erlauben
allow=alaw                                                                                                      ; ulaw (G.711 für USA), alaw (G.711 für Europa)
allow=gsm
allow=g723
allow=g726
allow=speex

;srvlookup=yes                                                                                                  ; Enable DNS SRV lookups on outbound calls
;canreinvite=no                                                                                                         ; Stellt HW-Kompatibilität sicher
vmexten=60                                                                                                      ; voicemail stuff:
language=de                                                                                                     ; vm...
qualify=yes                                                                                                                             ; Sends ping of life every X secs or on or off
alwaysauthreject=yes                                                                                                    ; Some username reject security
prematuremedia=no
progressinband=yes

; register => asterisk:pass@172.2.2.2/asterisk
;register => asterisk:pass@172.2.2.2/626

;[626]
[asterisk]
type=friend                                                                                                     
context=in-outbound-call
defaultuser=asterisk
fromuser=asterisk
fromdomain=172.2.2.2
secret=pass                                                                   
host=172.2.2.2                                                                                              ; Der Vertrieb ist mobil und wechselt eventuell die IP-Adresse
insecure=invite
;insecure=very
;nat=force_rport,comedia
;nat=no

;[ISDN CAPI]
[MSN_MAIN_NUMBER]
type=friend                                                                                                     ; friend user peer
context=in-outbound-call
defaultuser=extern
secret=pass                                                                                                                    ; Der Vertrieb ist mobil und wechselt eventuell die IP-Adresse
insecure=invite
;insecure=very
;nat=force_rport,comedia
;nat=no

[analog01]
;DIAL MIT *122# <INTERN-NR>
callerid=Analog 01 phone <111>
type=friend
username=analog01
secret=pass
mailbox=111
host=dynamic
;host=172.16.3.3.3
;domain=192.168.1.1
callgroup=1
pickupgroup=1

[suuhmer]
callerid=suuhmer <10>
type=friend
username=suuhm                                                                                                          
secret=pass                                                                 
dtmfmode=rfc2833                                                              entsprechend RFC
host=dynamic   

[11]
callerid=Call <11>
type=friend
username=11
secret=pass
mailbox=11
host=dynamic
;domain=192.168.1.2
callgroup=1
pickupgroup=1

[12]
callerid=Esszimmer <12>
type=friend
username=12
secret=pass2
host=dynamic
;context=from-internal
nat=force_rport,comedia

[buero]
callerid=buero <13>
type=friend
username=buero                                                                                                          ; Standardeinstellung: Benutzer ist »user« und »peer« zugleich
secret=pass                                                                                                             ; Passwort für Telefon              ; Benutzername für Telefon
dtmfmode=rfc2833                                                                                                        ; Tastentöne nach Anwahl entsprechend RFC
host=dynamic                                                                                                            ; Der Vertrieb ist mobil und wechselt eventuell die IP-Adresse
;context=nebenstelle1

extensions.conf

; asterisk -rvvv
; sip show peers
; sip set debug on
; dialplan reload ; sip reload

[general]
;static=yes
writeprotect=no
autofallthrough=no

[ansagen-demo]
exten => 601,1,Answer()
; FIX FOR FREETZ:
; ln -s /var/media/ftp/uStor01/asterisk/atdata/sounds/ /var/lib/asterisk/
; LOCATING /var/lib/asterisk/sounds/tt-monkeysintro
exten => 601,n,Playback(tt-monkeysintro)
exten => 601,n,Playback(tt-monkeys)

[echotest]
exten => 602,1,answer
exten => 602,n,Wait(1)
exten => 602,n,playback(demo-echotest)
exten => 602,n,echo
exten => 602,n,playback(demo-echodone)
exten => 602,n,hangup

[musiconholdd]
exten => 666,1,Answer()
same => n,Wait(2)
same => n,MusicOnHold()

[incoming-out]
exten => 1333711,1,Goto(intern,10,1)

[in-outbound-call]
;inbound calls
exten => asterisk,1,NoOp(*** Interner Anruf auf ${EXTEN} ***)
exten => asterisk,n,GotoIfTime(8:00-18:00,mon-fri,*,*?intern,1,1)
;exten => asterisk,n,GoSub(timecheck,subnr,1)
exten => asterisk,n,Playback(tt-monkeys)
exten => asterisk,n,Hangup()

[capiisdnin]
exten => MSN_NR,1,NoOp(*** Interner Anruf auf ${EXTEN} ***)
exten => MSN_NR,n,GotoIfTime(8:00-18:00,mon-fri,*,*?intern,1,1)
exten => MSN_NR,n,Playback(tt-monkeys)
exten => MSN_NR,n,Hangup()

;; Intern *3#1011 Isdn -> 1011 (#101*302)
exten => _.,1,NoOp(*** Interner *3#1011 ISDN => ${EXTEN} ***)
exten => same,1,Dial(SIP/11,30,TtrWw)
exten => same,n,Playback(tt-monkeys)
exten => same,n,Hangup()

[intern]
exten => 111,1,Dial(SIP/analog01,30,TtrWw)
same => n,Hangup()
;same => n,MusicOnHold()

exten => 10,1,Dial(SIP/suuhmer,30,TtrWw)
same => n,Hangup()
;same => n,MusicOnHold()

exten => 11,1,NoOp(Rufen mich mal an den test inbound an :D)
same => n,dial(SIP/11,30,TtrWw)
;same => n,MusicOnHold()
same => n,Hangup()

;exten => 12,1,answer
;same => n,Playback(something-terribly-wrong)
;same => n,wait(5)

exten => 13,1,NoOp(Rufe 13 an buero)
same => n,dial(SIP/buero,30,TtrWw)
same => n,Hangup()

exten => 1010,1,Dial(SIP/suuhmer,30,TtrWw)
same => n,Hangup()

exten => 1011,1,Dial(SIP/11,30,TtrWw)
same => n,Hangup()

exten => 1013,1,Dial(SIP/buero,30,TtrWw)
same => n,Hangup()

exten => 1,1,Dial(SIP/suuhmer&SIP/11&SIP/buero&SIP/analog01,60)
same => n,Hangup()

exten => *555,1,VoiceMailMain(11)
same => n,Record(/tmp/555record.wav,5,20)
same => n,Hangup

exten => *777,1,VoiceMailMain(11)
same => n,Hangup

;calling analog buero
exten => 555,1,NoOp(*** EXterner ISDN CAPI Anruf calling analog buero auf: *1 ***)
exten => same,n,Dial(CAPI/ISDN1/*301)
exten => same,n,Hangup()

;;else..
;; letzten 3 zahlen ${EXTEN:-3}
;; erste stelle weg ${EXTEN:1}
;exten => _XXXX,1,Dial(SIP/${EXTEN},55,TtrWw)
;same => _0X.,1,Dial(SIP/${EXTEN:1}@testcenter,20,r)

;;Amtholung Outbound-Calls:
;;exten => _0X.,1,NoOp(*** EXterner Anruf auf: ${EXTEN:1} ***)
;exten => _0X.,n,Set(CALLERID(num)=44206660)
;exten => _0X.,n,Dial(SIP/${EXTEN:1}@626,45,r)
;;exten => _0X.,n,Dial(SIP/${EXTEN:1}@asterisk)
;;exten => _0X.,n,Hangup()

;;Amt 99 ISDN Outbound-Calls:
exten => _55X.,1,NoOp(*** EXterner ISDN CAPI Anruf auf: ${EXTEN:2} ***)
exten => _55X.,n,Dial(CAPI/ISDN1/${EXTEN:2})
exten => _55X.,n,Hangup()

;;Amt -> # ISDN Outbound-Intern-Calls:
exten => _000.,1,NoOp(*** Interne ISDN CAPI auf: ${EXTEN:3} ***)
exten => _000.,n,Dial(CAPI/ISDN1/${EXTEN:3})
exten => _000.,n,Hangup()

;; SPOOF CALLER
;exten => _[0-9].,1,NoOp(#### [SET P CALLER ID] ####)
;exten => _[0-9].,n,Set(CALLERID(num)=442077677)

exten => i,1,Hangup()
exten => h,1,Hangup()
exten => t,1,Hangup()

[main]
include => ansagen-demo
include => echotest
include => musiconholdd
;; SETUPS
;; RANGFOLGE BEACHTEN!
include => intern
include => incoming-out
include => capiisdnin
include => in-outbound-call