![Page 1: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/1.jpg)
Bluetooth
Ana Cristina Benso da Silva Andrei Oliveira da SilvaFabrício D’Avila Cabral
CPSE – Centro de Pesquisa em Software EmbarcadoFACIN/PUCRS – Faculdade de Informática
![Page 2: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/2.jpg)
Roteiro
Introdução Redes Wireless
O mundo Wireless Bluetooth - Visão Teórica
HistóricoFuncionamentoPilha de Protocolos
Bluetooth –Visão PráticaInstalando e Configurando Dispositivos
BluetoothBlueZ – Pilha Bluetooth para LinuxExemplos de Aplicações
![Page 3: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/3.jpg)
Introdução
CPSE – Centro de Pesquisa em Software EmbarcadosIniciou atividades em 2002Cooperação PUCRS/ HP BrasilFoco
• Redes sem fio
• Computação ubíqua
• Software embarcado
• Linguagens de representação e design de documentos digitais
Tecnologias
![Page 4: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/4.jpg)
Redes Wireless
Internet 90´sGrande acontecimentoEliminou a barreira da distância geográficaAlteração de paradigmas de
disponibilização e obtenção de informações
![Page 5: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/5.jpg)
Redes Wireless
Redes Wireless – Século XXINova quebra de paradigmasDesafios
• Tornar a tecnologia acessível a maioria dos usuários
• Migração de sistemas orientados a voz para sistemas orientados a dados
• IP Networks
![Page 6: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/6.jpg)
Visão do Mundo Wireless
1980 1990 2000 2010
GSM
2G 3G 4G
TDMA
CDMASistema
Analógico
Telefonia Celular
1G
Serviços
de Voz
Serviços IP
Dados
UTMS
WLAN
IEEE 802.11a
BluetoothIEEE 802.11b
WPAN
IPv6
Wireless
Broadband
(next generation)
Semantic Aware
ServicesCyberWorl
d???
TCP/IP
Interconexão de
Redes
Internet
![Page 7: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/7.jpg)
Wireless LAN (WLAN)
Bluetooth2.4 GHz – ISMConexões de Curto Alcance
IEEE 802.11b2.4 GHz – ISM11 Mbps
IEEE 802.11a5 GHz50 Mbps
![Page 8: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/8.jpg)
Bluetooth – Visão Teórica
HistóricoHarald Blåtand (Bluetooth)
• Rei Viking Dinamarquês
• Século X (940 a 981)
• Habilidade de fazer as pessoas se comunicarem
• Uniu e controlou a Dinamarca e Noruega
• Costume de comer blueberries (arando ou uva-do-monte)
![Page 9: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/9.jpg)
Bluetooth - Histórico
1998 Bluetooth SIG (Special Interest Group)
• 3Com, Agere, Ericsson, IBM, Intel, Microsoft, Motorola, Nokia, Toshiba,...
1999 Primeira versão da especificação
2001 Primeiros produtos com BluetoothBluetooth Academy
• Ericsson +Teleca Comtec
![Page 10: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/10.jpg)
Bluetooth - Aplicações
Substituição de cabos
Redes caseiras
Redes em escritórios
![Page 11: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/11.jpg)
Bluetooth – Aplicações
Internet Bridge
Transferência de Arquivos
Acesso a Serviços
![Page 12: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/12.jpg)
Bluetooth - Funcionamento
Topologias Piconet Scatternet
![Page 13: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/13.jpg)
Estabelecendo Conexão
Inquiry Procura por dispositivos Estados:
• Inquiry• Inquiry Scan• Inquiry Response
PageEstabelece conexões Estados:
• Page• Page Scan
STANDBY
CONNECTION
PAGE
PAGE SCAN
INQUIRY SCAN
INQUIRY
MASTER
RESPONSE
SLAVE
RESPONSE
INQUIRY
RESPONSE
![Page 14: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/14.jpg)
Bluetooth – Pilha de Protocolos
Bluetooth Radio
Baseband
AudioL2CAP
SDP
LMP
TCS BIN
OBEX WAP
UDP/TCP
IP
PPP
RFCOMM
AT- Commands
Host Controller Interface
![Page 15: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/15.jpg)
Bluetooth - Radio
Nível Físico Rádio Freqüência
2.4 GHZEspectro
• 2400 MHz – 2483 MHz
• 2465 MHz – 2483 MHz
Hopping Sequences• 5 canais com 32 hops (79 Mhz)
• 5 canais com 16 hops (23 Mhz)
![Page 16: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/16.jpg)
Bluetooth - Radio
Potência do Sinal100 m – 100mW10 m – 2.5 mW10 cm – 1 mW
Canais suportados simultaneamente1 canal de dados assíncrono3 canais de voz síncronos1 canal de dados assíncrono + 1 canal de
voz síncrono Canal de Voz Síncrono – 64 Kbps
Canal Assíncronos Simétricos – 433.9 Kbps
Canal Assíncrono Assimétrico – 732.2 Kbps
Canal de Voz Síncrono – 64 Kbps
Canal Assíncronos Simétricos – 433.9 Kbps
Canal Assíncrono Assimétrico – 732.2 Kbps
![Page 17: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/17.jpg)
Bluetooth - Baseband
Conexões físicas como canais lógicos Funções
Gerenciar o estabelecimento de conexõesControlar FluxoControlar Erros de TransmissãoEndereçar os dispositivos com Bluetooth
Address Controlar a Segurança
![Page 18: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/18.jpg)
Baseband - Enlaces
Enlaces entre Mestre e EscravoACL (Asynchronous Connectionless Link)
• Ponto-a-Multiponto
• Tem Retransmissão
SCO (Synchronous Connection Oriented Link)• Ponto-a-Ponto
• Voz
• Não tem retransmissão
![Page 19: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/19.jpg)
Baseband – Canais Lógicos
LM – Link ManagerTransporte de informações de controle entre os
dispositivos mestre e escravo LC – Link Control
Transporte de informações de controle de fluxo e correção de erros
UA – User AynchronousTransporte de dados do usuário sobre L2CAP
UI – User IsochronousTransporte de serviços isócronos sobre L2CAP
US – User SynchronousTransporte de serviços síncronos em enlaces do tipo
SCO.
![Page 20: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/20.jpg)
Baseband – Formato do Pacote
Access CodeChannel Access Code (CAC) – Piconet IDDevice Code Access (DCA) – PagingInquiry Access Code (IAC) – Inquiry
HeaderAM_ADDRTypeARQNSEQNHEC
Access Code Header Payload
LSB MSB72 54 0-2745
![Page 21: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/21.jpg)
Baseband – Formato do Pacote
FECForward Error Correction
Enlaces SCO e ACLID, NULL, POLL, FHS, DM1
Enlaces SCO somenteHV1, HV2, HV3, DV
Enlaces ACL somente DH1, AUX1, DM3, DM5, DH5
![Page 22: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/22.jpg)
Baseband - Endereços
BD_ADDRBluetooth Address6 bytes
AM_ADDREndereço do dispositivo escravo3 Bits
PM_ADDR e AR_ADDREndereço especial para estações em
parked modePM_ADDR: mestre endereça o escravoAR_ADDR: escravo utiliza para determinar
janela de acesso
![Page 23: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/23.jpg)
Baseband – Modos de Operação Active mode
Dispositivo está ativo e sincronizado como canal
Sniff modeEstado de economia de energiaEscutando no canal com taxa menor
Park ModeDispositivo conectado a piconet, que participa
ocasionalmente Hold Mode
Dispositivo reduz a participação, de acordo com a solicitação do mestre ou de sua vontade
![Page 24: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/24.jpg)
Bluetooth - LMP
Link ManagerComponente de Software
• Controle de comunicação, autenticação e configuração
LMP - Protocolo• 55 PDU’s
– LMP_encryption_mode_req
– LMP_version_res
– ...
Link Controller - hardware
![Page 25: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/25.jpg)
Bluetooth - HCI
Host Controller Interface Interface para os
comandos LMP e Baseband
HCI Driver - software HCI Firmware - hardware HCI Controller Transport
Layer - comunicação• USB
• UART
• RS232
![Page 26: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/26.jpg)
Bluetooth - L2CAP
Logical Link Control and Adaptation Protocol Identifica e roteia mensagens para os
níveis mais altosCodifica e decodifica os pacotes de dadosSegmenta pacotes para o formato
BasebandDemultiplexar e redirecionar
• RFCOMM
• SDP
• Aplicações sobre L2CAP
![Page 27: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/27.jpg)
Bluetooth - RFCOMM
Emula conexões por portas seriais Canais com até 60 portas simuladas Controle de fluxo de dados para retransmitir dados para os níveis mais altos
![Page 28: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/28.jpg)
Bluetooth - SDP
Service Discovery Protocol Divulgação de serviços em uma rede Bluetooth
Cliente/servidor L2CAP
??!! SDPDevice
![Page 29: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/29.jpg)
Bluetooth - Perfis
Definidos pelo SIG Aplicações que utilizam os níveis superiores da pilha de protocolosPerfis de uso geral: perfis básicos que dão suporte a outros perfis
Perfis de uso específico: implementam protocolos para modelos de uso
![Page 30: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/30.jpg)
Bluetooth - Perfis
Modelos de usoCordless DesktopInternet Bridge, LAN accessFile Transfer, Automatic Synchronizer,
Instant PostcardBriefcase Trick, Forbidden MessageInteractive Conference3-in-1 PhoneUltimate Headset, PC Speaker PhoneHands-Free Car Kit
![Page 31: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/31.jpg)
Bluetooth – Perfis Básicos
Serial Port Profile:emula sinais de
transmissão de uma porta serial
General Object Exchange Profile:transferência de
dados utiliza SPP
Generic Access Profile:informações
básicas do dispositivo
Service Discovery Application Profile:Aplicações que
utilizam SDP - como usar e comportamento
![Page 32: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/32.jpg)
Bluetooth – Perfis Uso Específico
Synchronization Profile:Informações
Troca Atualização
Object Push Profile :Troca de:
DadosObjetos
LAN Access Profile:ponto de acesso
LANTCP/IP SPP
Dial-up Networking Profile:Modem - TCP/IPInternet sem fio
![Page 33: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/33.jpg)
Bluetooth – Perfis Uso Específico
Headset Profile:Input/output
remotoÁudio
Fax Profile:Fax modem sem
fioManda/recebe msg
Cordless Telephony Profile:“Gateway” de
telefonia
Intercom Profile:“walkie-talkie”
![Page 34: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/34.jpg)
Bluetooth – Perfis Adicionais
Video Remote Distribution Profile :Vídeo
alta qualidadeACL
Basic Printing Profile:GOEPvCards,...
Extended Service Discovery Profile:SDP+UPnP
Advanced Audio Distribution Profile:Audio
alta qualidadeACL
![Page 35: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/35.jpg)
Bluetooth -Hardware
Dispositivos:
![Page 36: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/36.jpg)
Bluetooth - Software
Software Proprietários (3com, Toshiba,...)Drivers
DesenvolvimentoBlueZ (http://bluez.sourceforge.net/) Stack LinuxAffix (http://affix.sourceforge.net/) Stack LinuxAtinav (http://www.atinav.com/download.htm) SDK
C e JavaImpronto (http://www.rococosoft.com/) SDK Java
![Page 37: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/37.jpg)
Bluetooth – Visão Prática
Instalação Configuração Programação Aplicações
![Page 38: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/38.jpg)
Aspectos Práticos
BlueZ – Pilha Oficial LinuxGPLDocumentaçãoAPIProgramaçãoPerfis
![Page 39: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/39.jpg)
BlueZ - Instalação
Arquivos • Implementação das bibliotecas básicas
• Implementação de perfis
• Aplicações de apoio
• Instalação– rpm –ivh *.rpm
• Distribuições– Red Hat 9.0
– Mandrake 9.1
• Kernel– 2.4.20
– 2.4.21
BlueZ-libs-2.4-1.i386.rpm BlueZ-utils-2.3-1.i386.rpm BlueZ-sdp-1.2-1.i386.rpm BlueZ-hcidump-1.5-1.i386.rpmBlueZ-pan-1.1-1.i386.rpmBlueZ-bluefw-1.0.i386.rpm
http://bluez.sourceforge.net/download/redhat/
![Page 40: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/40.jpg)
BlueZ - Módulos
Carregar no kernel Editar /etc/modules.conf :
alias net-pf-31 blueZ - inicia a pilha BlueZalias bt-proto-0 l2cap - inicia o protocolo L2CAPalias bt-proto-2 sco - inicia o protocolo SCOalias bt-proto-3 rfcomm - inicia o protocolo RFCOMM
![Page 41: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/41.jpg)
BlueZ - Módulos
Ativar módulos Editar /etc/rc.local:
modprobe bluez - pilha BlueZmodprobe hci_usb - interface USBmodprobe ppp_asyncmodprobe ppp_deflatemodprobe bnep - Ativa protocolo BNEPhcid - HCIhciconfig hci0 up - Inicia o dispositivo bluetooth
![Page 42: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/42.jpg)
BlueZ - Módulos
Exemplo de Script para iniciar os módulos:#!/bin/sh
if [ "$1" == "restart" ]
then
echo "Killing dund process..."
killall dund
echo "Killing sdpd process..."
killall sdpd
echo "Killing hcid process..."
killall hcid
fi
echo "Starting the BLUEZ modules and services..."
modprobe bluez
modprobe hci_usb
modprobe ppp_async
modprobe ppp_deflate
modprobe bnep
hcid -f /etc/bluetooth/hcid.conf
hciconfig hci0 up
sdpd
echo "Starting dund..."
sleep 2
dund --listen --channel 1 noauth
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j ACCEPT
![Page 43: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/43.jpg)
BlueZ - Aplicações
Ferramentas de auxílio:hciconfig
• Configuração (nome, classe,...)
hcitool• scan
• Inquiry
sdptool• browse
l2ping• Teste de conexão
![Page 44: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/44.jpg)
BlueZ - Aplicações
LANDisponibiliza um serviço de LAN Access
PointConfigurando o DUND:
• Criando os dispositivos /dev/rfcommX– Máximo 7 dispositivos:mknod –m 666 /dev/rfcomm0 c 216 0
mknod –m 666 /dev/rfcomm1 c 216 1
mknod –m 666 /dev/rfcomm2 c 216 2
mknod –m 666 /dev/rfcomm3 c 216 3
mknod –m 666 /dev/rfcomm4 c 216 4
mknod –m 666 /dev/rfcomm5 c 216 5
mknod –m 666 /dev/rfcomm6 c 216 6
![Page 45: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/45.jpg)
BlueZ - Aplicações
LANConfigurando o DUND (cont.):
• Configurando o PPP– /etc/ppp/options
noauth
local
noipdefault
proxyarp
ms-dns 10.0.0.1
netmask 255.255.255.0
connect "sleep 2; echo -n CLIENTSERVER"
![Page 46: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/46.jpg)
BlueZ - Aplicações
LANConfigurando o DUND (cont.):
– Criar um arquivo para cada dispositivo rfcomm contendo IP local e o IP a ser atribuido pro dispositivo que se conectou:
– /etc/ppp/options.rfcommX:
10.0.0.1:10.0.0.2IP LOCAL IP REMOTO
![Page 47: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/47.jpg)
BlueZ - Aplicações
LANConfigurando o DUND (cont.):
• Servidor:
• Exemplo tirado do script mostrado anteriormente:
#!/bin/sh
echo "Starting dund..."
sleep 2
dund --listen --channel 1 noauth
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -o eth0 -j ACCEPT
![Page 48: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/48.jpg)
BlueZ - Aplicações
LANConfigurando o DUND (cont.):
• Cliente:
dund –-connect xx:xx:xx:xx:xx:xx --channel 1 --msdun
Endereço Bluetooth da máquina servidora
![Page 49: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/49.jpg)
BlueZ - Programação
SocketsBibliotecas
#include <bluetooth/bluetooth.h> #include <bluetooth/l2cap.h>#include <bluetooth/rfcomm.h>
![Page 50: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/50.jpg)
BlueZ - Programação
Estruturas
Exemplos:
sockaddr_in s_addr L2CAP
sockaddr_l2RFCOMM
sockaddr_rc
s_addr.l2_family = AF_BLUETOOTH; s_addr.l2_psm = htobs(100); baswap(&s_endereco.l2_bdaddr, addr);
s_ addr.rc_family = AF_BLUETOOTH; bacpy(&s_ addr.rc_bdaddr, BDADDR_ANY); s_ addr.rc_channel = 1; str2ba(addr, &s_addr.rc_bdaddr);
![Page 51: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/51.jpg)
BlueZ - Programação
Criação do sockets
RFCOMM:int nsocket = socket(PF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM);
L2CAP:int nsocket = socket(PF_BLUETOOTH, SOCK_SEQPACKET, BTPROTO_L2CAP);
Bind:bind(nsocket, (struct sockaddr *) &s_addr, sizeof(s_addr));
![Page 52: Bluetooth Ana Cristina Benso da Silva Andrei Oliveira da Silva Fabrício DAvila Cabral CPSE – Centro de Pesquisa em Software Embarcado FACIN/PUCRS – Faculdade](https://reader038.vdocuments.net/reader038/viewer/2022110117/552fc10c497959413d8c33b0/html5/thumbnails/52.jpg)
BlueZ - Programação
Cliente
connect( nsocket, (struct
sockaddr*)&s_endereco,
sizeof(struct sockaddr) );
Servidor
listen(nsocket, 10); int news = accept (nsocket,
(struct sockaddr *) &c_addr, &tam);