Bluetooth: differenze tra le versioni
(→Messa in opera) |
(→Configurazione) |
||
| Riga 313: | Riga 313: | ||
lp rswitch,hold,sniff,park; |
lp rswitch,hold,sniff,park; |
||
} |
} |
||
| + | </pre> |
||
In questo modo il pin non verà chiesto all'utente e sarà quello scritto in passkey. |
In questo modo il pin non verà chiesto all'utente e sarà quello scritto in passkey. |
||
= Conclusione = |
= Conclusione = |
||
| Riga 322: | Riga 323: | ||
fi |
fi |
||
</pre> |
</pre> |
||
| + | |||
= Ringraziamenti e Fonti = |
= Ringraziamenti e Fonti = |
||
Ringrazio SukkoPera per il suo script, la parte di informazioni relative al kernel sono state prese dal wiki di gentoo. |
Ringrazio SukkoPera per il suo script, la parte di informazioni relative al kernel sono state prese dal wiki di gentoo. |
||
Versione delle 19:41, 16 dic 2006
Questa guida si occuperà di spiegare passo passo come installare una periferica bluetooth su slackware 11. Le periferiche bluetooth che consentono la connettività tra telefonini, stampanti auricolari ecc ecc. L'implementazione di queste periferiche è ormai ben radicata nel kernel ma il progetto che le gestisce ha fatto un drastico cambiamento inserendo il supporto per dbus. Questo ha creato non pochi problemi, dovuti non solo alla gestione delle dipendeze (su slackware in particolare) ma anche alla gestione delle regole di dbus.
Indice |
Il necessario
- i pacchetti del progetto bluez (www.bluez.org)
- dbus (nella versione consigliato su bluez)
- il vostro editor di testo preferito
- diritti di root
- sorgenti del kernel
Messa in opera
Se avete scaricato i pacchetti da Slacky.it potete passare direttamente alla sezione #Configurazione
Kernel
Se il kernel da voi in uso è diverso da quello di default di Slackware 11, sarà necessario compilare anche
Networking ---> <*> Bluetooth subsystem support ---> --- Bluetooth subsystem support <M> L2CAP protocol support <M> SCO links support <M> RFCOMM protocol support [*] RFCOMM TTY support <M> BNEP protocol support [*] Multicast filter support [*] Protocol filter support <M> HIDP protocol support Bluetooth device drivers ---> <M> HCI USB driver [*] SCO (voice) support <M> HCI UART driver [*] UART (H4) protocol support [*] BCSP protocol support [*] Transmit CRC with every BCSP packet <M> HCI BCM203x USB driver <M> HCI BPA10x USB driver <M> HCI BlueFRITZ! USB driver <M> HCI DTL1 (PC Card) driver <M> HCI BT3C (PC Card) driver <M> HCI BlueCard (PC Card) driver <M> HCI UART (PC Card) device driver <M> HCI VHCI (Virtual HCI device) driver
Ricompilando in kernel avrete così a disposizione i moduli per il supporto bluetooth.
Bluez
I pacchetti di bluez sono:
- bluez-firmware
- bluez-hcidump
- bluez-libs
- bluez-utils
Quindi per compilarli e installarli
tar zxvpf bluez-libs*.tar.gz cd bluez-libs* ./configure --prefix=/usr make if `checkinstall -v &> /dev/null`; then checkinstall; installpkgbluez-libs*.tgz; else make install; fi cd .. tar zxvpf bluez-firmware*.tar.gz cd bluez-firmware* ./configure --prefix=/usr if `checkinstall -v &> /dev/null`; then checkinstall; installpkg bluez-firmware*; else make install; fi tar zxvpf bluez-hcidump*.tar.gz cd bluez-hcidump* ./configure --prefix=/usr make if `checkinstall -v &> /dev/null`; then checkinstall; installpkg bluez-hcidump*; else make install; fi tar zxvpf bluez-utils*.tar.gz cd bluez-utils* ./configure --prefix=/usr --enable-all make if `checkinstall -v &> /dev/null`; then checkinstall; installpkg bluez-utils*.tgz; else make install; fi
A questo punto il sistema è quasi pronto per funzionare.
Configurazione
Ci serve ora uno script che faccia partire il sistema, nei pacchetti di slacky è giò inserito ma c'è una piccola modifica da fare (/etc/rc.d/rc.bluetooth.conf):
#!/bin/sh
#
# Start/stop the Bluetooth daemons
#
# This version has been modified by SukkoPera, taking inspiration from then
# Debian init script, to add support for register-passkeys
# Edited by L1q1d for enabling the discovery system.
#
set -e
PATH=/sbin:/bin:/usr/sbin:/usr/bin
NAME=bluetooth
DESC="Bluetooth subsystem"
# This script was stolen from Debian
# REGISTER_PASSKEYS=/usr/lib/bluetooth/register-passkeys
# tolto poiche nell'installazione generica nn c'è
HCID_NAME=hcid
SDPD_NAME=sdpd
HIDD_NAME=hidd
HID2HCI_NAME=hid2hci
RFCOMM_NAME=rfcomm
PAND_NAME=pand
DUND_NAME=dund
HCID_EXEC="`which $HCID_NAME || true`"
SDPD_EXEC="`which $SDPD_NAME || true`"
HIDD_EXEC="`which $HIDD_NAME || true`"
HID2HCI_EXEC="`which $HID2HCI_NAME || true`"
RFCOMM_EXEC="`which $RFCOMM_NAME || true`"
PAND_EXEC="`which $PAND_NAME || true`"
DUND_EXEC="`which $DUND_NAME || true`"
HCID_ENABLE=true
SDPD_ENABLE=true
HIDD_ENABLE=false
HID2HCI_ENABLE=false
RFCOMM_ENABLE=true
DUND_ENABLE=false
PAND_ENABLE=false
HCID_CONFIG="/etc/bluetooth/hcid.conf"
RFCOMM_CONFIG="/etc/bluetooth/rfcomm.conf"
HIDD_OPTIONS=""
DUND_OPTIONS=""
PAND_OPTIONS=""
[ -e /etc/rc.d/rc.bluetooth.conf ] && . /etc/rc.d/rc.bluetooth.conf
case "$1" in
start)
echo -n "Starting $DESC:"
if $HCID_ENABLE && [ -x "$HCID_EXEC" -a -f "$HCID_CONFIG" ] ; then
$HCID_EXEC -f $HCID_CONFIG
echo -n " $HCID_NAME"
fi
if $SDPD_ENABLE && [ -x "$SDPD_EXEC" ] ; then
$SDPD_EXEC
echo -n " $SDPD_NAME"
fi
if $HIDD_ENABLE && [ -x "$HIDD_EXEC" ] ; then
$HIDD_EXEC $HIDD_OPTIONS --server || true
echo -n " $HIDD_NAME"
fi
if $HID2HCI_ENABLE && [ -x "$HID2HCI_EXEC" ] ; then
$HID2HCI_EXEC --tohci > /dev/null 2>&1 || true
echo -n " $HID2HCI_NAME"
fi
if $RFCOMM_ENABLE && [ -x "$RFCOMM_EXEC" -a -f "$RFCOMM_CONFIG" ] ; then
$RFCOMM_EXEC -f $RFCOMM_CONFIG bind all || true
echo -n " $RFCOMM_NAME"
fi
if $DUND_ENABLE && [ -x "$DUND_EXEC" -a -n "$DUND_OPTIONS" ] ; then
$DUND_EXEC $DUND_OPTIONS
echo -n " $DUND_NAME"
fi
if $PAND_ENABLE && [ -x "$PAND_EXEC" -a -n "$PAND_OPTIONS" ] ; then
$PAND_EXEC $PAND_OPTIONS
echo -n " $PAND_NAME"
fi
# if [ -x $REGISTER_PASSKEYS ]; then
# $REGISTER_PASSKEYS
# echo -n " passkeys"
# fi
echo "."
# Piccola modifica da apportare <----
echo "Enabling d-bus discovery"
dbus-send --system --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetMode string:discoverable
;;
stop)
echo -n "Stopping $DESC:"
killall $PAND_NAME > /dev/null 2>&1 || true
echo -n " $PAND_NAME"
killall $DUND_NAME > /dev/null 2>&1 || true
echo -n " $DUND_NAME"
if [ -x "$RFCOMM_EXEC" ] ; then
$RFCOMM_EXEC release all > /dev/null 2>&1 || true
echo -n " $RFCOMM_NAME"
fi
killall $HIDD_NAME > /dev/null 2>&1 || true
echo -n " $HIDD_NAME"
killall $SDPD_NAME > /dev/null 2>&1 || true
echo -n " $SDPD_NAME"
killall $HCID_NAME > /dev/null 2>&1 || true
echo -n " $HCID_NAME"
echo "."
;;
*)
N=/etc/rc.d/$NAME
echo "Usage: $N {start|stop}" >&2
exit 1
;;
esac
exit 0
Con il suo file di configurazione (/etc/rc.d/rc.bluetooth.conf):
# Bluetooth configuraton file # Start of hcid (allowed values are "true" and "false") HCID_ENABLE=true # Config file for hcid HCID_CONFIG="/etc/bluetooth/hcid.conf" # Start sdpd (allowed values are "true" and "false") SDPD_ENABLE=true # Start hidd (allowed values are "true" and "false") HIDD_ENABLE=false # Arguments to hidd HIDD_OPTIONS="" # Run hid2hci (allowed values are "true" and "false") HID2HCI_ENABLE=false # Bind rfcomm devices (allowed values are "true" and "false") RFCOMM_ENABLE=true # Config file for rfcomm RFCOMM_CONFIG="/etc/bluetooth/rfcomm.conf" # Start dund (allowed values are "true" and "false") DUND_ENABLE=false # Arguments to dund DUND_OPTIONS="--listen --persist" # Start pand (allowed values are "true" and "false") PAND_ENABLE=false # Arguments to pand PAND_OPTIONS="--listen --role NAP" <pre> A questo punto creaimo le regole per i moduli da caricare: <pre>cat << EOF > /etc/modprobe.d/bluetooth alias bt-proto-0 l2cap alias bt-proto-2 sco alias bt-proto-3 rfcomm ctrl + d
Carichiamo i moduli:
modprobe bluez | bluetooth modprobe l2cap modprobe sco modprobe rfcomm
Come ultima modifica andiamo su /etc/bluetooth/hcid.conf e mettiamo:
#
# HCI daemon configuration file.
#
# HCId options
options {
# Automatically initialize new devices
autoinit yes;
# Security Manager mode
# none - Security manager disabled
# auto - Use local PIN for incoming connections
# user - Always ask user for a PIN
#
security auto;
# Pairing mode
# none - Pairing disabled
# multi - Allow pairing with already paired devices
# once - Pair once and deny successive attempts
pairing multi;
# Default PIN code for incoming connections
passkey "1234";
}
# Default settings for HCI devices
device {
# Local device name
# %d - device id
# %h - host name
name "%d Bluetooth";
# Local device class
class 0x3e0100;
# Default packet type
#pkt_type DH1,DM1,HV1;
# Inquiry and Page scan
iscan enable; pscan enable;
# Default link mode
# none - no specific policy
# accept - always accept incoming connections
# master - become master on incoming connections,
# deny role switch on outgoing connections
lm accept;
# Default link policy
# none - no specific policy
# rswitch - allow role switch
# hold - allow hold mode
# sniff - allow sniff mode
# park - allow park mode
lp rswitch,hold,sniff,park;
}
In questo modo il pin non verà chiesto all'utente e sarà quello scritto in passkey.
Conclusione
Per abilitare il bluetooth basterà ora attivare il demone con:
/etc/rc.d/rc.bluetooth start
E per automatizzare il boot alla partenza inerire nel rc.local:
if [ -x /etc/rc.d/rc.bluetooth ]; then
/etc/rc.d/rc.bluetooth start
fi
Ringraziamenti e Fonti
Ringrazio SukkoPera per il suo script, la parte di informazioni relative al kernel sono state prese dal wiki di gentoo.