Difference between revisions of "How to setup Bluetooth"
(→Configuring the kernel) |
(→Troubleshooting: This is how I got bluetooth working again on my Thinkpad X130e) |
||
(75 intermediate revisions by 29 users not shown) | |||
Line 1: | Line 1: | ||
− | This | + | {| width="100%" |
+ | |style="vertical-align:top;padding-right:20px;width:10px;white-space:nowrap;" | __TOC__ | ||
+ | |style="vertical-align:top" | | ||
+ | <div style="margin: 0; margin-right:10px; border: 1px solid #dfdfdf; padding: 0em 1em 1em 1em; background-color:#efefef; align:right;"> | ||
+ | This HOWTO tells you how to install and configure Bluetooth on your Linux driven ThinkPad and how to make the most common Bluetooth applications (like connecting your mobile phone etc.) work. | ||
+ | </div> | ||
+ | |} | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | ||
+ | ==Enabling/Disabling Bluetooth== | ||
+ | If bluetooth is disabled and you have the [[thinkpad-acpi]] kernel module loaded you can enable bluetooth by entering: | ||
+ | :{{cmdroot|echo 1 > /sys/devices/platform/thinkpad_acpi/bluetooth_enable}} | ||
+ | or to disable | ||
+ | :{{cmdroot|echo 0 > /sys/devices/platform/thinkpad_acpi/bluetooth_enable}} | ||
+ | |||
+ | If you do not have [[thinkpad-acpi]] installed, simply check bluetooth status: | ||
+ | |||
+ | :{{cmdroot|cat /proc/acpi//ibm/bluetooth}} | ||
+ | |||
+ | :{{cmdresult|status: disabled}} | ||
+ | |||
+ | :{{cmdresult|commands: enable, disable}} | ||
+ | |||
+ | The following commands activate and deactivate bluetooth respectively: | ||
+ | |||
+ | $echo "enable" > /proc/acpi/ibm/bluetooth | ||
+ | $echo "disable" > /proc/acpi/ibm/bluetooth | ||
+ | |||
+ | You might also be able to toggle bluetooth using Fn+F5. | ||
+ | |||
+ | To make {{key|Fn}}{{key|F5}} work on R50p with CentOS 5. | ||
+ | |||
+ | Create {{path|/etc/acpi/actions/bluetooth.sh}}: | ||
+ | <pre>#!/bin/bash | ||
+ | SYSFS="/sys/devices/platform/thinkpad_acpi/bluetooth_enable" | ||
+ | case "$(cat "$SYSFS")" in | ||
+ | 0) | ||
+ | echo 1 > "$SYSFS" | ||
+ | ;; | ||
+ | 1) | ||
+ | echo 0 > "$SYSFS" | ||
+ | ;; | ||
+ | esac</pre> | ||
+ | |||
+ | Create {{path|/etc/acpi/events/radio.conf}}: | ||
+ | <pre>event=ibm/hotkey HKEY 00000080 00001005 | ||
+ | action=/etc/acpi/actions/bluetooth.sh</pre> | ||
+ | |||
+ | Make {{path|/etc/acpi/actions/bluetooth.sh}} executable and restart acpid. | ||
+ | For troubleshooting see {{path|/var/log/acpid}}. | ||
+ | |||
+ | === rfkill interface === | ||
+ | |||
+ | For some reason, {{key|Fn}}{{key|F5}} does not work on my 2.6.27 kernel (may be due to rfkill addition in thinkpad-acpi), here is a Bash script I use to switch Bluetooth status using the standard rfkill interface: | ||
+ | <pre>#!/bin/bash | ||
+ | |||
+ | NAME="tpacpi_bluetooth_sw" | ||
+ | |||
+ | find_by_name() { | ||
+ | NAME="$1" | ||
+ | test -z "${NAME}" && return 1 | ||
+ | SYSFS_NAME=$(find -P /sys -name name -path "*/rfkill/*" -exec grep -l "${NAME}" \{\} + | head -n 1) | ||
+ | if [[ ! -z "${SYSFS_NAME}" && -r "${SYSFS_NAME/%name/state}" ]]; then | ||
+ | RESULT=${SYSFS_NAME%%/name} | ||
+ | echo $RESULT | ||
+ | return 0 | ||
+ | fi | ||
+ | return 1 | ||
+ | } | ||
+ | |||
+ | SYSFS="$(find_by_name "${NAME}")" | ||
+ | |||
+ | if [[ ! -z "${SYSFS}" && -r "${SYSFS}/state" ]]; then | ||
+ | case "$(cat "${SYSFS}/state")" in | ||
+ | 0) | ||
+ | echo 1 > "${SYSFS}/state" | ||
+ | ;; | ||
+ | 1) | ||
+ | echo 0 > "${SYSFS}/state" | ||
+ | ;; | ||
+ | esac | ||
+ | fi</pre> | ||
+ | |||
+ | It is triggered by the following acpid rule: | ||
+ | event=ibm/hotkey HKEY 00000080 00001005 | ||
+ | action=/path/to/script.sh | ||
+ | |||
+ | |||
+ | Add the following kernel parameter (when builtin) to prevent Bluetooth from being enabled at boot time: | ||
+ | rfkill.default_state=0 | ||
==Configuring the kernel== | ==Configuring the kernel== | ||
Line 21: | Line 99: | ||
Choose an appropriate USB host driver, one of: | Choose an appropriate USB host driver, one of: | ||
− | :{{kernelconf|CONFIG_USB_EHCI_HCD|<M>| | + | :{{kernelconf|CONFIG_USB_EHCI_HCD|<M>|EHCI HCD (USB 2.0) support|USB support|Device Drivers||}} |
:{{kernelconf|CONFIG_USB_UHCI|<M>|UHCI HCD support|USB support|Device Drivers||}} | :{{kernelconf|CONFIG_USB_UHCI|<M>|UHCI HCD support|USB support|Device Drivers||}} | ||
:{{kernelconf|CONFIG_USB_OHCI|<M>|OHCI HCD support|USB support|Device Drivers||}} | :{{kernelconf|CONFIG_USB_OHCI|<M>|OHCI HCD support|USB support|Device Drivers||}} | ||
− | + | Enable Bluetooth subsystem and drivers: | |
+ | :{{kernelconf|CONFIG_BT|<*>|Bluetooth subsystem support|Networking|||}} | ||
+ | :{{kernelconf|CONFIG_BT_L2CAP|<*>|L2CAP protocol support|Bluetooth subsystem support|Networking||}} | ||
+ | :{{kernelconf|CONFIG_BT_SCO|<*>|SCO links support|Bluetooth subsystem support|Networking||}} | ||
+ | :{{kernelconf|CONFIG_BT_RFCOMM|<*>|RFCOMM protocol support|Bluetooth subsystem support|Networking||}} | ||
+ | :{{kernelconf|CONFIG_BT_RFCOMM_TTY|[*]|RFCOMM TTY support|Bluetooth subsystem support|Networking||}} | ||
+ | :{{kernelconf|CONFIG_BT_BNEP|<*>|BNEP protocol support|Bluetooth subsystem support|Networking||}} | ||
+ | :{{kernelconf|CONFIG_BT_HID|<*>|HID protocol support|Bluetooth subsystem support|Networking||}} | ||
+ | :{{kernelconf|CONFIG_BT_HCIUSB|<M>|HCI USB driver|Bluetooth device drivers|Bluetooth subsystem support|Networking|}} | ||
+ | :{{kernelconf|CONFIG_BT_HCIUSB_SCO|[*]|SCO (voice) support|Bluetooth device drivers|Bluetooth subsystem support|Networking|}} | ||
Make sure that the according modules are loaded: | Make sure that the according modules are loaded: | ||
− | :{{cmdroot|modprobe uhci_hcd ; modprobe ehci_hcd}} | + | :{{cmdroot|modprobe uhci_hcd ; modprobe ehci_hcd ; modprobe hci_usb}} |
− | + | Since '''2.6.29''' hci_usb is replaced by btusb | |
+ | :{{kernelconf|CONFIG_BT_HCIBTUSB|[m]|HCI USB driver|Bluetooth device drivers|Bluetooth subsystem support|Networking support|}} | ||
+ | :{{cmdroot|modprobe btusb}} | ||
==Serial connection over Bluetooth== | ==Serial connection over Bluetooth== | ||
− | One | + | One common application is to connect your mobile phone and use it as a modem to connect to the internet via GPRS or 3G (UMTS). A lot of phones do this through using AT-commands on a serial over Bluetooth connection. |
+ | |||
+ | By configuring {{path|/etc/bluetooth/rfcomm.conf}} correctly, you'll get a device {{path|/dev/rfcomm0}}. | ||
+ | |||
+ | Eventually one could use the command: | ||
+ | :{{cmdroot|rfcomm bind 0 00:15:A0:7A:90:F2 3}} | ||
− | : | + | The hardware address should be replaced with that of your phone. If you don't know the hardware address of your phone yet, you can get it by running: |
+ | :{{cmdroot|hcitool scan}} | ||
− | + | The last parameter ('3') is the channel to use. I spent quite some time fighting before I found out of that one; I didn't find it documented anywhere, but by running | |
− | + | :{{cmdroot|sdptool records 00:15:A0:7A:90:F2}} | |
− | + | I found channel 3 to be the right one for my phone. You will have to experiment to find the right one for your phone setup; for T-Mobile GSM/GPRS carrier in USA this is channel 1. | |
− | :sdptool records 00:15:A0:7A:90:F2 | + | {{NOTE|By experimenting, the bluetooth stack on the cellphone may crash. Reboot it if that happens.}} |
− | I found channel 3 to be the right one for my phone. You will have to experiment to find the right one for your phone setup; for T-Mobile GSM/GPRS carrier in USA this is channel 1. | ||
− | + | Alternativly one could use the following to find the right channel: | |
+ | :{{cmdroot|sdptool search DUN}} | ||
− | At this point you can use an automatic dialing utility such as wvdial, editing the config file to point to the modem at /dev/rfcomm0, and everything should work just like a land line! | + | Inquiring ... |
+ | Searching for DUN on 00:11:22:33:44:55 ... | ||
+ | Service Name: Dial-up Networking | ||
+ | Service RecHandle: 0x10001 | ||
+ | Service Class ID List: | ||
+ | "Dialup Networking" (0x1103) | ||
+ | "Generic Networking" (0x1201) | ||
+ | Protocol Descriptor List: | ||
+ | "L2CAP" (0x0100) | ||
+ | "RFCOMM" (0x0003) | ||
+ | Channel: 4 | ||
+ | |||
+ | Now {{path|/dev/rfcomm0}} exists. | ||
+ | |||
+ | At this point you can use an automatic dialing utility such as wvdial, editing the config file to point to the modem at {{path|/dev/rfcomm0}}, and everything should work just like a land line! | ||
+ | |||
+ | {{NOTE|If you experience strange disconnects while using wvdial, disable "Carrier Check" in your wvdial configuration.}} | ||
You may directly access the modem (i.e. by using minicom:) | You may directly access the modem (i.e. by using minicom:) | ||
− | :minicom -s | + | :{{cmduser|minicom -s}} |
− | set the serial device to be | + | set the serial device to be {{path|/dev/rfcomm0}}, choose 'exit' and then the AT-commands can be typed in. |
+ | With my operator (Telenor, Norway) it seemed simple enough, I just entered | ||
:ATDT *99# | :ATDT *99# | ||
and lots of cryptic letters started dancing across the screen, indicating a ppp session startup. | and lots of cryptic letters started dancing across the screen, indicating a ppp session startup. | ||
− | + | To configure pppd create {{path|/etc/ppp/peers/nokia}} with particularly those lines: | |
− | + | /dev/rfcomm0 | |
− | + | connect '/usr/sbin/chat -v -f /etc/ppp/chat-nokia' | |
− | + | debug | |
− | + | 10.0.1.3 | |
− | + | crtscts | |
− | + | noipdefault | |
− | + | ipcp-accept-local | |
− | + | defaultroute | |
− | + | novj | |
− | + | nobsdcomp | |
− | + | novjccomp | |
− | + | nopcomp | |
− | + | noaccomp | |
− | + | usepeerdns | |
− | + | Furthermore, you need a simple chat script. Create {{path|/etc/ppp/chat-nokia}}: | |
− | + | 'TIMEOUT' '5' | |
− | + | 'ABORT' 'BUSY' | |
− | + | 'ABORT' 'ERROR' | |
− | + | 'ABORT' 'NO ANSWER' | |
− | + | 'ABORT' 'NO CARRIER' | |
− | + | 'ABORT' 'NO DIALTONE' | |
− | + | 'ABORT' 'Invalid Login' | |
− | + | 'ABORT' 'Login incorrect' | |
− | + | '' 'ATZ' | |
− | + | 'OK' 'ATDT*99#' | |
− | + | '~--' '' | |
− | + | Here's a script that works for Cingular's network: | |
− | + | TIMEOUT 35 | |
− | + | ECHO ON | |
+ | ABORT '\nBUSY\r' | ||
+ | ABORT '\nERROR\r' | ||
+ | ABORT '\nNO ANSWER\r' | ||
+ | ABORT '\nNO CARRIER\r' | ||
+ | ABORT '\nNO DIALTONE\r' | ||
+ | ABORT '\nRINGING\r\n\r\nRINGING\r' | ||
+ | '' \rAT | ||
+ | OK 'AT+CGDCONT=1,"IP","WAP.CINGULAR"' | ||
+ | OK ATD*99***1# | ||
+ | CONNECT "" | ||
− | Different network operators may require different call strings. | + | See more [https://help.ubuntu.com/community/BluetoothDialup#preview here] |
+ | |||
+ | Run pppd with: | ||
+ | :{{cmduser|pppd call nokia}} | ||
+ | This should establish the internet connection. | ||
+ | |||
+ | {{NOTE|Different network operators may require different call strings. For many carriers (including T-Mobile USA) "*99#" works without additional parameters.}} | ||
For editing phonebook / ringtones / etc., the gammu utils (http://www.gamu.net) has been reported to work well, but this appears to be primarily for Nokia phones. | For editing phonebook / ringtones / etc., the gammu utils (http://www.gamu.net) has been reported to work well, but this appears to be primarily for Nokia phones. | ||
Line 104: | Line 232: | ||
to list the files. Note that the brackets *are* necessary. From there, you can list directories easily and batch download files. | to list the files. Note that the brackets *are* necessary. From there, you can list directories easily and batch download files. | ||
+ | |||
+ | ==Mount a phone as a directory== | ||
+ | You can also mount a phone as a standard directory using obexfs and the FUSE (file system in userspace) utilities. | ||
+ | |||
+ | {{NOTE|The ibm bluetooth card can work like an usb-dongle. You don't need the bcm203x module.}} | ||
+ | |||
+ | Configure your kernel as outlined above. | ||
+ | |||
+ | * Install the required packages | ||
+ | To mount the filesystem we need the fuse program. FuseFS is also implemented in the kernel, but for some reason it only works with 2.6.18. If you run 2.6.17 or earlier, please download it and build the module according to your distro. | ||
+ | |||
+ | * Emerge or apt-get bluez-utils and obexfs. This should pull other required packages (bluez-libs, openobex, obexftp, sys-fs/fuse) as dependencies. | ||
+ | |||
+ | :{{cmdroot|emerge bluez-utils obexfs}} | ||
+ | |||
+ | * Modify /etc/bluetooth/hcid.conf if you haven't already. It can be done as above, or use the following: | ||
+ | options { | ||
+ | autoinit yes" | ||
+ | security user | ||
+ | pairing multi | ||
+ | pin_helper /usr/bin/bluepin | ||
+ | } | ||
+ | device { | ||
+ | name testname | ||
+ | class 0x3e0100 | ||
+ | iscan enable | ||
+ | pscan enable | ||
+ | lm accept | ||
+ | lp rswitch,hold,sniff,park | ||
+ | } | ||
+ | |||
+ | * load the modules: | ||
+ | :{{cmdroot|modprobe fuse}} | ||
+ | :{{cmdroot|modprobe bluetooth}} | ||
+ | :{{cmdroot|modprobe ehci-hcd}} | ||
+ | :{{cmdroot|modprobe uhci-hcd}} | ||
+ | :{{cmdroot|modprobe hci_usb}} | ||
+ | :{{cmdroot|modprobe l2cap}} | ||
+ | :{{cmdroot|modprobe rfcomm}} | ||
+ | |||
+ | * activate your bluetooth (show howto ibm-acpi for more details) by using fn+f5 or: | ||
+ | :{{cmdroot|echo enable >/proc/acpi/ibm/bluetooth}} | ||
+ | |||
+ | * start the bluetooth device: | ||
+ | :{{cmdroot|/etc/init.d/bluetooth start}} | ||
+ | |||
+ | * turn on bluetooth of your mobile phone (visible mode) and get the mac-address of your phone using hcitool. | ||
+ | :{{cmdroot|hcitool scan}} | ||
+ | |||
+ | === For non symbian mobile phones === | ||
+ | |||
+ | * mount your phone - don't forget to umount it when you're finished | ||
+ | :{{cmdroot|mkdir /mnt/phone}} | ||
+ | :{{cmdroot|mount -t fuse "obexfs#-b00:16:20:32:25:3C -B6" /mnt/phone}} | ||
+ | ''use your mac-address instead of my 00:16:20:32:25:3C and don't forget the -b option in front of the mac'' | ||
+ | |||
+ | Works perfectly with IBM T43p, X41, sony ericsson k750i, nokia 6280, samsung z400, sony ericsson k700i. | ||
+ | |||
+ | |||
+ | === Mounting Symbian Phones === | ||
+ | |||
+ | * You need network file system support in your kernel | ||
+ | |||
+ | :{{cmdroot|cd /usr/src/linux}} | ||
+ | :{{cmdroot|make menuconfig}} | ||
+ | |||
+ | :{{kernelconf|NFS_FS|<M>|NFS file system support|Network File Systems|File Systems|||}} | ||
+ | :{{kernelconf|NFS_V3|<M>|Provide NFSv3 client support|Network File Systems|File Systems|||}} | ||
+ | |||
+ | :{{kernelconf|NFSD|<M>|NFS server support|Network File Systems|File Systems|||}} | ||
+ | :{{kernelconf|NFSD_V3|<*>|Provide NFSv3 server support|Network File Systems|File Systems|||}} | ||
+ | :{{kernelconf|NFSD_TCP|<*>|Provide NFS server over TCP support|Network File Systems|File Systems|||}} | ||
+ | |||
+ | :{{cmdroot|make && make modules_install}} | ||
+ | |||
+ | * Install required programs | ||
+ | |||
+ | :{{cmdroot|emerge -av p3nfs}} | ||
+ | |||
+ | * Modify your /etc/bluetooth/rfcomm.conf | ||
+ | |||
+ | rfcomm0 { | ||
+ | bind yes; | ||
+ | device 00:0F:DE:8C:E6:94; | ||
+ | channel 13; | ||
+ | comment "symbian connection" | ||
+ | } | ||
+ | |||
+ | * restart your bluetooth device, load kernel modules and start portmap (required for p3nfs) | ||
+ | |||
+ | :{{cmdroot|/etc/init.d/bluetooth restart}} | ||
+ | :{{cmdroot|modprobe nfs}} | ||
+ | :{{cmdroot|modprobe nfsd}} | ||
+ | |||
+ | :{{cmdroot|/etc/init.d/portmap start}} | ||
+ | |||
+ | * get the application for your mobile phone [http://www.koeniglich.de/p3nfs.html here] | ||
+ | |||
+ | * start bt at your mobile phone, send application to mobilephone, install and launch the nfsapp with bluetooth at channel 13 (default) | ||
+ | |||
+ | :{{cmdroot|obexftp -b 00:0F:DE:8C:E6:94 -p /home/tava/ablage/nfsapp*}} | ||
+ | |||
+ | * mount your mobile phone: | ||
+ | |||
+ | :{{cmdroot|p3nfsd -UIQ -tty /dev/rfcomm0 -dir /mnt/bluetooth}} (-UIQ is only for UIQ-Phones, type p3nfsd --help and get informations for your phone) | ||
+ | |||
+ | * if doesn't work, make sure rfcomm0 is clean | ||
+ | |||
+ | :{{cmdroot|rfcomm}} | ||
+ | |||
+ | |||
+ | |||
+ | ---- | ||
+ | |||
+ | ===Building from source=== | ||
+ | Get the source packages from [http://www.bluez.org www.bluez.org]. | ||
+ | |||
+ | Build each of them with the usual steps: | ||
+ | :{{cmduser|./configure && make}} | ||
+ | :{{cmdroot|make install}} | ||
+ | |||
+ | ===Gentoo ebuilds=== | ||
+ | Under {{Gentoo}}, install the following ebuilds: | ||
+ | *net-wireless/bluez-bluefw | ||
+ | *net-wireless/bluez-firmware | ||
+ | *net-wireless/bluez-hcidump | ||
+ | *net-wireless/bluez-hciemu | ||
+ | *net-wireless/bluez-libs | ||
+ | *net-wireless/bluez-utils | ||
+ | |||
+ | {{NOTE|net-wireless/bluez-kernel is not needed, since the current version is included in your kernel.}} | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ===Other distributions=== | ||
+ | You will find packages for {{Debian}}, {{Redhat}} and {{Slackware}} on the [http://www.bluez.org/packages.html packages page] of the BlueZ project. | ||
+ | |||
+ | Bluez packages are included in Debian Sid (bluez-utils, and non-free package bluez-firmware). | ||
+ | |||
+ | ==Troubleshooting== | ||
+ | If you cant get hci0 up with a /etc/init.d/bluetooth restart (or similar) then you might want to try a | ||
+ | :{{cmdroot|hciconfig hci0 down && hciconfig hci0 up}} | ||
+ | (solved the problem on a X60s and T60 (debian/testing)) | ||
+ | |||
+ | If there's no physical switch to enable bluetooth, and {{cmd|rfkill list|}} shows: | ||
+ | 0: tpacpi_bluetooth_sw: Bluetooth | ||
+ | Soft blocked: no | ||
+ | Hard blocked: yes | ||
+ | 1: phy0: Wireless LAN | ||
+ | Soft blocked: no | ||
+ | Hard blocked: no | ||
+ | Try rebooting and resetting BIOS settings to defaults. | ||
==External Links== | ==External Links== | ||
− | http://gagravarr.org/series-60/ | + | *[http://www.holtmann.org/linux/bluetooth/ Bluetooth and Linux]: Marcel Holtmann's list of bluetooth HOWTOs. |
+ | *http://gagravarr.org/series-60/ | ||
+ | *http://koti.kapsi.fi/mcfrisk/linux_gprs.html | ||
+ | *[http://www.gentoo.org/doc/en/bluetooth-guide.xml Guide on how to set up Bluetooth in Gentoo] | ||
+ | *[http://www.linux.ie/articles/bluetoothheadset.php www.linux.ie:Linux and Bluetooth Headset howto (AKA: Fedora, BTSCO, Bluez, Jabra and Skype)] | ||
+ | |||
− | + | [[Category:A30]] [[Category:A30p]] [[Category:A31]] [[Category:A31p]] [[Category:R40]] [[Category:R40e]] [[Category:R50]] [[Category:R50p]] [[Category:R51]] [[Category:R52]] [[Category:T30]] [[Category:T40]] [[Category:T40p]] [[Category:T41]] [[Category:T41p]] [[Category:T42]] [[Category:T42p]] [[Category:T43]] [[Category:T43p]] [[Category:T60]] [[Category:T60p]] [[Category:T61]] [[Category:X23]] [[Category:X24]] [[Category:X30]] [[Category:X31]] [[Category:X32]] [[Category:X40]] [[Category:X41]] [[Category:X41 Tablet]] [[Category:X60]] [[Category:X60s]] [[Category:Z60m]] [[Category:Z60t]] |
Latest revision as of 13:41, 13 November 2015
This HOWTO tells you how to install and configure Bluetooth on your Linux driven ThinkPad and how to make the most common Bluetooth applications (like connecting your mobile phone etc.) work. |
Enabling/Disabling Bluetooth
If bluetooth is disabled and you have the thinkpad-acpi kernel module loaded you can enable bluetooth by entering:
# echo 1 > /sys/devices/platform/thinkpad_acpi/bluetooth_enable
or to disable
# echo 0 > /sys/devices/platform/thinkpad_acpi/bluetooth_enable
If you do not have thinkpad-acpi installed, simply check bluetooth status:
# cat /proc/acpi//ibm/bluetooth
status: disabled
commands: enable, disable
The following commands activate and deactivate bluetooth respectively:
$echo "enable" > /proc/acpi/ibm/bluetooth $echo "disable" > /proc/acpi/ibm/bluetooth
You might also be able to toggle bluetooth using Fn+F5.
To make FnF5 work on R50p with CentOS 5.
Create /etc/acpi/actions/bluetooth.sh:
#!/bin/bash SYSFS="/sys/devices/platform/thinkpad_acpi/bluetooth_enable" case "$(cat "$SYSFS")" in 0) echo 1 > "$SYSFS" ;; 1) echo 0 > "$SYSFS" ;; esac
Create /etc/acpi/events/radio.conf:
event=ibm/hotkey HKEY 00000080 00001005 action=/etc/acpi/actions/bluetooth.sh
Make /etc/acpi/actions/bluetooth.sh executable and restart acpid. For troubleshooting see /var/log/acpid.
rfkill interface
For some reason, FnF5 does not work on my 2.6.27 kernel (may be due to rfkill addition in thinkpad-acpi), here is a Bash script I use to switch Bluetooth status using the standard rfkill interface:
#!/bin/bash NAME="tpacpi_bluetooth_sw" find_by_name() { NAME="$1" test -z "${NAME}" && return 1 SYSFS_NAME=$(find -P /sys -name name -path "*/rfkill/*" -exec grep -l "${NAME}" \{\} + | head -n 1) if [[ ! -z "${SYSFS_NAME}" && -r "${SYSFS_NAME/%name/state}" ]]; then RESULT=${SYSFS_NAME%%/name} echo $RESULT return 0 fi return 1 } SYSFS="$(find_by_name "${NAME}")" if [[ ! -z "${SYSFS}" && -r "${SYSFS}/state" ]]; then case "$(cat "${SYSFS}/state")" in 0) echo 1 > "${SYSFS}/state" ;; 1) echo 0 > "${SYSFS}/state" ;; esac fi
It is triggered by the following acpid rule:
event=ibm/hotkey HKEY 00000080 00001005 action=/path/to/script.sh
Add the following kernel parameter (when builtin) to prevent Bluetooth from being enabled at boot time:
rfkill.default_state=0
Configuring the kernel
Since the Bluetooth card is connected to the USB subsystem, you will need to enable USB support in your kernel:
- Device Drivers → USB support → <M>Support for Host-side USB (CONFIG_USB)
- Device Drivers → USB support → [*]USB device file system (CONFIG_USB_DEVICEFS)
Choose an appropriate USB host driver, one of:
- Device Drivers → USB support → <M>EHCI HCD (USB 2.0) support (CONFIG_USB_EHCI_HCD)
- Device Drivers → USB support → <M>UHCI HCD support (CONFIG_USB_UHCI)
- Device Drivers → USB support → <M>OHCI HCD support (CONFIG_USB_OHCI)
Enable Bluetooth subsystem and drivers:
- Networking → <*>Bluetooth subsystem support (CONFIG_BT)
- Networking → Bluetooth subsystem support → <*>L2CAP protocol support (CONFIG_BT_L2CAP)
- Networking → Bluetooth subsystem support → <*>SCO links support (CONFIG_BT_SCO)
- Networking → Bluetooth subsystem support → <*>RFCOMM protocol support (CONFIG_BT_RFCOMM)
- Networking → Bluetooth subsystem support → [*]RFCOMM TTY support (CONFIG_BT_RFCOMM_TTY)
- Networking → Bluetooth subsystem support → <*>BNEP protocol support (CONFIG_BT_BNEP)
- Networking → Bluetooth subsystem support → <*>HID protocol support (CONFIG_BT_HID)
- Networking → Bluetooth subsystem support → Bluetooth device drivers → <M>HCI USB driver (CONFIG_BT_HCIUSB)
- Networking → Bluetooth subsystem support → Bluetooth device drivers → [*]SCO (voice) support (CONFIG_BT_HCIUSB_SCO)
Make sure that the according modules are loaded:
# modprobe uhci_hcd ; modprobe ehci_hcd ; modprobe hci_usb
Since 2.6.29 hci_usb is replaced by btusb
- Networking support → Bluetooth subsystem support → Bluetooth device drivers → [m]HCI USB driver (CONFIG_BT_HCIBTUSB)
# modprobe btusb
Serial connection over Bluetooth
One common application is to connect your mobile phone and use it as a modem to connect to the internet via GPRS or 3G (UMTS). A lot of phones do this through using AT-commands on a serial over Bluetooth connection.
By configuring /etc/bluetooth/rfcomm.conf correctly, you'll get a device /dev/rfcomm0.
Eventually one could use the command:
# rfcomm bind 0 00:15:A0:7A:90:F2 3
The hardware address should be replaced with that of your phone. If you don't know the hardware address of your phone yet, you can get it by running:
# hcitool scan
The last parameter ('3') is the channel to use. I spent quite some time fighting before I found out of that one; I didn't find it documented anywhere, but by running
# sdptool records 00:15:A0:7A:90:F2
I found channel 3 to be the right one for my phone. You will have to experiment to find the right one for your phone setup; for T-Mobile GSM/GPRS carrier in USA this is channel 1.
Alternativly one could use the following to find the right channel:
# sdptool search DUN
Inquiring ... Searching for DUN on 00:11:22:33:44:55 ... Service Name: Dial-up Networking Service RecHandle: 0x10001 Service Class ID List: "Dialup Networking" (0x1103) "Generic Networking" (0x1201) Protocol Descriptor List: "L2CAP" (0x0100) "RFCOMM" (0x0003) Channel: 4
Now /dev/rfcomm0 exists.
At this point you can use an automatic dialing utility such as wvdial, editing the config file to point to the modem at /dev/rfcomm0, and everything should work just like a land line!
You may directly access the modem (i.e. by using minicom:)
$ minicom -s
set the serial device to be /dev/rfcomm0, choose 'exit' and then the AT-commands can be typed in. With my operator (Telenor, Norway) it seemed simple enough, I just entered
- ATDT *99#
and lots of cryptic letters started dancing across the screen, indicating a ppp session startup.
To configure pppd create /etc/ppp/peers/nokia with particularly those lines:
/dev/rfcomm0 connect '/usr/sbin/chat -v -f /etc/ppp/chat-nokia' debug 10.0.1.3 crtscts noipdefault ipcp-accept-local defaultroute novj nobsdcomp novjccomp nopcomp noaccomp usepeerdns
Furthermore, you need a simple chat script. Create /etc/ppp/chat-nokia:
'TIMEOUT' '5' 'ABORT' 'BUSY' 'ABORT' 'ERROR' 'ABORT' 'NO ANSWER' 'ABORT' 'NO CARRIER' 'ABORT' 'NO DIALTONE' 'ABORT' 'Invalid Login' 'ABORT' 'Login incorrect' 'ATZ' 'OK' 'ATDT*99#' '~--'
Here's a script that works for Cingular's network:
TIMEOUT 35 ECHO ON ABORT '\nBUSY\r' ABORT '\nERROR\r' ABORT '\nNO ANSWER\r' ABORT '\nNO CARRIER\r' ABORT '\nNO DIALTONE\r' ABORT '\nRINGING\r\n\r\nRINGING\r' \rAT OK 'AT+CGDCONT=1,"IP","WAP.CINGULAR"' OK ATD*99***1# CONNECT ""
See more here
Run pppd with:
$ pppd call nokia
This should establish the internet connection.
For editing phonebook / ringtones / etc., the gammu utils (http://www.gamu.net) has been reported to work well, but this appears to be primarily for Nokia phones.
File Transfer
File transfers are accomplished through OBEX transfer, which I believe is basically an FTP over bluetooth connection. Once you have bonded with your phone (yes, I know you love your sexy RAZR, but here I mean paired it with your laptop via bluetooth), you can easily use "obexftp" to transfer files. As an example,
- obexftp -b 00:01:02:03:04:05 -l
will list the root directory of the phone with bluetooth address 00:01:02:03:04:05. Refer to the man page for more of the unique commands. What a wonderful interface! Unfortunately there doesn't seem to be a way to get a standard 'ftp' session using familiar commands (e.g. 'mget').
For a more user-friendly experience, you can use the kde tools, just launch
- kbtobexclient
for a file browser. In the Location: option put
- obex://[00:01:02:03:04:05]
to list the files. Note that the brackets *are* necessary. From there, you can list directories easily and batch download files.
Mount a phone as a directory
You can also mount a phone as a standard directory using obexfs and the FUSE (file system in userspace) utilities.
Configure your kernel as outlined above.
- Install the required packages
To mount the filesystem we need the fuse program. FuseFS is also implemented in the kernel, but for some reason it only works with 2.6.18. If you run 2.6.17 or earlier, please download it and build the module according to your distro.
- Emerge or apt-get bluez-utils and obexfs. This should pull other required packages (bluez-libs, openobex, obexftp, sys-fs/fuse) as dependencies.
# emerge bluez-utils obexfs
- Modify /etc/bluetooth/hcid.conf if you haven't already. It can be done as above, or use the following:
options { autoinit yes" security user pairing multi pin_helper /usr/bin/bluepin } device { name testname class 0x3e0100 iscan enable pscan enable lm accept lp rswitch,hold,sniff,park }
- load the modules:
# modprobe fuse
# modprobe bluetooth
# modprobe ehci-hcd
# modprobe uhci-hcd
# modprobe hci_usb
# modprobe l2cap
# modprobe rfcomm
- activate your bluetooth (show howto ibm-acpi for more details) by using fn+f5 or:
# echo enable >/proc/acpi/ibm/bluetooth
- start the bluetooth device:
# /etc/init.d/bluetooth start
- turn on bluetooth of your mobile phone (visible mode) and get the mac-address of your phone using hcitool.
# hcitool scan
For non symbian mobile phones
- mount your phone - don't forget to umount it when you're finished
# mkdir /mnt/phone
# mount -t fuse "obexfs#-b00:16:20:32:25:3C -B6" /mnt/phone
use your mac-address instead of my 00:16:20:32:25:3C and don't forget the -b option in front of the mac
Works perfectly with IBM T43p, X41, sony ericsson k750i, nokia 6280, samsung z400, sony ericsson k700i.
Mounting Symbian Phones
- You need network file system support in your kernel
# cd /usr/src/linux
# make menuconfig
- File Systems → Network File Systems → <M>NFS file system support (NFS_FS)
- File Systems → Network File Systems → <M>Provide NFSv3 client support (NFS_V3)
- File Systems → Network File Systems → <M>NFS server support (NFSD)
- File Systems → Network File Systems → <*>Provide NFSv3 server support (NFSD_V3)
- File Systems → Network File Systems → <*>Provide NFS server over TCP support (NFSD_TCP)
# make && make modules_install
- Install required programs
# emerge -av p3nfs
- Modify your /etc/bluetooth/rfcomm.conf
rfcomm0 { bind yes; device 00:0F:DE:8C:E6:94; channel 13; comment "symbian connection" }
- restart your bluetooth device, load kernel modules and start portmap (required for p3nfs)
# /etc/init.d/bluetooth restart
# modprobe nfs
# modprobe nfsd
# /etc/init.d/portmap start
- get the application for your mobile phone here
- start bt at your mobile phone, send application to mobilephone, install and launch the nfsapp with bluetooth at channel 13 (default)
# obexftp -b 00:0F:DE:8C:E6:94 -p /home/tava/ablage/nfsapp*
- mount your mobile phone:
# p3nfsd -UIQ -tty /dev/rfcomm0 -dir /mnt/bluetooth
(-UIQ is only for UIQ-Phones, type p3nfsd --help and get informations for your phone)
- if doesn't work, make sure rfcomm0 is clean
# rfcomm
Building from source
Get the source packages from www.bluez.org.
Build each of them with the usual steps:
$ ./configure && make
# make install
Gentoo ebuilds
Under Gentoo, install the following ebuilds:
- net-wireless/bluez-bluefw
- net-wireless/bluez-firmware
- net-wireless/bluez-hcidump
- net-wireless/bluez-hciemu
- net-wireless/bluez-libs
- net-wireless/bluez-utils
Other distributions
You will find packages for Debian, Red Hat and Slackware on the packages page of the BlueZ project.
Bluez packages are included in Debian Sid (bluez-utils, and non-free package bluez-firmware).
Troubleshooting
If you cant get hci0 up with a /etc/init.d/bluetooth restart (or similar) then you might want to try a
# hciconfig hci0 down && hciconfig hci0 up
(solved the problem on a X60s and T60 (debian/testing))
If there's no physical switch to enable bluetooth, and rfkill list
shows:
0: tpacpi_bluetooth_sw: Bluetooth Soft blocked: no Hard blocked: yes 1: phy0: Wireless LAN Soft blocked: no Hard blocked: no
Try rebooting and resetting BIOS settings to defaults.