Mitel SX-200 via T1 E-M and PRI


We've connected Asterisk to Mitel SX-200 in two configurations:

  • T1 E&M link (Asterisk in between two SX-200s that used to talk directly);
  • T1 PRI (Asterisk in between phone company and SX-200).

SX-200 intro


Good luck with that. There isn't much freely available information on the web, but there is an online help system in the godawful web interface. The various forms are connected roughly as follows:
  1. ARS digit strings (form 26): leading digit strings are routed to route numbers.
  2. ARS route definition (form 23): route numbers are sent to trunk groups, with optional modified digit entries.
  3. ARS modified digit table (form 22): dial strings are mangled in various ways.
  4. Trunk groups (form 16): a list of channels (e.g. the 24 channels in your T1 E&M link).
  5. Dial-in trunks (form 15): the channels are defined here before being listed under trunk groups. Each channel has a COS (class of service) and a CDN (circuit descriptor number); in theory every channel in a group should have the same COS and CDN, but typos happen.
  6. Trunk circuit descriptors (form 13): these define protocol-level options such as whether to use WINK, DTMF, etc.
  7. T1 link descriptors (form 42): these define line-level options such as coding and framing.
  8. Network synchronization (form 44): this is where the preference for clock source is defined.
  9. COS definitions (form 3): Hundreds of magic options for calls going into and out of trunks, all ambiguously named and poorly documented.

For ISDN/PRI links you may be using an NSU, which will ignore some undocumented set of options from your COS and CDN settings and require others... plus you get to configure it using a Windows-only tool that isn't available on the web.

For Mitel help, the Tek-Tips forums are great: http://www.tek-tips.com/ under Wiring Closet, Phone Systems, Mitel Networks solutions.

E&M Wink


This is digital emulation of ancient analog signalling. Avoid it if you can, but I suspect the Mitel E&M license is cheaper than PRI.

You can get numeric caller ID passing in both directions. Everything is toned out using DTMF, so it's a bit slower than PRI. You can also turn on/off message waiting indicator (MWI) lights.

Asterisk and Mitel will use the following digit modifications to exchange caller ID and other information:
  • Normal calls: 64CCCC...#DDDD...
    • 64: this is the Mitel feature access code for "analog network accept caller ID";
    • CCCC... the caller ID
    • DDDD...: the number being dialled
  • Forward to voicemail: 64CCCC#57MMMM#60*RRR#VVVV
    • 64: analog network accept caller ID
    • CCCC...: original caller ID
    • 57: analog network accept forwarding extension
    • MMMM: the forwarding extension (i.e. the mailbox number)
    • *RRR: call forwarding reason:
      • *611 = extension is set to call forward always
      • *612 = busy
      • *613 = no answer
    • VVVV: the extension we're forwarding to, usually some system voicemail extension
  • User checking his own voicemail: 64MMMM#VVVV (mailbox number is in caller ID)
  • Turn on message waiting indicator (MWI): 581MMMM where MMMM is mailbox number
    • can be preceded by 64CCCC#, but this information is ignored
  • Turn off MWI: 582MMMM

Asterisk settings

/etc/dahdi/system.conf



; Link to Mitel - we are timing master
; ESF would be better than D4, but we had a D4 telco link in the middle and it was
; easier not to deal with getting them to change it at 4 in the morning.
span=1,0,0,d4,b8zs
e&m=1-24


/etc/asterisk/chan_dahdi.conf



[trunkgroups]

[channels]
context=from_mitel
immediate=no

usecallerid=yes
usecallingpres=yes
facilityenable = yes
echocancel=128
echocancelwhenbridged=yes

signalling=em_w
wink=200          ;wink timer
debounce=100             ;debounce timer
flash=300         ;flash timer
toneduration=100
starttime=750

group=0

; This setting must come LAST; all the settings above apply to the
; listed channels.
channel => 1-24


extensions.conf



; Incoming call from Mitel
[from_mitel]
    ; Note: if you have a catch-all pattern like _X., Asterisk will wait
    ; 3 seconds for more digits every time a call comes in; if you want to
    ; shortcut this, you will have to add lots of ; nasty patterns ending in
    ; '!' to catch as many cases as you can.

    ; user-to-user, forward to voicemail (our voicemail extension is 5100)
    ; Our extensions are 4 digits
    exten => _64XXXX#57XXXX#60*XXX#5100!,1,Gosub(decode_mitel_voicemail_string,${EXTEN},1)
    exten => _64XXXX#57XXXX#60*XXX#5100!,n,Gosub(dial_asterisk_vmail,s,1)
    exten => _64XXXX#57XXXX#60*XXX#5100!,n,Hangup()

    ; User checking his own voicemail
    exten => _64XXXX#57#60#5100!,1,Gosub(decode_mitel_voicemail_string,${EXTEN},1)
    exten => _64XXXX#57#60#5100!,n,Gosub(dial_asterisk_vmail,s,1)
    exten => _64XXXX#57#60#5100!,n,Hangup()

    ; No caller ID, forward to voicemail
    exten => _64#57XXXX#60*XXX#5100!,1,Gosub(decode_mitel_voicemail_string,${EXTEN},1)
    exten => _64#57XXXX#60*XXX#5100!,n,Gosub(dial_asterisk_vmail,s,1)
    exten => _64#57XXXX#60*XXX#5100!,n,Hangup()

    ; North American caller ID, forward to voicemail
    exten => _64XXXXXXXXXX#57XXXX#60*XXX#5100!,1,Gosub(decode_mitel_voicemail_string,${EXTEN},1)
    exten => _64XXXXXXXXXX#57XXXX#60*XXX#5100!,n,Gosub(dial_asterisk_vmail,s,1)
    exten => _64XXXXXXXXXX#57XXXX#60*XXX#5100!,n,Hangup()

    ; Catch all other voicemail (with 3-second delay at end of dialling)
    ; note: this part is untested and is not in our dialplan
    exten => _64.#57.#5100,1,Gosub(decode_mitel_voicemail_string,${EXTEN},1)
    exten => _64.#57.#5100,n,Gosub(dial_asterisk_vmail,s,1)
    exten => _64.#57.#5100,n,Hangup()

    ; User-to-user dialling one of our 4-digit extensions
    ; (which begin with 1, 2 or 4)
    ; note: this part is untested
    exten => _64XXXX#[124]XXX!,1,Gosub(decode_mitel,${EXTEN},1)
    exten => _64XXXX#[124]XXX!,n,Goto(from_mitel_decoded,${DECODED_EXTEN},1)

    ; Catch all caller-id enabled dials with 3-second delay at end of dialling
    exten => _64.,1,NoOp(from_mitel: catch all CID: ${EXTEN})
    exten => _64.,n,Gosub(decode_mitel,${EXTEN},1)
    exten => _64.,n,Goto(from_mitel_decoded,${DECODED_EXTEN},1)

    ; Catch everything else, 3-second delay
    exten => _X.,1,NoOp(from_mitel: catch all no CID: ${EXTEN})
    exten => _X.,n,Goto(from_mitel_decoded,${DECODED_EXTEN},1)

[from_mitel_decoded]
    ; XXX include your inbound/outbound contexts here

[decode_mitel_voicemail_string]
    exten => _64.,1,NoOp(${EXTEN})
    exten => _64.,n,Set(CALLERID(num)=${CUT(EXTEN:2,#,1)})
    exten => _64.,n,Set(USER_EXTEN=${CUT(EXTEN:2,#,2):2})
    exten => _64.,n,Set(FWD_REASON=${CUT(EXTEN:2,#,3):2})
    exten => _64.,n,Return()

[dial_asterisk_vmail]
    exten => s,1,GotoIf($["${FWD_REASON}" = "*612"]?busy)
    exten => s,n,GotoIf($["${FWD_REASON}" = "*613"]?unavail)
    exten => s,n,GotoIf($["${FWD_REASON}" = "*611"]?unavail)

    ; Catch any other reason we don't know about.
    exten => s,n,GotoIf($["${FWD_REASON}" != ""]?unavail)

    exten => s,n(check),NoOp(XXX put your code for checking mailbox ${CALLERID(num)} here)
    exten => s,n,Return()

    exten => s,n(busy),NoOp(XXX put your code for leaving a busy message with ${USER_EXTEN} here)
    exten => s,n,Return()

    exten => s,n(unavail),NoOp(XXX put your code for leaving an unavail message with ${USER_EXTEN} here)
    exten => s,n,Return()


; Decode 64<callerid>#<dialled number>
[decode_mitel]
    exten => _64.,1,Set(CALLERID(num)=${CUT(EXTEN:2,#,1)})
    exten => _64.,n,Set(DECODED_EXTEN=${CUT(EXTEN:2,#,2)})
    exten => _64.,n,Return

; XXX Call this sub to dial a Mitel and pass caller ID.
; e.g. exten => _1XXX,1,Gosub(dial_a_mitel_cid,${EXTEN},1(Dahdi/g0))
;      exten => _1XXX,n,Hangup
[dial_a_mitel_cid]
    exten => _X.,1,Dial(${ARG1}/64${CALLERID(num)}#${EXTEN})



Mitel MWI script: /usr/local/bin/mitel_mwi.sh


To turn on Mitel MWI when a voicemail is left in Asterisk, you'll need an externnotify script such as the one in Asterisk Realtime MWI Hacks. If the notify script decides it needs to send MWI to a Mitel handset, it can call this script, /usr/local/bin/mitel_mwi.sh:


#!/bin/sh

LOG="logger -t $0"
EXTEN=$1
STATE=$2

if [ $# -ne 2 ] ; then
    echo "Usage: basename $0 <ext> <on|off>"
    exit 0
fi

outdir=/var/spool/asterisk/outgoing
tmpdir=/var/spool/asterisk/tmp

callfile=$(mktemp "$tmpdir/mwiXXXXXX")

if [ $2 = "on" ] ; then
    NUM="581$EXTEN"
elif [ $2 = "off" ] ; then
    NUM="582$EXTEN"
else
    echo "Usage: $0 <ext> <up|down>"
    exit 0
fi

# XXX replace Dahdi/g1 with the Dahdi channel group for your Mitel.
cat <<EOF > "$callfile"
Channel: Dahdi/g1/${NUM}
WaitTime: 15
Context: mitel_mwi_ctx
Extension: s
Priority: 1
EOF

mv "$callfile" "$outdir/"




In extensions.conf, add:


; Calls to turn MWI on are dropped into this context by mitel_mwi.sh
[mitel_mwi_ctx]
    exten => s,1,NoOp(mitel_mwi_ctx)

    ; Wait long enough for the call to make it through to another Mitel
    ; if it has to.
    exten => s,n,Wait(7)

    exten => s,n,Hangup()


Mitel settings


T1 link configuration

On form 42 (T1 Link Descriptors), define a T1 DS1. Use mostly default settings:
  • Alarm debounce timer: 2500ms
  • Line coding: B8ZS
  • Line build out: 0 DB
  • length: 266-398 ft
  • framing: ESF if you can; we used D4
  • slip rate limits - default
  • BER rate limits - default
  • framing loss limits - default
  • termination mode - NT
  • protocol - DMS 100 (probably ignored for E&M)
  • protocol variant: NONE
  • network/user: USER
  • unknown numbering plan: DISABLED
  • bearer capability voice: SPEECH
  • CLIR voice: ALLOW
  • invert D channel: NO

Assign your T1 link(s) on Form 43. On Form 44 (network sync), set up your clock sources so the Mitel takes clock from Asterisk, if appropriate.

Feature code setup

On form 2, feature access codes, set up the following access codes:
  • feature 39 - analog network accept caller ID - access code 64
  • feature 41 - send message - code 58
  • feature 54 - analog network accept call forward data - 57
  • feature 55 - analog network accept call forward reason - 60

On form 31, system abbreviated dial entries, create a speed dial entry for voicemail access. Pick a digit string, e.g. 5100, and fill it in under some speed dial index, e.g. 200. Later you'll set up a route for 5100.

On form 9, desktop device assignments, go into call forward review for each phone and set them up to call forward to speed dial 200 on busy and no answer.

COS definition


On form 3, create a COS for your Asterisk trunk lines. Enable the following options:
  • 802, Limited Wait for Dial Tone
  • 229, voice mail port
  • 259, message sending (this is required for MWI)
  • 265: voicemail system speed dial index: 200. This is the entry the Mitel will dial when users hit the MESSAGE button if Asterisk turned on MWI.

On form 4 (sys opts), enable option 48 - limited wait for dial tone - set it to 1 second.

In the COS for your handsets, you'll want to turn on all the X to X Connect settings (options 313-319) if you want users to be able to transfer incoming calls back out to Asterisk (e.g. if the receptionist is still on the Mitel and some handsets are on Asterisk).

Trunk setup

On Form 13, trunk circuit descriptors, create a T1 E&M descriptor and edit it (SEL. OPTION).
  • DTMF: YES
  • Disconnect timer: 300ms
  • Release ack timer: 40ms
  • Guard timer: 800ms
  • Incoming start type: WINK
  • Debounce timer: 100ms
  • Wink timer: 200ms
  • Outgoing start type: WINK
  • Interdigit timer: 300ms

On form 15, dial-in trunks, add your trunks, referencing your COS and CDN (trunk circuit descriptor). You can leave N and M at 0.

On form 16, trunk groups, create a SMDR, TERM trunk group and add your trunk lines.

Routing


On form 22, modified digit table, create two entries:
  • qtd 0, insert 64*6#: this will be for normal calls
  • qtd 0, insert 64*6#57*01#60*02#: this will be for forwarding to voicemail
    • *6: insert caller ID
    • *01: insert forwarding extension (mailbox number)
    • *02: insert call forward reason (*611, *612 or *613 - see the example Asterisk dialplan above)

On form 23, route definition, create two routes, each referencing your trunk group but one of them using the first mod dig entry and the other using the second.

On form 26, digit strings, create the digit strings you need and send them to the first route.

For example, for outgoing calls that start with 9:
  • 9, return dial tone
    • digits to analyze: 011, qty to follow unknown
    • digits: 1XXXXXXXXXX, qty to follow 0
    • digits: <your area code>XXXXXXX, qty to follow 0

Now create a digit string for voicemail.
  • digit string: 5100 - this matches the speed dial you added above
  • no digits to analyze, quantity to follow 0
  • route it to the route that uses the long 64*6#57... modified digit entry

T1 PRI


TODO.

This works, and you can pass numeric caller ID, caller ID name, and MWI status over the link. We couldn't get call-forward to voicemail to work properly over the PRI because of restrictions in how the NSU re-mangles the modified digit string. We used a second T1 link running E&M for voicemail forwarding.


Asterisk


Mitel settings

Created by: mike_smith, Last modification: Tue 10 of Feb, 2009 (01:12 UTC)


Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+

Page Changes | Comments