Was this page helpful?

Asterisk 使用藍芽連接手機 - chan mobile

    [ 本頁短網址: http://tinyurl.com/qc7b7j8 ]
    Asterisk 主機可以透過內建的藍芽或外接一個 USB 的藍芽接收器,與有支援藍芽的手機作連結,且可以作電話撥入及撥出,就像 FXO 那樣的應用模式。
    使用到的 Asterisk 模組稱為 chan_mobile。

    文章列表:

    系統環境
    • PIAF 1.7.5.5, BRONZE
    • Linux 2.6.18-194.26
    • Asterisk 1.6.2.17.2
    • Asterisk-addons 1.6.2.3
    • IVT BlueSoleil USB Bluetooth Dongle
    • Nokia E65
    • 硬體相容性列表在參考連結
       

    USB_Bluetooth_Dongle.jpgNokia-E65.jpg

    bluez 套件列表

    [email protected]:~ $ rpm -qa | grep -i bluez
    bluez-gnome-0.5-5.fc6
    bluez-libs-3.7-1.1
    bluez-libs-devel-3.7-1.1
    bluez-utils-3.7-2.2.el5.centos
    
    安裝 USB Bluetooth Dongle

    確定 bluetooth 服務啟動

    # chkconfig bluetooth on
    # service bluetooth start 

    插上 USB Bluetooth Dongle

    # dmesg
    ...
    ...
    usb 1-1: new full speed USB device using uhci_hcd and address 2
    usb 1-1: device descriptor read/64, error -71
    usb 1-1: configuration #1 chosen from 1 choice
    Bluetooth: HCI USB driver ver 2.9
    usbcore: registered new driver hci_usb
    
    # hcitool dev
    Devices:
            hci0    00:15:83:0B:88:D0
    
    # lsusb
    Bus 001 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
    

    註:藍芽接受器的硬體位址是 00:15:83:0B:88:D0

    設定藍芽接收器

    # cd /etc/bluetooth/
    # mv hcid.conf hcid.conf.bak
    # vi hcid.conf 
    

    hcid.conf:

    # HCId options
    options {
                 autoinit yes;
                 security auto;
                 pairing multi;
                 passkey "1234";
    }
    device {
               name "Asterisk PBX";
               class 0x3e0100;
               iscan enable; pscan enable;
               discovto 0;
               lm accept;
               lp rswitch,hold,sniff,park;
    }

    重啟 bluetooth 服務

    # service bluetooth stop
    # service bluetooth start 
    
    編譯安裝 chan_mobile.so 模組
    # cd /usr/arc/asterisk-addons
    # make distclean
    # ./configure --with-bluetooth
    # make menuselect 
    

    Channel Drivers > [*] chan_mobile > Save & Exit

    # make
    # amportal stop
    # make install  
    # amportal start
    

    檢查 chan_mobile 模組

    # asterisk -rx "module show like chan_mobile"
    Module                         Description                              Use Count
    chan_mobile.so                 Bluetooth Mobile Device Channel Driver   0      
    1 modules loaded
    

    F.A.Q

    編譯 asterisk-addons 時出現錯誤:configure: *** The Bluetooth Support installation on this system appears to be broken.
    Ans: 安裝套件 bluez-libs-devel。

    設定 Asterisk

    編輯 /etc/asterisk/mobile.conf,將藍芽接收器的硬體位址:00:15:83:0B:88:D0 輸入。

    [adapter]
    id=blue
    address=00:15:83:0B:88:D0
    ;forcemaster=yes        ; attempt to force adapter into master mode. default is no.
    ;alignmentdetection=yes ; enable this if you sometimes get 'white noise' on asterisk side of the call
    

    為了要使藍芽接受器可以被其他的藍芽手機裝置搜尋到,請執行以下指令

    # dbus-send --system --type=method_call --print-reply --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetMode string:discoverable
    開啟手機的藍芽功能及配對

    以筆者的手機 Nokia E65 為例:

    選單 > 連線方式 > 藍芽 >
    藍芽 --- [開]
    本機名稱 --- [E65]

    選項 > 新配對裝置
    搜尋到 Asterisk PBX,進行配對連接,輸入 PIN '1234'

    F.A.Q

    手機一直無法搜尋到 Asterisk 主機的藍芽?
    Ans: 請重新檢查主機上的藍芽接受器的設定 hcid.conf,且修改後,除了要重啟 bluetooth 服務外,還要執行一次 dbus-send --system....... 的這行指令,詳細看以上的步驟。

    從藍芽接受器搜尋 Nokia E65
    # hcitool scan
    Scanning ...
            00:17:E6:9C:B0:CC       E65
    

    註:手機的藍芽位址:00:17:E6:9C:B0:CC

    設定 Asterisk

    登入 Asterisk CLI 模式,搜尋手機的藍芽。

    pbx*CLI> mobile search
    00:17:E6:9C:B0:CC E65                            Yes    Phone   28
    Address           Name                           Usable Type    Port
    

    註:搜尋到手機的藍芽後,記住硬體位址及 port。

    編輯 /etc/asterisk/mobile.conf

    ; My Mobile Phone
    [NokiaE65]
    address=00:17:E6:9C:B0:CC
    port=28
    context=from-bt-gsm
    adapter=blue
    group=1
    

    Notes:

    * port 必須以搜尋到資訊為主。
    * context 必須 inbound 設定相同。
    * 名稱 不可以包含有 dash,否則會影響到 inbound 的運作,例如 NokiaE65。

    重啟 Asterisk 服務

    # amportal stop
    # amportal start 
    

    檢查設定:
    如果與手機藍芽連線正常,訊息顯示:

    pbx*CLI> mobile search
    All Bluetooth adapters are in use at this time.
    
    pbx*CLI> mobile show devices
    ID              Address           Group Adapter         Connected State SMS
    E65             00:17:E6:9C:B0:CC 1     blue            Yes       Free  No
    

    如果有偵測到手機的藍芽,但無法連線,訊息顯示:

    pbx*CLI> mobile search
    Address           Name                           Usable Type    Port
    00:17:E6:9C:B0:CC E65                            Yes    Phone   28
        -- Bluetooth Device NokiaE65 has connected, initializing...
        -- Error initializing Bluetooth device NokiaE65.
        -- Bluetooth Device NokiaE65 has disconnected.
    

    會不斷出現初始化錯誤,請檢查 mobile.conf 的 port 是否正確。

    如果偵測不到周圍的藍芽裝置,訊息顯示:

    No Bluetooth Cell / Mobile devices found.

    請檢查手機的藍芽是否已開啟,且已開啟可被掃描的功能。

    註:執行 mobile search 時,需要一點掃描的時間。

    Dial Outbound 設定

    新增 Custom Trunk
    FreePBX > Trunks > Add Custom Trunk

    Trunk Description: Nokia E65
    Outbound Caller ID: <手機號碼>
    Custom Dial String: Mobile/NokiaE65/$OUTNUM$

    註:NokiaE65 必須與 mobile.conf 的內容相同。

    新增 Outbound Route
    FreePBX > Outbound Routes > Add Roue

    Route Name: MyE65
    Dial Patterns: 009|.
    Trunk Sequence: Mobile/NokiaE65/$OUTNUM$

    Inbound 設定

    編輯 /etc/asterisk/extensions_custom.conf,增加以下內容:

    [from-bt-gsm]
    exten => s,1,Noop(Entering from-bt-gsm with CHANNEL == ${CHANNEL})
    exten => s,n,GotoIf($["${CHANNEL:0:6}"="Mobile"]?mobileok:notmobile)
    exten => s,n(notmobile),Macro(Hangupcall,dummy)
    exten => s,n(mobileok),Noop(Is a Mobile Channel)
    exten => s,n,Set(CHAN=${CHANNEL:7})
    exten => s,n,Set(DID=${CUT(CHAN,-,1)})
    exten => s,n,Noop(The complete channel variable is ${CHAN}, please make sure the name you added into mobile.conf doesn't contain dash symbolic. )
    exten => s,n,Goto(from-pstn,${DID},1)
    exten => s,n,Hangup
    

    存檔後,執行指令套用:
    #asterisk -rx "dialplan reload"

    新增 Inbound Route
    FreePBX > Inbound Routes > Add Incoming Route

    Description = from GSM
    DID Number = <mobile.conf 的名稱,例如 NokiaE65>
    Set Destination =<whatever you wanted>

    評測報告

    手機型號:Nokia E65
    USB藍芽接收器:IVT BlueSoleil USB Bluetooth Dongle

    評測項目 結果 備註
    藍芽連線 PASS  
    電話撥出 PASS  
    電話撥入 PASS  
    撥出後 DTMF 辨識 (SJphone -> Nokia E65 -> Vibo 客服 PASS  
    撥入後 DTMF 辨識 (市話 -> Nokia E65 -> Asterisk IVR -> SIP 分機) PASS  
    簡訊SMS unsupported  

     

    從 SJPhone 撥到 Vibo 客服,channel 狀況:

    pbx*CLI> sip show channels
    Peer             User/ANR         Call ID          Format           Hold     Last Message    Expiry
    10.1.1.201       100              4826588A-8950-4  0x4 (ulaw)       No       Rx: ACK
    
    pbx*CLI> core show channels verbose
    Channel              Context              Extension        Prio State   Application  Data                      CallerID        Duration Accountcode BridgedTo
    Mobile/E65-1721      from-bt-gsm                              1 Up      AppDial      (Outgoing Line)           009123          00:00:23             SIP/100-00000001
    SIP/100-00000001     macro-dialout-trunk  s                  26 Up      Dial         Mobile/E65/123,300,       8261            00:00:23             Mobile/E65-1721
    2 active channels
    1 active call
    
    Was this page helpful?
    標籤 (Edit tags)
    • No tags

    文件 2

    文件大小日期附件上傳者 
     Nokia-E65.jpg
    Nokia E65
    33.35 KB12:00, 2 May 2011alang動作
     USB_Bluetooth_Dongle.jpg
    USB Bluetooth Dongle
    12.06 KB11:13, 2 May 2011alang動作
    查看第2個(總2個)評論: 查看所有
    Hello ... would like to ask about the above program is complete?
    發佈時間 20:12, 5 May 2011 ()
    Yes, welcome to post your questions on our mail-list at https://sites.google.com/site/asterisktaiwan/ or email to [email protected]
    Thank you.
    發佈時間 09:05, 6 May 2011 ()
    查看第2個(總2個)評論: 查看所有
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core