Was this page helpful?

Configure chan-mobile on RasPBX

    系統環境

    • raspbx-28-01-2017
    • Asterisk 13.13.1
    • FreePBX 13.0.190.11
    • HTC A9
    • SONY Xperia TX

    HTCA9-.pngsonyXperiaTX.jpegUSB_Bluetooth_Dongle.jpg

    確認 BT Dongle 是否被支援

    # lsusb
    Bus 001 Device 004: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

    藍芽套件安裝

    apt-get install bluetooth bluez
    

    NOTE:

    檢查 systemctl status bluetooth 狀態如下:

    Sep 19 20:35:55 raspbx bluetoothd[425]: Starting SDP server
    Sep 19 20:35:55 raspbx bluetoothd[425]: Bluetooth management interface 1.14 initialized
    Sep 19 20:35:55 raspbx bluetoothd[425]: Sap driver initialization failed.
    Sep 19 20:35:55 raspbx bluetoothd[425]: sap-server: Operation not permitted (1)

    忽略 failed 訊息,這不影響藍芽運作。

    與手機配對

    NOTE: 先開啟手機的藍芽,並設定為可接收其他裝置掃描

    bluetoothctl
    
    [bluetooth]# list
    Controller 00:15:83:0D:70:5C raspbx [default]       <== 這是USB 藍芽接收器的位址
    
    [bluetooth]# scan on
    正在掃描,等一下
    
    [bluetooth]# scan on
    Discovery started
    [CHG] Controller 00:15:83:0D:70:5C Discovering: yes
    [NEW] Device 00:9E:C8:93:2C:9A MIBOX3
    [NEW] Device 04:C2:3E:B1:DF:47 04-C2-3E-B1-DF-47
    [CHG] Device 04:C2:3E:B1:DF:47 LegacyPairing: no
    [CHG] Device 04:C2:3E:B1:DF:47 Name: HTC A9
    [CHG] Device 04:C2:3E:B1:DF:47 Alias: HTC A9         <== 這是要配對手機的位址
    [CHG] Device 7C:61:93:DA:81:76 Connected: yes
    [CHG] Device 7C:61:93:DA:81:76 Connected: no
    [CHG] Device 04:C2:3E:B1:DF:47 LegacyPairing: yes
    
    
    [bluetooth]# agent on
    
    [bluetooth]# default-agent
    
    [bluetooth]# discoverable on
    
    [bluetooth]# pairable on
    
    [bluetooth]# pair 04:C2:3E:B1:DF:47
    Attempting to pair with 04:C2:3E:B1:DF:47
    [CHG] Device 04:C2:3E:B1:DF:47 Connected: yes
    Request PIN code
    [agent] Enter PIN code: 0000                    <== 隨意輸入,同時間手機端也必須輸入一樣的密碼
    [CHG] Device 04:C2:3E:B1:DF:47 Modalias: bluetooth:v000Fp1200d1436
    [CHG] Device 04:C2:3E:B1:DF:47 UUIDs:
        00001105-0000-1000-8000-00805f9b34fb
        0000110a-0000-1000-8000-00805f9b34fb
        0000110c-0000-1000-8000-00805f9b34fb
        0000110e-0000-1000-8000-00805f9b34fb
        00001112-0000-1000-8000-00805f9b34fb
        00001115-0000-1000-8000-00805f9b34fb
        00001116-0000-1000-8000-00805f9b34fb
        0000111f-0000-1000-8000-00805f9b34fb
        0000112d-0000-1000-8000-00805f9b34fb
        0000112f-0000-1000-8000-00805f9b34fb
        00001132-0000-1000-8000-00805f9b34fb
        00001200-0000-1000-8000-00805f9b34fb
        00001800-0000-1000-8000-00805f9b34fb
        00001801-0000-1000-8000-00805f9b34fb
    [CHG] Device 04:C2:3E:B1:DF:47 Paired: yes
    Pairing successful
    

    TIP:

    Failed to pair: org.bluez.Error.AuthenticationFailed 手機端的密碼與主機端不同

    移除配對的裝置

    [bluetooth]# devices
    Device D0:51:62:43:90:09 Xperia TX
    
    [bluetooth]# remove D0:51:62:43:90:09
    [DEL] Device D0:51:62:43:90:09 Xperia TX
    Device has been removed
    

    設定 chan_mobile

    vi /etc/asterisk/chan_mobile.conf

    [general]
    interval=30		; Number of seconds between trying to connect to devices. 
    
    ; The following is a list of adapters we use.
    ; id must be unique and address is the bdaddr of the adapter from hciconfig.
    ; Each adapter may only have one device (headset or phone) connected at a time.
    ; Add an [adapter] entry for each adapter you have.
    
    [adapter]
    id=bt0
    address=00:15:83:0D:70:5C
    ;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
    			; its a bug in the bluetooth adapter firmware, enabling this will compensate for it.
    			; default is no.
    
    ;[adapter]
    ;id=bt1
    ;address=00:80:C8:35:52:78
    
    
    [SONYTX]
    address=D0:51:62:43:90:09	; the address of the phone
    port=4				; the rfcomm port number (from mobile search)
    context=incoming-mobile		; dialplan context for incoming calls
    adapter=bt0			; adapter to use
    group=1				; this phone is in channel group 1
    ;sms=no				; support SMS, defaults to yes
    ;nocallsetup=yes		; set this only if your phone reports that it supports call progress notification, but does not do it. Motorola L6 for example.
    
    

    TIP:

    一個 adapter 對應一個 BT dongle,只能連接一個手機裝置

    bt0 第一個 BT dongle

    raspbx*CLI> module load chan_mobile.so
    
    raspbx*CLI> mobile search
    Address           Name                           Usable Type    Port
    04:C2:3E:B1:DF:47 HTC A9                         Yes    Phone   3
    00:9E:C8:93:2C:9A MIBOX3                         Yes    Phone   3
    

    TIP

    如果出現 No Bluetooth Cell / Mobile devices found. ,檢查手機的藍芽連線是否開啟,並且開啟接受掃描。

    修改 /etc/asterisk/chan_mobile.conf

    將 port 改成 3

    重啟 Asterisk 套用新設定

    asterisk -rx "core restart now"
    

    確認設定
    NOTE: Connected 必須是 Yes,否則就是連接失敗。(實際與 HTC Desire S 作配對,始終連接失敗,但使用其他手機正常。)

    [email protected]:~# asterisk -rx "mobile show devices"
    ID              Address           Group Adapter         Connected State      SMS
    HTCA9           04:C2:3E:B1:DF:47 1     blue            Yes       Free       No
    

    F.A.Q

    Q: 如何連接多個手機?

    A: 一個 BT Dongle 只能與一支手機做配對,所以 RasPi 必須使用多個 BT Dongles,視可用 USB port 數量而定。

    另外,坊間的 BT Dongle 有些廠牌會使用同一組 BT address,這會影響到 chan_mobile 的運作,解決方式有二:

    1. 使用不同廠牌的 BT Dongles
    2. 修改 BT address

     

    Was this page helpful?
    標籤 (Edit tags)
    • No tags

    文件 2

    文件大小日期附件上傳者 
     HTCA9-.png
    HTC One A9
    36.29 KB14:52, 12 Mar 2017alang動作
     sonyXperiaTX.jpeg
    SONY Xperia TX
    17.72 KB14:48, 12 Mar 2017alang動作
    您必須 登入 才能發佈評論。
    Powered by MindTouch Core