Bluetooth (Italiano)
From ArchWiki
Article summary |
---|
In questo articolo viene spiegato come installare e configurare il supporto al Bluetooth su Arch Linux. |
Languages |
English |
Italiano |
Contents |
Installazione
Per usare il Bluetooth, il pacchetto bluez per il Linux Bluetooth protocol stack deve essere installato:
# pacman -S bluez
Bisogna poi avviare manualmente il demone bluetooth (da avviare dopo che dbus sia stato correttamente attivato):
# /etc/rc.d/dbus start # /etc/rc.d/bluetooth start
Se si desidera che il demone parta in fase di avvio di sistema, è possibile aggiungere bluetooth in coda alla lista DAEMONS nel file rc.conf:
DAEMONS=(... bluetooth)
GNOME
Se desiderate controllare il Bluetooth da GNOME, avrete bisogno di installare anche uno fra bluez-gnome e gnome-bluetooth.
bluez-gnome
Innanzitutto, installate bluez-gnome:
# pacman -S bluez-gnome
E poi eseguite questa utility, per avere un applet direttamente sul pannello di GNOME:
$ bluetooth-applet
Adesso dovreste essere in grado di impostare le perifieriche e inviare i file cliccando col destro sull'icona Bluetooth. Notare che bluez-gnome non ha il supporto alla ricezione dei files.
Per far si che l'applet parta da sola ad ogni avvio del sistema, aggiungetela a:
Sistema -> Preferenze -> Applicazioni all'avvio.
Se usate Thunar e volete aggiungere una voce relativa al Bluetooth nel menu "Invia A", fate riferimento a: http://thunar.xfce.org/pwiki/documentation/sendto_menu
NOTE: At present, "Browse Device" function of bluetooth tray icon (bluez-gnome) doesn't work, It only shows a blank nautilus window. It is said that gnome-vfs-obexftp package in AUR may work, but I cannot figure it out for now.
gnome-bluetooth
First,install gnome-bluetooth:
# pacman -S gnome-bluetooth
Then run this to be able to receive files:
$ gnome-obex-server
A blue tray icon will appear. Now you should be able to send files to your Arch box, where a receive dialog will appear and you can choose to accept them or not. Update: in order to be able to receive files install gnome-user-share:
# pacman -S gnome-user-share
and enable bluetooth in Personal File Sharing preferences (Gnome).
Per controllare che l'adattatore sia stato effettivamente riconosciuto e attivato:
# grep bluetooth /var/log/messages.log Feb 17 16:38:02 bloom Bluetooth: Core ver 2.13 Feb 17 16:38:02 bloom Bluetooth: HCI device and connection manager initialized Feb 17 16:38:02 bloom Bluetooth: HCI socket layer initialized Feb 17 16:38:02 bloom Bluetooth: Generic Bluetooth USB driver ver 0.3 Feb 17 16:40:50 bloom bluetoothd[4426]: Bluetooth daemon Feb 17 16:40:50 bloom bluetoothd[4426]: Starting SDP server Feb 17 16:40:50 bloom Bluetooth: L2CAP ver 2.11 Feb 17 16:40:50 bloom Bluetooth: L2CAP socket layer initialized Feb 17 16:40:50 bloom bluetoothd[4426]: Registered interface org.bluez.Service on path /org/bluez/4426/any Feb 17 16:40:50 bloom Bluetooth: SCO (Voice Link) ver 0.6 Feb 17 16:40:50 bloom Bluetooth: SCO socket layer initialized Feb 17 16:40:50 bloom Bluetooth: BNEP (Ethernet Emulation) ver 1.3 Feb 17 16:40:50 bloom bluetoothd[4426]: bridge pan0 created Feb 17 16:40:50 bloom bluetoothd[4426]: HCI dev 0 registered Feb 17 16:40:50 bloom bluetoothd[4426]: HCI dev 0 up Feb 17 16:40:50 bloom bluetoothd[4426]: Starting security manager 0 Feb 17 16:40:50 bloom bluetoothd[4426]: Registered interface org.bluez.Service on path /org/bluez/4426/hci0 Feb 17 16:40:51 bloom Bluetooth: RFCOMM socket layer initialized Feb 17 16:40:51 bloom Bluetooth: RFCOMM TTY layer initialized Feb 17 16:40:51 bloom Bluetooth: RFCOMM ver 1.10 Feb 17 16:40:51 bloom bluetoothd[4426]: Registered interface org.bluez.SerialProxyManager on path /org/bluez/4426/hci0 Feb 17 16:40:51 bloom bluetoothd[4426]: Registered interface org.bluez.NetworkPeer on path /org/bluez/4426/hci0 Feb 17 16:40:51 bloom bluetoothd[4426]: Registered interface org.bluez.NetworkHub on path /org/bluez/4426/hci0 Feb 17 16:40:51 bloom bluetoothd[4426]: Registered interface org.bluez.NetworkRouter on path /org/bluez/4426/hci0 Feb 17 16:40:51 bloom bluetoothd[4426]: Adapter /org/bluez/4426/hci0 has been enabled
Il seguente comando rileva gli adattatori bluetooth collegati al computer:
$ hcitool dev Devices: hci0 00:1B:DC:0F:DB:40
Per informazioni più dettagliate:
$ hciconfig -a hci0 hci0: Type: USB BD Address: 00:1B:DC:0F:DB:40 ACL MTU: 310:10 SCO MTU: 64:8 UP RUNNING PSCAN ISCAN RX bytes:1226 acl:0 sco:0 events:27 errors:0 TX bytes:351 acl:0 sco:0 commands:26 errors:0 Features: 0xff 0xff 0x8f 0xfe 0x9b 0xf9 0x00 0x80 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: SLAVE ACCEPT Name: 'BlueZ (0)' Class: 0x000100 Service Classes: Unspecified Device Class: Computer, Uncategorized HCI Ver: 2.0 (0x3) HCI Rev: 0xc5c LMP Ver: 2.0 (0x3) LMP Subver: 0xc5c Manufacturer: Cambridge Silicon Radio (10)
Configurazione
Manuale
I file di configurazione per il Bluetooth, da modificare per una configurazione manuale, si trovano in /etc/bluetooth, e in particolare sono:
audio.conf input.conf main.conf network.conf rfcomm.conf
La configurazione di default dovrebbe andar bene per la maggior parte dei casi. Le opzioni di configurazione possibili sono già ben documentate all'interno dei file stessi, quindi per un eventuale modifica alle opzioni dovrebbe bastare leggere le relative descrizioni. Per le opzioni generali, iniziate dal file main.conf.
Gnome
bluez-gnome
The bluez-gnome package allows for a graphical interface to customize Bluetooth. The bluetooth-applet puts a Bluetooth icon in the system tray, which is used to configure Bluetooth settings. To add a new device simply click on the icon, and select Setup New Device. This will bring up a program to automatically find, pair, and connect to an external device. To edit other preferences, right-click on the icon and select Preferences. This will bring up a (very) small list of options, as well as all devices "known" by your computer.
Pairing
Many bluetooth devices require pairing. The exact procedure depends among other on the devices involved, and their input functionality. The procedure on a mobile may be as follows:
- The computer sends a connect request to the mobile.
- A pin, determined by the computer, is prompted for at the mobile
- The same key must be re-entered at the computer.
To scan for external devices, do
$> hcitool scan
To pair with a device without using the gnome-bluez package you will need to use a tool named bluez-simple-agent that comes with the bluez package. You need a few python related packages from the regular repositories to get this to run: dbus-python and pygobject. If you have everything ready you can start the script from the root user:
$> bluez-simple-agent
If it all works, you should get the message "Agent registered" on that console. You can now start pairing from your mobile device, and the script will ask you for the passcode on this console, you type it and confirm with enter - voila that's all. You can now also shut down the agent using ^C-c, you need it only for pairing, not every time you want to connect.
For an example scroll down to the example section.
Using Obex for sending and receiving files
Another option, rather than using KDE or Gnome Bluetooth packages, is Obexfs which allows you to mount your phone and treat it as part of your filesystem. Note that to use Obexfs, you need a device that provides an Obex FTP service.
To install;
# pacman -S obexfs
and then your phone can then be mounted running as root
# obexfs -b <devices mac address> /mountpoint
For more mounting options see http://dev.zuckschwerdt.org/openobex/wiki/ObexFs
Examples
Siemens S55
This is what I did to connect to my S55. (I have not figured out how to initiate the connection from the phone)
- The steps under installation
$> hcitool scan Scanning ... XX:XX:XX:XX:XX:XX NAME $> B=XX:XX:XX:XX:XX:XX
Start the simple-agent in a second terminal
$> su -c bluez-simple-agent Password: Agent registered
Back to the first console
$> obexftp -b $B -l "Address book" # Phone ask for pin, I enter it and answer yes when asked if I want to save the device ... <file name="5F07.adr" size="78712" modified="20030101T001858" user-perm="WD" group-perm="" /> ... $> obexftp -b 00:01:E3:6B:FF:D7 -g "Address book/5F07.adr" Browsing 00:01:E3:6B:FF:D7 ... Channel: 5 Connecting...done Receiving "Address book/5F07.adr"... Sending "Address book"... done Disconnecting...done $> obexftp -b 00:01:E3:6B:FF:D7 -p a ... Sending "a"... done Disconnecting...done
Logitech Mouse MX Laser
Connect Bluetooth Logitech Mouse MX Laser without Dongle.
$> hidd --connect XX:XX:XX:XX:XX:XX
Troubleshooting
passkey-agent
$> passkey-agent --default 1234 Can't register passkey agent The name org.bluez was not provided by any .service files
You probably started /etc/rc.d/bluetooth before /etc/rc.d/dbus
$> hciconfig dev # (no listing)
Try running hciconfig hc0 up
bluez-gnome
If you see this when trying to enable receiving files in bluetooth-properties:
Bluetooth OBEX start failed: Invalid path Bluetooth FTP start failed: Invalid path
Then run:
# pacman -S xdg-user-dirs $ xdg-user-dirs-update
You can edit the paths using:
$ vi ~/.config/user-dirs.dirs
Bluetooth USB Dongle
If you are using a USB dongle, you should check that your Bluetooth dongle is recognized. You can do that by inspecting /var/log/messages.log when plugging in the USB dongle. It should look something like the following (look out for hci):
# tail -f /var/log/messages.log May 2 23:36:40 tatooine usb 4-1: new full speed USB device using uhci_hcd and address 9 May 2 23:36:40 tatooine usb 4-1: configuration #1 chosen from 1 choice May 2 23:36:41 tatooine hcid[8109]: HCI dev 0 registered May 2 23:36:41 tatooine hcid[8109]: HCI dev 0 up May 2 23:36:41 tatooine hcid[8109]: Device hci0 has been added May 2 23:36:41 tatooine hcid[8109]: Starting security manager 0 May 2 23:36:41 tatooine hcid[8109]: Device hci0 has been activated
For a list of supported hardware please refer to the resources section on this page.
To verify that the device was detected you can use hcitool which is part of the bluez-utils. You can get a list of available devices and their identifiers and their MAC address by issuing:
$ hcitool dev Devices: hci0 00:1B:DC:0F:DB:40
More detailed informations about the device can be retrieved by using hciconfig.
$ hciconfig -a hci0 hci0: Type: USB BD Address: 00:1B:DC:0F:DB:40 ACL MTU: 310:10 SCO MTU: 64:8 UP RUNNING PSCAN ISCAN RX bytes:1226 acl:0 sco:0 events:27 errors:0 TX bytes:351 acl:0 sco:0 commands:26 errors:0 Features: 0xff 0xff 0x8f 0xfe 0x9b 0xf9 0x00 0x80 Packet type: DM1 DM3 DM5 DH1 DH3 DH5 HV1 HV2 HV3 Link policy: RSWITCH HOLD SNIFF PARK Link mode: SLAVE ACCEPT Name: 'BlueZ (0)' Class: 0x000100 Service Classes: Unspecified Device Class: Computer, Uncategorized HCI Ver: 2.0 (0x3) HCI Rev: 0xc5c LMP Ver: 2.0 (0x3) LMP Subver: 0xc5c Manufacturer: Cambridge Silicon Radio (10)
hcitool scan: Device not found
On some Dell laptops (e.g. Studio 15) you have to switch the Bluetooth mode from HID to HCI using
# hid2hci