เชื่อมต่อ Asterisk + DAHDI กับ E1 MFC/R2 ตอนที่ 2

Asterisk Opensource IP Pbx

เชื่อมต่อ Asterisk + DAHDI กับ E1 MFC/R2 ตอนที่ 2

โพสต์โดย voip4share » 24 ก.พ. 2010 15:42

Asterisk, MFC/R2 ตอนที่ 1


1. ไฟล์คอนฟิกของ OpenR2
ไฟล์ /etc/r2proto.conf นี้จะควบคุมการทำงานของ OpenR2 (MFC/R2) ซึ่งที่ผ่านมาจะเห็นว่าเราในไฟล์ /etc/asterisk/chan_dahdi.conf เราตั้งค่า

mfcr2_variant=itu

ถ้ามันไม่เวอร์คสำรับประเทศไทย ให้เรามาแก้ไขข้อมูลในไฟล์ r2proto.conf นี้นะครับ โดยเอาพารามิเตอร์ในไฟล์ไปสอบถามผู้ให้บริการ

# Group A tones
mf_ga_tones.request_next_dnis_digit=1
mf_ga_tones.request_dnis_minus_1=2
mf_ga_tones.request_dnis_minus_2=7
mf_ga_tones.request_dnis_minus_3=8
mf_ga_tones.request_all_dnis_again=X
mf_ga_tones.request_next_ani_digit=5
mf_ga_tones.request_category=5
mf_ga_tones.request_category_and_change_to_gc=X
mf_ga_tones.request_change_to_g2=3
mf_ga_tones.address_complete_charge_setup=6
mf_ga_tones.network_congestion=4

# Group B tones
mf_gb_tones.accept_call_with_charge=6
mf_gb_tones.accept_call_no_charge=7
mf_gb_tones.busy_number=3
mf_gb_tones.network_congestion=4
mf_gb_tones.unallocated_number=5
mf_gb_tones.line_out_of_order=8
mf_gb_tones.special_info_tone=2
mf_gb_tones.reject_collect_call=X
mf_gb_tones.number_changed=X

# Group C tones (just Mexico use Group C signals)
mf_gc_tones.request_next_ani_digit=X
mf_gc_tones.request_change_to_g2=X
# This advanced configuration file allows you to tweak
# some R2 protocol definitions.
# If you happen to need to tweak definitions of this
# file to make openr2 work in your country, please let me
# know in order to implement them directly on the library
# http://www.libopenr2.org

# No spaces are allowed in parameter definition
# ie: parameter = value will not be properly read
# use parameter=value instead
# Lines starting with '#' or spaces will be IGNORED

# This DEFAULT configuration
# has the definitions of the ITU R2 variant as used by OpenR2
# and some other sample values (not ITU values)
# (may be outdated so don't fully trust this, code is the ultimate reference)

## TONE OVERRIDES ##
# The *ONLY* valid tone values are 1234567890BCDEF or X
# case sensitive (not accepted b c d e f x)
# NOTE that 'A' nor '10' are valid values, use 0 instead
# X means invalid tone (when you dont want to support a tone)

# Group A tones
mf_ga_tones.request_next_dnis_digit=1
mf_ga_tones.request_dnis_minus_1=2
mf_ga_tones.request_dnis_minus_2=7
mf_ga_tones.request_dnis_minus_3=8
mf_ga_tones.request_all_dnis_again=X
mf_ga_tones.request_next_ani_digit=5
mf_ga_tones.request_category=5
mf_ga_tones.request_category_and_change_to_gc=X
mf_ga_tones.request_change_to_g2=3
mf_ga_tones.address_complete_charge_setup=6
mf_ga_tones.network_congestion=4

# Group B tones
mf_gb_tones.accept_call_with_charge=6
mf_gb_tones.accept_call_no_charge=7
mf_gb_tones.busy_number=3
mf_gb_tones.network_congestion=4
mf_gb_tones.unallocated_number=5
mf_gb_tones.line_out_of_order=8
mf_gb_tones.special_info_tone=2
mf_gb_tones.reject_collect_call=X
mf_gb_tones.number_changed=X

# Group C tones (just Mexico use Group C signals)
mf_gc_tones.request_next_ani_digit=X
mf_gc_tones.request_change_to_g2=X
mf_gc_tones.request_next_dnis_digit_and_change_to_ga=X

# Group I tones
mf_g1_tones.no_more_dnis_available=F
mf_g1_tones.no_more_ani_available=F
mf_g1_tones.caller_ani_is_restricted=X

# Group II tones
mf_g2_tones.national_subscriber=1
mf_g2_tones.national_priority_subscriber=2
mf_g2_tones.international_subscriber=7
mf_g2_tones.international_priority_subscriber=9
mf_g2_tones.collect_call=X

# Timers in milliseconds
# Use -1 to leave default, or just comment it out for that matter
timers.mf_back_cycle=1500
timers.mf_back_resume_cycle=150
timers.mf_fwd_safety=10000
timers.r2_seize=8000
timers.r2_answer=80000
timers.r2_metering_pulse=0
timers.r2_double_answer=400
timers.r2_answer_delay=150
timers.cas_persistence_check=500
timers.dtmf_start_dial=100

## misc settings ##

# time that a MF tone should persist before handling it
mf_threshold=0

ต่อไปเราจะมาเทสการใช้งาน E1 MFC/R2 กันครับ สามารถเทสได้เลยโดยไม่ต้องรัน Asterisk

2. ทดสอบด้วย r2test
โปรแกรมนี้จะใช้คอนฟิกในไฟล์ /etc/r2test.conf คอย "ฟัง" คอลที่โทรเข้ามายังแชนแนล DAHDI ที่เราจะเทส จากนั้นรับสายและอาจจะสะท้อนเสียงกลับไปหาคนที่โทรเข้ามา (echo like) หรือเล่นไฟล์เสียง (ฟอร์แม็ต alaw) ให้ฟัง โปรแกรม r2test ยังสร้าง call ได้ด้วยนะครับ

2.1 สร้างไฟล์คอนฟิก /etc/r2test.conf ก่อน
ข้อมูลในไฟล์ มีรูปแบบนี้ครับ
# this is a comment
parameter1=value
parameter2=value
channel=start-end

เมื่อโปรแกรม r2test อ่านเจอบรรทัด channel มันจะสร้างบล๊อกของ DAHDI channel ขึ้นมาใหม่ตามจำนวนที่กำหนดไว้ มีหมายเลขเริ่มต้นจาก start ไปจนถึง end และคอนฟิกแชนแนลเหล่านั้นด้วยพารามิเตอร์ในบรรทัดบนๆ ตัวอย่าง

variant=itu
caller=no
maxani=10
maxdnis=4
channel=1-15

ซึ่งจะสร้างแชนแนล DAHDI ตั้งแต่ 1-15 และคอนฟิกแต่ละแชนแนลให้มี caller=no, maxani=10, maxdnis=4 ถ้าเจอข้อความว่า "No such file or directory" เป็นไปได้ว่าเรายังไม่ได้โหลดไดร์เวอร์ DAHDI ถ้ามันโหลดมันจะสร้าง device ใน /dev/dahdi ในตัวอย่างนี้เราต้องการแชนแนล /dev/dahdi/1 ถึง /dev/dahdi/15

บรรทัด varint เป็น variant ที่จะใช้ สามารถลิสต์ดูรายชื่อ variant ได้ด้วยคำสั่งนี้
โค้ด: เลือกทั้งหมด
r2test -l


บรรทัด caller กำหนดว่า group ของ channel ที่จะใช้สร้างคอลหรือรอคอล ถ้าเซ็ต caller=yes หมายความว่า channel จะ make call ซึ่งกรณีนี้เราต้องระบุ dnid ด้วย
บรรทัด maxani และ maxdnis กำหนดจำนวนดิจิตสูงสุดที่จะยอมรับสำหรับ ani และ dnis
บรรทัด channel ต้องอยู่ในรูปแบบ x-y ถ้าต้องการแค่ 1 channel ให้ใส่เป็น channel=1-1

ออปชั่นอื่นๆ
loglevel กำหนดระดับการ log มีอยู่หลาย level ได้แก่ error, warning, notice, debug
cas ล๊อก CAS TX/RX
mf ล๊อก MF Tone TX/RX
all
nothing
ใส่ผสมกันก็ได้นะครับ เช่น loglevel=warning,error,notice,cas,mf

2. เทส MFC/R2 ด้วยคำสั่ง
โค้ด: เลือกทั้งหมด
r2test -c /etc/r2test.conf


โปรแกรมจะรอรับคอลที่แชนแนล 1 ถึง 15 เมื่อมีคนโทรเข้ามา โปรแกรมนี้จะตอบรับ พูดอะไรก็จะได้ยินเสียงนั้นสะท้อนกลับไป (echo-like application) แต่ถ้าต้องการเล่นไฟล์เสียงแทน ให้เพิ่มอีก 2 บรรทัดนี้นะครับ

playaudio=yes
audiofile=/usr/src/openr2-1.2.0/doc/intro-openr2-es.alaw

3. รายละเอียดทั้งหมดในไฟล์ chan_dahdi.conf
[channels]
context=incomingr2

; MFC/R2 signalling
signalling=mfcr2

; MFC/R2 variant. This depends on the OpenR2 supported variants
; A list of values can be obtained with the command r2test -l
; common values are:
; mx (Mexico)
; br (Brazil)
; ar (Argentina)
; itu (per ITU spec)
mfcr2_variant=mx

; whether or not to get the ANI before getting DNIS.
; some telcos require ANI first some others do not care
; if this go wrong, change this value
; mfcr2_get_ani_first=no

; Max amount of ANI to ask for
; mfcr2_max_ani=10

; Max amount of DNIS to ask for
; mfcr2_max_dnis=4

; Caller Category to send
; national_subscriber
; national_priority_subscriber
; international_subscriber
; international_priority_subscriber
; collect_call
; usually national_subscriber works just fine
; you can change this setting from the dialplan
; by setting the variable MFCR2_CATEGORY
; (remember to set _MFCR2_CATEGORY from originating channels)
; MFCR2_CATEGORY will also be a variable available
; on incoming calls set to the value received from
; the far end
; mfcr2_category=national_subscriber

; Call logging is stored at the Asterisk
; logging directory specified in asterisk.conf
; plus mfcr2/<whatever you put here>
; if you specify 'span1' here and asterisk.conf has
; as logging directory /var/log/asterisk then the full
; path to your MFC/R2 call logs will be /var/log/asterisk/mfcr2/span1
; (the directory will be automatically created if not present already)
; remember to set mfcr2_call_files=yes
; mfcr2_logdir=span1

; whether or not to drop call files into mfcr2_logdir
; mfcr2_call_files=yes|no

; MFC/R2 valid logging values are: all,error,warning,debug,notice,cas,mf,stack,nothing
; error,warning,debug and notice are self-descriptive
; 'cas' is for logging ABCD CAS tx and rx
; 'mf' is for logging of the Multi Frequency tones
; 'stack' is for very verbose output of the channel and context call stack, only useful
; if you are debugging a crash or want to learn how the library works. The stack logging
; will be only enabled if the openr2 library was compiled with -DOR2_TRACE_STACKS
; You can mix up values, like: loglevel=error,debug,mf to log just error, debug and
; multi frequency messages
; 'all' is a special value to log all the activity
; 'nothing' is a clean-up value, in case you want to not log any activity for
; a channel or group of channels
; BE AWARE that the level of output logged will ALSO depend on
; the value you have in logger.conf, if you disable output in logger.conf
; then it does not matter you specify 'all' here, nothing will be logged
; so logger.conf has the last word on what is going to be logged
; mfcr2_logging=all

; MFC/R2 value in milliseconds for the MF timeout. Any negative value
; means 'default', smaller values than 500ms are not recommended
; and can cause malfunctioning. If you experience protocol error
; due to MF timeout try incrementing this value in 500ms steps
; mfcr2_mfback_timeout=-1

; MFC/R2 value in milliseconds for the metering pulse timeout.
; Metering pulses are sent by some telcos for some R2 variants
; during a call presumably for billing purposes to indicate costs,
; however this pulses use the same signal that is used to indicate
; call hangup, therefore a timeout is sometimes required to distinguish
; between a *real* hangup and a billing pulse that should not
; last more than 500ms, If you experience call drops after some
; minutes of being stablished try setting a value of some ms here,
; values greater than 500ms are not recommended.
; BE AWARE that choosing the proper protocol mfcr2_variant parameter
; implicitly sets a good recommended value for this timer, use this
; parameter only when you *really* want to override the default, otherwise
; just comment out this value or put a -1
; Any negative value means 'default'.
; mfcr2_metering_pulse_timeout=-1

; Brazil uses a special calling party category for collect calls (llamadas por cobrar)
; instead of using the operator (as in Mexico). The R2 spec in Brazil says a special GB tone
; should be used to reject collect calls. If you want to ALLOW collect calls specify 'yes',
; if you want to BLOCK collect calls then say 'no'. Default is to block collect calls.
; (see also 'mfcr2_double_answer')
; mfcr2_allow_collect_calls=no

; This feature is related but independent of mfcr2_allow_collect_calls
; Some PBX's require a double-answer process to block collect calls, if
; you ever have problems blocking collect calls using Group B signals (mfcr2_allow_collect_calls=no)
; then you may want to try with mfcr2_double_answer=yes, this will cause that every answer signal
; is changed by answer->clear back->answer (sort of a flash)
; (see also 'mfcr2_allow_collect_calls')
; mfcr2_double_answer=no

; This feature allows to skip the use of Group B/II signals and go directly
; to the accepted state for incoming calls
; mfcr2_immediate_accept=no

; WARNING: advanced users only! I really mean it
; this parameter is commented by default because
; YOU DON'T NEED IT UNLESS YOU REALLY GROK MFC/R2
; READ COMMENTS on doc/r2proto.conf in openr2 package
; for more info
; mfcr2_advanced_protocol_file=/path/to/r2proto.conf

; Brazil use a special signal to force the release of the line (hangup) from the
; backward perspective. When mfcr2_forced_release=no, the normal clear back signal
; will be sent on hangup, which is OK for all mfcr2 variants I know of, except for
; Brazilian variant, where the central will leave the line up for several seconds (30, 60)
; which sometimes is not what people really want. When mfcr2_forced_release=yes, a different
; signal will be sent to hangup the call indicating that the line should be released immediately
; mfcr2_forced_release=no

; Whether or not report to the other end 'accept call with charge'
; This setting has no effect with most telecos, usually is safe
; leave the default (yes), but once in a while when interconnecting with
; old PBXs this may be useful.
; Concretely this affects the Group B signal used to accept calls
; mfcr2_charge_calls=yes
voip4share
Administrator
 
โพสต์: 656
ลงทะเบียนเมื่อ: 18 พ.ย. 2009 11:26
ที่อยู่: รามคำแหง กรุงเทพฯ

ย้อนกลับไปยัง Asterisk SIP Server

ผู้ใช้งานขณะนี้

่กำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และ บุคคลทั่วไป 1 ท่าน

cron