| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!

View
 

Asterisk com Bluetooth

Page history last edited by PBworks 16 years, 5 months ago

 

Asterisk 1.4 + Bluetooth

 

 

Objetivo: Fazer ligações a partir de um celular, substituir solução com cellfix

 

 

Ambiente de testes:    Open Suse 10.2

 

Bluetooth no linux

 

O daemon do Bluetooth deve estar ativado

 

    # rcbluetooth start -> carregar serviço

    # chkconfig bluetooth on -> na inicialização

 

 

Indetificando o disposotivo Bluetooth no Linux

 

     # lsusb

 Bus 002 Device 001: ID 0000:0000

    Bus 001 Device 002: ID 050d:0012 Belkin Components

    Bus 001 Device 001: ID 0000:0000

 

Verificar se o dispositivo esta ativo.

 

    # hciconfig

    hci0:   Type: USB

    BD Address: 00:0A:3A:6E:1E:DB ACL MTU: 1017:8 SCO MTU: 64:8

    UP RUNNING PSCAN ISCAN - > Indica dispositivo ATIVO e FUNCIONANDO

    RX bytes:391 acl:0 sco:0 events:17 errors:0

    TX bytes:317 acl:0 sco:0 commands:17 errors:0

 

    A estiver  "DOWN" significa que o adaptador foi detectado, mas não está ativo.

    Para ativá-lo:     # hciconfig hci0 up

 

 

Ativando e configurando o serviço

 

Ativando

 

    Ative o bluetooth de seu celular, palm.

 

    Buscar por dispositivos:

 

    # hcitool scan

    Scanning

    00:1C:15:A5:11:96 <SEU DISPOSITIVO PALM, CELULAR OU NOTE)

    Esse número é a identificação MAC do dispositivo que você ativou: note, palm, etc.

 

 

Configurando

 

    Edite o arquivo rfcomm.conf localizado no diretório /etc/bluetooth/:

 

    # vi /etc/bluetooth/rfcomm.conf

 

    Descomente o arquivo, na linha "bind no" troque para "yes", na linha "device aa:bb:cc:dd:ee:ff;"     troque para o número de identificação do seu dispositivo obtido pelo comando "hcitool scan".

 

 

    Edite o arquivo hcid.conf localizado no diretório /etc/bluetooth/:

 

    # vi /etc/bluetooth/hcid.conf

 

    Na sessão HCId options na linha "security user" troque para "security auto".

 

            Alterea a linha passkey, incluindo o PIN do celular e crie a linha abaixo.

            passkey "seu_PIN";

            pin_helper /etc/bluetooth/pin.sh;

    Salve e feche arquivo.

 

    Crie um arquivo /etc/bluetooh com o nome de pin.sh com o conteúdo:

        #!/bin/sh

        echo "PIN:seu_PIN"

 

    Mude as permissões do arquivo /etc/bluetooth/pin.sh

     # chmod 770 /etc/bluetooth/pin.sh

 

    Reinicie o serviço:

 

    # rcbluetooth restart

 

 

Instalação / Compilação do Asterisk

 

 

Dowload arquivos:

 

     Deve-se fazer um download de cada vez, e depois mover a pasta, pois todas criarão um diretório chamado trunk.

 

    Mudar para o diretório de instalação

    # cd /usr/src

    # svn checkout http://svn.digium.com/svn/asterisk/trunk/

 

    Após o download mover a pasta.

    # mv trunk asterisk

 

    # svn checkout http://svn.digium.com/svn/asterisk-addons/trunk/

    # mv trunk asterisk-addons

 

    # svn checkout http://svn.digium.com/svn/libpri/trunk/

    # mv trunk libpri

 

    # svn checkout http://svn.digium.com/svn/zaptel/trunk/

    # mv trunk zaptel

 

    Os arquivos de som serão usados os da versão corrente, neste momento.

    # wget http://www.digium.com/elqNow/elqRedir.htm?ref=http://downloads.digium.com/pub/asterisk/releases/asterisk-sounds-1.2.1.tar.gz

 

    Descompactar o arquivo

    # tar xvzf asterisk-sounds-1.2.1.tar.gz

 

 

Compilação do asterisk

 

   Primeiro compilar a libpri

    # cd /usr/src/libpri

    # make clean

    # make

    # make install    

 

  Depois compilar o zaptel

    # cd /usr/src/zaptel

    # make clean

    # make

    # make install

    # make menuconfig

 

  Logo após compilar o asterisk

    # cd /usr/src/asterisk

    # make clean

    # make

    # make install

    # make samples     ===> Para criar os arquivos de configuração de modelo

 

  Agora compilaremos o asterisk-addons, com suporte ao chan_mobile, módulo que atuará nas ligações com telefones celulares.

    # cd /usr/src/asterisk-addons

    # ./configure

    # make menuselect  ===> Verificar se o módulo chan_mobile está selocionado

    # make

    # make install

 

  E por último vamos instalar os arquivos de som

    # cd /usr/src/asterisk-sounds

    # make clean

    # make install

 

 

Configuração do Asterisk

 

/etc/asterisk/mobile.conf

 

    O arquivo de configuração para os dispositivos móveis.

     Nele é definido configurações gerais, dos adaptadores e telefones.

 

    [general]                                    ; Configurações gerais e globais.

    interval=30                                 ; Define o intervalo de tempo para conectar dispositivos

 

    [adapter]                                    ; Define os adaptadores Bluetooth existentes

    id=Belkin                                     ; Identificação do adaptador bluetooth

    address=00:0A:3A:6E:1E:DB      ; MAC Address do adaptador bluetooth

 

    [T610]                                         ; Identificação do telefone

    address=00:0A:D9:81:D1:4B      ; MAC Address do telefone

    port=6                                         ; Porta para o Asterisk, obtida com móbile search no CLI

    context=default                           ; Contexto

    adapter=Belkin                            ; Adaptador bluetooh a qual o telefone será conectado

    group=1                                      ; Grupos de troncos

 

 

Arquivos de configuração do teste:

 

/etc/bluetooh/hcid.conf

 

#

# HCI daemon configuration file.

#

 

# HCId options

options {

              # Automatically initialize new devices

              autoinit yes;

              security auto;

 

              # Pairing mode

              pairing multi;

 

              # Default PIN code for incoming connections

              # passkey "seu_PIN";

              pin_helper /etc/bluetooth/pin.sh;

}

 

# Default settings for HCI devices

device {

            # Local device name

            name "BlueZ %h (%d)";

 

            # Local device class

            class 0x7e0100;

 

            # Inquiry and Page scan

            # valid parameters: enable | disable

            iscan enable;

            pscan enable;

 

            # Default link mode

            lm accept;

 

            # Default link policy

lp rswitch,hold,sniff,park;

 

}

 

 

/etc/bluetoth/pin.sh

 

#!/bin/sh

echo "PIN:seu_PIN"

 

 

/etc/Bluetooth/rfcomm.conf

 

#

# RFCOMM configuration file.

#

 

rfcomm0 {

#       # Automatically bind the device at startup

        bind yes;

#

#       # Bluetooth address of the device

        device 00:0A:D9:81:D1:4B;

#

#       # RFCOMM channel for the connection

        channel 1;

#

#       # Description of the connection

        comment "T610";

}

 

 

/etc/asterisk/extensions.conf

 

; extensions.conf - the Asterisk dial plan

;

;

; The "General" category is for certain variables.

;

[general]

 

 

[default]

 

exten => XXXX,1,Awnser

exten => XXXX,n,Dial(SIP/${EXTEN})

exten => XXXX,n,Hangup

 

; O básico do comando Dial é que a tecnologia é MOBILE

 

exten => _XXXXXXXX,1,Dial(MOBILE/g1/${EXTEN})

; pode-se também ligar através de um aparelho específico ao invés de um grupo de troncos

;exten => _XXXXXXXX,1,Dial(MOBILE/T610/${EXTEN})

exten => _XXXXXXXX,n,Hangup

 

 

No Console do Asterisk (CLI)

 

Status do dispositivo

 

CLI> mobile show devices

ID              Address                   Group Adapter         Connected     State SMS

T610         00:0A:D9:81:D1:4B     1         Belkin              Yes           Free  No

 

    Mostra o telephone conectado e disponível para o uso

 

 

CLI> mobile search

All Bluetooth adapters are in use at this time.

 

    Somente um telephone pode ser conectado a cada adaptador Bluetooth, mas é possível instalar vários adaptadores bluetooth no  micro

 

 

Obs.: Caso tenha dificuldade de emparelhar os dispositivos Bluetooth (Adaptador e Celular) pode-se usar o seguinte commando.

    # passkey-agent --default [PIN]

Comments (0)

You don't have permission to comment on this page.