Was this page helpful?

Huawei/Vodafone 3G USB Modem on Asterisk-datacard

    說明:使用 3G USB Modem 作為 Asterisk 的 GSM gateway。

    Chan_Dongle 官網:http://wiki.e1550.mobi/doku.php?id=Main%20page

    文章列表

    簡訊應用:

    系統環境

    • Vodafone_3G_Modem_k3520.jpgPIAF 1.7.5.5, BRONZE
    • Linux 2.6.18-194.26
    • Asterisk 1.6.2.17.2
    • Asterisk-addons 1.6.2.3
    • Vodafone 3G Modem K3520

    前往更多可支援的硬體列表

    安裝開始

    未作任何安裝前,Linux 偵測 USB 3G Modem 的情形:

    [email protected]:~ $ lsusb
    Bus 001 Device 012: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem <<<
    Bus 001 Device 001: ID 0000:0000
    Bus 002 Device 001: ID 0000:0000
    
    [email protected]:~ $ dmesg
    ...
    ...
    usb 1-1: new full speed USB device using uhci_hcd and address 12
    usb 1-1: configuration #1 chosen from 1 choice
    usb-storage: probe of 1-1:1.0 failed with error -5
    usb-storage: probe of 1-1:1.1 failed with error -5
    usb-storage: probe of 1-1:1.2 failed with error -5
    scsi27 : SCSI emulation for USB Mass Storage devices
    usb-storage: device found at 12
    usb-storage: waiting for device to settle before scanning
      Vendor: HUAWEI    Model: Mass Storage      Rev: 2.31
      Type:   CD-ROM                             ANSI SCSI revision: 02
    sr0: scsi-1 drive
    sr 27:0:0:0: Attached scsi CD-ROM sr0
    sr 27:0:0:0: Attached scsi generic sg0 type 5
      Vendor: HUAWEI    Model: SD Storage        Rev: 2.31
      Type:   Direct-Access                      ANSI SCSI revision: 02
    sd 27:0:0:1: Attached scsi removable disk sda
    sd 27:0:0:1: Attached scsi generic sg1 type 0
    usb-storage: device scan complete
    

    Tips:

    如果存在 /dev/ttyUSB* 檔案,就表示 modem 驅動正常。

    硬體驅動設定

    步驟的一開始要先使 CentOS Linux 能夠正常辨識 USB modem 硬體,而且能夠正常驅動它,很幸運,在筆者的 CentOS 5.5 Linux 預裝環境已經內建支援 USB modem。

    確認方法為:

    [email protected]:~/temp $ lsusb
    Bus 001 Device 004: ID 12d1:1001 Huawei Technologies Co., Ltd. E620 USB Modem
    Bus 001 Device 001: ID 0000:0000
    Bus 002 Device 001: ID 0000:0000
    
    [email protected]:~/temp $ ls -l /dev/ttyUSB*
    crw-rw---- 1 root asterisk 188, 0 May  9 17:56 /dev/ttyUSB0
    crw-rw---- 1 root asterisk 188, 1 May  9 17:56 /dev/ttyUSB1
    crw-rw---- 1 root asterisk 188, 2 May  9 18:12 /dev/ttyUSB2 
    

    如果裝置名稱 ttyUSB* 群組權限不是 Asterisk,請參考 F.A.Q

    安裝 Dongle 模組

    下載位址:https://code.google.com/p/asterisk-chan-dongle/downloads/list

    如果你是 Asterisk 11 以後的版本你還需要加上這個 patch(直接覆蓋上面下載的檔案即可) https://github.com/jstasiak/asterisk...asterisk11.zip

    cd /usr/src
    tar xzf chan_dongle-1.1.r14.tgz
    cd chan_dongle-1.1.r14/
    ./configure
    make
    make install
    amportal stop
    amportal start
    

    如果上述的 make 發生錯誤,再執行一次 make 即可

    檢查 dongle 模組

    # asterisk -rx "module show like dongle"
    Module                         Description                              Use Count
    chan_dongle.so               dongle Channel Driver                  0
    1 modules loaded
    

    新增設定檔 /etc/asterisk/dongle.conf

    [general]
    
    interval=15                     ; Number of seconds between trying to connect to devices
    
    ;------------------------------ JITTER BUFFER CONFIGURATION --------------------------
    ;jbenable = yes                 ; Enables the use of a jitterbuffer on the receiving side of a
                                    ; Dongle channel. Defaults to "no". An enabled jitterbuffer will
                                    ; be used only if the sending side can create and the receiving
                                    ; side can not accept jitter. The Dongle channel can't accept jitter,
                                    ; thus an enabled jitterbuffer on the receive Dongle side will always
                                    ; be used if the sending side can create jitter.
    
    ;jbforce = no                   ; Forces the use of a jitterbuffer on the receive side of a Dongle
                                    ; channel. Defaults to "no".
    
    ;jbmaxsize = 200                ; Max length of the jitterbuffer in milliseconds.
    
    ;jbresyncthreshold = 1000       ; Jump in the frame timestamps over which the jitterbuffer is
                                    ; resynchronized. Useful to improve the quality of the voice, with
                                    ; big jumps in/broken timestamps, usually sent from exotic devices
                                    ; and programs. Defaults to 1000.
    
    ;jbimpl = fixed                 ; Jitterbuffer implementation, used on the receiving side of a Dongle
                                    ; channel. Two implementations are currently available - "fixed"
                                    ; (with size always equals to jbmaxsize) and "adaptive" (with
                                    ; variable size, actually the new jb of IAX2). Defaults to fixed.
    
    ;jbtargetextra = 40             ; This option only affects the jb when 'jbimpl = adaptive' is set.
                                    ; The option represents the number of milliseconds by which the new jitter buffer
                                    ; will pad its size. the default is 40, so without modification, the new
                                    ; jitter buffer will set its size to the jitter value plus 40 milliseconds.
                                    ; increasing this value may help if your network normally has low jitter,
                                    ; but occasionally has spikes.
    
    ;jblog = no                     ; Enables jitterbuffer frame logging. Defaults to "no".
    ;-----------------------------------------------------------------------------------
    
    [defaults]
    ; now you can set here any not required device settings as template
    ; sure you can overwrite in any [device] section this default values
    
    context=from-trunk                 ; context for incoming calls, SMS and USSD
    group=0                         ; calling group
    rxgain=0                        ; increase the incoming volume; may be negative
    txgain=0                        ; increase the outgoint volume; may be negative
    autodeletesms=yes               ; auto delete incoming sms
    resetdongle=yes                 ; reset dongle during initialization with ATZ command
    u2diag=-1                       ; set ^U2DIAG parameter on device (0 = disable everything except modem function) 
                    ; -1 not use ^U2DIAG command
    usecallingpres=yes              ; use the caller ID presentation or not
    callingpres=allowed_passed_screen ; set caller ID presentation. By default use default network settings
                    ; see http://www.the-asterisk-book.com/unstable/applikationen-setcallerpres.html
    disablesms=no                   ; disable of SMS reading from device when received. Enable this option to disable 
                    ; sms reception. Use smsaspdu=yes to avoid problem when SMS is too long in TEXT mode.
    smsaspdu=yes                    ; if 'yes' send SMS in PDU mode.
    language=en                     ; set channel default language
    mindtmfgap=45                   ; minimal interval from end of previews DTMF from begining of next in ms
    mindtmfduration=80              ; minimal DTMF tone duration in ms
    mindtmfinterval=200             ; minimal interval between ends of DTMF of same digits in ms
    
    callwaiting=auto                ; if 'yes' allow incoming calls waiting; by default use network settings
                                    ; if 'no' waiting calls just ignored
    disable=no                      ; if 'yes' no load this device and just ignore this section
    exten=+1234567890               ; exten for start incoming calls, only in case of Subscriber Number not available!,
                    ; also set to CALLERID(dnid)
    
    dtmf=relax          ; control of incoming DTMF detection, possible values:
                    ;   off    - off DTMF tone detection, voice data passed to asterisk unaltered
                    ;              use this value for gateways or if you do not use IVR in diaplan
                    ;   inband - do DTMF tones detection
                    ;   relax  - like inband but with relaxdtmf option
                    ;  default is 'relax' for backward compatibility
    
    
    
    
    ; dongle required settings
    [dongle0]
    audio=/dev/ttyUSB1              ; tty port for audio connection;        
    data=/dev/ttyUSB2               ; tty port for AT commands; 
    
        ; or you can omit both audio and data parameters and use imei=123456789012345 and/or imsi=612849384756451
        ; imei and imsi must contain exactly 15 digits !
            ;  imei/imsi discovery is available on Linux only
    
    imei=123456789012345
    imsi=612849384756451
        
        ; if you set audio and data parameter together with imei and/or imsi, audio and data is used.
        ; you can use both imei and imsi together. In this case exact match by imei and imsi is required.
    chown asterisk:asterisk /etc/asterisk/dongle.conf
    chmod 664 /etc/asterisk/dongle.conf

    檢查設定檔是否被載入

    # asterisk -rx "help dongle"
                dongle callwaiting Enable/Disable Call-Waiting on the dongle
                        dongle cmd Send commands to port for debugging
                  dongle discovery Discovery devices and create config
                        dongle pdu Send PDU of SMS from the dongle
                     dongle reload Reload dongle
                     dongle remove Remove dongle
                      dongle reset Reset dongle now
                    dongle restart Restart dongle
       dongle show device settings Show Dongle device settings
          dongle show device state Show Dongle device state
     dongle show device statistics Show Dongle device statistics
               dongle show devices Show Dongle devices state
               dongle show version Show module version
                        dongle sms Send SMS from the dongle
                      dongle start Start dongle
                       dongle stop Stop dongle
                       dongle ussd Send USSD commands to the dongle
    

    找尋 IMEI & IMSI:

    pbx*CLI> dongle show devices
    ID           Group State      RSSI Mode Submode Provider Name  Model      Firmware          IMEI             IMSI             Number
    dongle    0     Free       19   0    0       805A015BF696FB K3520      11.314.17.31.00   353436038000000  466890000000000  0973000000

    Tips:

    搜尋 dongle 前,必須已作過 modem 解鎖及放入 SIM card。

    修改 /etc/asterisk/dongle.conf:

    ; K3520
    imei=3534360385000000
    imsi=466890000000000
    

    dongle 指令輸出:

    pbx*CLI> dongle show device statistics dongle0
    -------------- Statistics -------------
      Device                      : dongle0
      Queue tasks                 : 13
      Queue commands              : 34
      Responses                   : 53
      Bytes of readed responces   : 657
      Bytes of wrote commands     : 268
      Bytes of readed audio       : 0
      Bytes of wrote audio        : 0
      Readed frames               : 0
      Readed short frames         : 0
      Wrote frames                : 0
      Wrote short frames          : 0
      Wrote silence frames        : 0
      Write buffer overflow bytes : 0
      Write buffer overflow times : 0
      Incoming calls              : 0
      Waiting calls               : 0
      Handled input calls         : 0
      Fails to PBX run            : 0
      Attempts to outgoing calls  : 0
      Answered outgoing calls     : 0
      Answered incoming calls     : 0
      Seconds of outgoing calls   : 0
      Seconds of incoming calls   : 0
      ACD for incoming calls      : -1
      ACD for outgoing calls      : -1
      ASR for incoming calls      : -1
      ASR for outgoing calls      : -1
    
    pbx*CLI> dongle show device settings dongle0
    ------------- Settings ------------
      Device                  : dongle0
      Audio                   : /dev/ttyUSB1
      Data                    : /dev/ttyUSB2
      IMEI                    : 123456789012345
      IMSI                    : 612849384756451
      Channel Language        : UTF-8
      Context                 : dongle-incoming
      Exten                   : +85267896789
      Group                   : 0
      RX gain                 : 3
      TX gain                 : -3
      U2Diag                  : -1
      Use CallingPres         : Yes
      Default CallingPres     : Presentation Allowed, Passed Screen
      Auto delete SMS         : Yes
      Disable SMS             : No
      Reset Dongle          : Yes
      SMS PDU                 : Yes
      Call Waiting            : auto
      DTMF                    : inband
      Minimal DTMF Gap        : 45
      Minimal DTMF Duration   : 80
      Minimal DTMF Interval   : 200
      Initial device state    : start
    

    FreePBX/Asterisk 撥號設定

    Inbound 設定
    1. 確定 dongle.conf 內兩個參數:
      • [defaults] > context=from-trunk
      • [dongle0] > exten=<SIM 卡的電話號碼>
    2. FreePBX > Inbound Routes > Add Inbound Roue
      • DID Number: <SIM 卡的號碼>
      • Set Destination: <whatever you wanted>
    Outbound 設定

    1. 新增 Custom Trunk
    FreePBX > Trunks > Add Custom Trunk

    • Trunk Description: 3G Modem
    • Outbound Caller ID: <手機號碼>
    • Custom Dial String: Dongle/dongle0/$OUTNUM$

    註:dongle0 必須與 dongle.conf 的內容相同。

    2. 新增 Outbound Route
    FreePBX > Outbound Routes > Add Roue

    • Route Name: 3GModem
    • Dial Patterns: 009|.
    • Trunk Sequence: Dongle/dongle0/$OUTNUM$

    評測報告

    3G Modem 型號:Vodafone K3520

    評測項目 結果 備註
    Linux 支援-CentOS 5.5 PASS  
    電話撥出 PASS  
    電話撥入 PASS  
    撥出後 DTMF 辨識 (SJphone -> 3G Modem -> Vibo 客服 PASS  
    撥入後 DTMF 辨識 (市話 -> 3G Modem -> Asterisk IVR -> SIP 分機) PASS  
    英文簡訊SMS PASS  
    中文簡訊SMS PASS  

    F.A.Q

    錯誤訊息:

    chan_dongle.c:     -- [dongle0] Trying to connect on /dev/ttyUSB2...
    chan_dongle.c: unable to open /dev/ttyUSB2: No such file or directory

    Ans:

    chown asterisk:asterisk /dev/ttyUSB1
    chown asterisk:asterisk /dev/ttyUSB2 
    
    錯誤訊息:

    -- [dongle0] Trying to connect on /dev/ttyUSB2...
    -- [dongle0] Dongle has connected, initializing...
    -- [dongle0] Dongle needs to be reinitialized. The SIM card is not ready yet
    -- [dongle0] Error initializing Dongle
    -- [dongle0] Dongle has disconnected

    Ans: 可能 3G Modem 尚未解鎖或未插入 SIM card,請參閱教學。

    檔案 /dev/ttyUSB1, ttyUSB2 權限只要每次 USB modem 重插後就會回復成 root?

    Ans: 編輯 /etc/udev/rules.d/50-udev.rules

    KERNEL=="tty[A-Z]*",            NAME="%k", GROUP="asterisk", MODE="0660"
    

    想了解更多有關 udev,請前往:http://benjr.tw/node/407

    當來電進入 IVR 後,無法有效辨識 DTMF 轉接到指定分機?

    Ans: 請調整 /etc/asterisk/dongle.conf 幾個參數:

    • dtmf=inband
    • mindtmfgap=45
    • mindtmfduration=20, 在筆者實驗,是將這參數從 80 調到 20 後,辨識度比較正常。
    • mindtmfinterval=200
    如何確認 USB modem 是否有被偵測到

    Ans:

    cat /proc/bus/usb/devices
    
    Was this page helpful?
    標籤 (Edit tags)
    • No tags

    文件 1

    文件大小日期附件上傳者 
     Vodafone_3G_Modem_k3520.jpg
    Vodafone USB 3G Modem
    8.52 KB12:13, 6 May 2011alang動作
    查看第1個(總1個)評論: 查看所有
    請問我撥號並結束通話掛斷後,datacard的state就會一直停留在dailing不會結束,可能是那邊的問題呢?
    發佈時間 10:44, 30 Jul 2011 ()
    查看第1個(總1個)評論: 查看所有
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core