Was this page helpful?

Asterisk 11 with chan_dongle

    系統環境

    • cubieboard_3G_Modem.jpgCubieboard v1 (Cortex-A8 ARM-based)
    • Cubian (Debian 7.1)
    • Asterisk 11
    • chan_dongle(patched for asterisk 11)
    • Vodafone 3G Modem K3520

    安裝 Linux Kernel source

    先升級 linux kernel 至 3.4.79

    apt-get install linux-image-3.4.79-sun4i
    

    重啟系統

    apt-get install linux-headers-`uname -r`
    

    套件編譯的需求軟體

    apt-get install build-essential automake git libncurses5-dev libxml2-dev libsqlite3-dev sqlite3 mysql-client libmysql++-dev libmyodbc libssl-dev libcurl4-openssl-dev libgmime-2.6-dev unixodbc-dev uuid-dev libsrtp0-dev libiksemel-dev
    

    硬體驅動

    apt-get install usbutils usb-modeswitch

    插入GSM USB Dongle 前

    # lsusb
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    
    # ls -l /dev/ttyUSB*
    ls: cannot access /dev/ttyUSB*: No such file or directory
    

    插入GSM USB Dongle 後

    # lsusb
    Bus 004 Device 003: ID 12d1:1001 Huawei Technologies Co., Ltd. E169/E620/E800 HSDPA Modem
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    
    # ls -l /dev/ttyUSB*
    crw-rw---T 1 root dialout 188, 0 Feb 28 09:21 /dev/ttyUSB0
    crw-rw---T 1 root dialout 188, 1 Feb 28 09:21 /dev/ttyUSB1
    crw-rw---T 1 root dialout 188, 2 Feb 28 09:21 /dev/ttyUSB2
    

    如果 ttyUSB 的群組權限不是 asterisk,請繼續下面的步驟:
    新增 /etc/udev/rules.d/92-huawei-3g.rules

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

    重啟 udev 服務

    #> service udev stop
    #> service udev start
    

    安裝 Asterisk 11

    cd /usr/src
    wget http://downloads.asterisk.org/pub/te...current.tar.gz
    tar xzf asterisk-11-current.tar.gz
    cd cd asterisk-11.16.0/
    ./configure
    make menuselect
    make
    make install
    make install-logrotate
    make config
    make samples

    設定 Asterisk 啟動檔

    編輯 /etc/default/asterisk

    移除註解符號
    AST_USER="asterisk"
    AST_GROUP="asterisk"
    

    新增帳號及群組 asterisk

    addgroup --system asterisk
    adduser --system --ingroup asterisk --home /var/lib/asterisk --no-create-home --shell /bin/bash asterisk
    

    設定目錄權限

    chown -R asterisk:asterisk /etc/asterisk
    chown -R asterisk:asterisk  /var/{run,log,spool,lib}/asterisk
    

    啟動 Asterisk 服務

    /etc/init.d/asterisk start
    

    關閉服務

    /etc/init.d/asterisk stop
    

    NOTE:

    啟動服務後,出現這個提示:
    asteriskPrivilege escalation protection disabled!
    See https://wiki.asterisk.org/wiki/x/1gKfAQ for more details.

    要解決這個,修改檔案 /etc/asterisk/asterisk.conf
    移除註解符號
    live_dangerously = no

    重啟 Asterisk 服務後再試試。

    安裝 chan_dongle for asterisk 11

    cd /usr/src
    wget https://github.com/jstasiak/asterisk-chan-dongle/archive/asterisk11.zip
    unzip asterisk11.zip
    cd asterisk-chan-dongle-asterisk11
    aclocal
    autoconf
    automake -a
    ./configure
    make
    make install
    cp etc/dongle.conf /etc/asterisk/
    chown asterisk:asterisk /etc/asterisk/dongle.conf
    

    測試 Chan_Dongle 模組

    /etc/init.d/asterisk start
    
    #> asterisk -rx "module show like dongle"
    Module                         Description                              Use Count
    chan_dongle.so                 Huawei 3G Dongle Channel Driver          0
    1 modules loaded
    
    

    設定 chan_dongle 模組

    編輯 /etc/asterisk/dongle.conf

    [general]
    ...
    [defaults]
    context=from-trunk
    ...
    dtmf=inband
    ...
    ;exten=+1234567890 ;註解這行
    
    [dongle0]
    audio=/dev/ttyUSB1
    data=/dev/ttyUSB2
    
    ;imei=123456789012345 ;註解這兩行
    ;imsi=123456789012345
    
    

    查詢 IMEI & IMSI

    1. 插上 SIM card
    2. 執行指令 CLI>dongle show devices
       
    Cubian*CLI> dongle reload now
      == Parsing '/etc/asterisk/dongle.conf': Found
    [Feb 28 09:50:34] NOTICE[3351]: chan_dongle.c:420 do_monitor_phone: [dongle0] stopping by restart request
        -- [dongle0] Dongle has disconnected
        -- [dongle0] Trying to connect on /dev/ttyUSB2...
        -- [dongle0] Dongle has connected, initializing...
        -- [dongle0] Dongle initialized and ready
    
    Cubian*CLI> dongle show devices
    ID           Group State      RSSI Mode Submode Provider Name  Model      Firmware          IMEI             IMSI             Number
    dongle0      0     Free       26   0    0       7-Mobile       K3520      11.314.17.31.00   353436038500000  466013029000000  Unknown
    

    將 IMEI & IMSI 設定在 dongle.conf

    imei=353436038500000
    imsi=466013029000000
    exten=09891234567 ;這是 SIM 卡的電話號碼
    
    

    套用設定

    Cubian*CLI> dongle reload now
      == Parsing '/etc/asterisk/dongle.conf': Found
    [Feb 28 09:58:14] NOTICE[3355]: chan_dongle.c:420 do_monitor_phone: [dongle0] stopping by restart request
        -- [dongle0] Dongle has disconnected
        -- [dongle0] Trying to connect on /dev/ttyUSB2...
        -- [dongle0] Dongle has connected, initializing...
        -- [dongle0] Dongle initialized and ready
    
    

    檢測狀態

    Cubian*CLI> dongle show device state dongle0
    -------------- Status -------------
      Device                  : dongle0
      State                   : Free
      Audio                   : /dev/ttyUSB1
      Data                    : /dev/ttyUSB2
      Voice                   : Yes
      SMS                     : Yes
      Manufacturer            : huawei
      Model                   : K3520
      Firmware                : 11.314.17.31.00
      IMEI                    : 353436038500000
      IMSI                    : 466013029000000
      GSM Registration Status : Registered, home network
      RSSI                    : 26, -61 dBm
      Mode                    : No Service
      Submode                 : No service
      Provider Name           : 7-Mobile
      Location area code      : 23F2
      Cell ID                 : 2D4A
      Subscriber Number       : Unknown
      SMS Service Center      : +886936000104
      Use UCS-2 encoding      : Yes
      USSD use 7 bit encoding : No
      USSD use UCS-2 decoding : Yes
      Tasks in queue          : 0
      Commands in queue       : 0
      Call Waiting            : Disabled
      Current device state    : start
      Desired device state    : start
      When change state       : now
      Calls/Channels          : 0
        Active                : 0
        Held                  : 0
        Dialing               : 0
        Alerting              : 0
        Incoming              : 0
        Waiting               : 0
        Releasing             : 0
        Initializing          : 0
    
    

    簡易測試 chan_dongle
    從另一支手機撥到這個 SIM 卡的號碼

    #> asterisk -rvvvvvvv
    
    [Feb 28 10:05:36] WARNING[3381][C-00000001]: pbx.c:6646 __ast_pbx_run: Channel 'Dongle/dongle0-0100000001' sent to invalid extension but no invalid handler: context,exten,priority=from-trunk,09891234567,1
    
    

    如果有出現以上訊息,表示電話撥入成功。

    設定 FreePBX

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

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

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

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

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

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

    評測報告

    3G Modem 型號:Vodafone K3520

    評測項目 結果 備註
    Linux 支援-Debian 7.1 PASS  
    電話撥出 PASS  
    電話撥入 PASS  
    撥出後 DTMF 辨識 (SJphone -> 3G Modem -> Vibo 客服 PASS  
    撥入後 DTMF 辨識 (市話 -> 3G Modem -> Asterisk IVR -> SIP 分機) PASS  
    英文簡訊SMS    
    中文簡訊SMS    
    Was this page helpful?
    標籤 (Edit tags)
    • No tags

    文件 1

    文件大小日期附件上傳者 
     cubieboard_3G_Modem.jpg
    無描述
    365.35 KB13:11, 6 Mar 2015alang動作
    查看第3個(總3個)評論: 查看所有
    Hi,
    Thanks for the sharing. Do you encounter any problem during the configuration? Which model of Chan_dongle you are using? Thanks.
    發佈時間 02:30, 6 Jan 2016 ()
    xml0202,
    If I recall correctly the setup process was not difficult if you have complete installed Debian.
    The 3G modem I used in this case is "Vodafone 3G Modem K3520".
    發佈時間 18:17, 10 Jan 2016 ()
    Hi,
    Have you tried on other modem? It looks like the configuration cannot support the latest HuaWei dongle.
    發佈時間 15:01, 18 Jan 2016 ()
    查看第3個(總3個)評論: 查看所有
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core