How to use Bluetooth __linux under Linux

Source: Internet
Author: User
How to use Bluetooth under Linux

Bluetooth is a wireless protocol chosen by many mobile device manufacturers, and it is a short-range wireless transmission technology. It has a number of attractive features, the most important of which is its low energy consumption in data transmission. Currently there are three versions of the Bluetooth protocol running on the market: version 1.1, 1.2 Afh and 2.0+edr respectively. The new version of the Protocol is fully compatible with the old version.

Using Bluetooth

Before using Bluetooth, make sure that the kernel you are using is already in Bluetooth support, and that the core of each major Linux vendor's distribution is usually Bluetooth enabled.

Load Module First:

#modprobe Hci_usb (I am using the Bluetooth adapter for USB interface)

#modprobe Rfcomm

Turn on Bluetooth service

#/etc/rc.d/init.d/bluetooth start

To open the device interface:

#hciconfig hci0 up

To view device status:

#hciconfig-A

Hci0:Type:USB

BD address:00:10:60:a3:68:9f ACL mtu:192:8 SCO mtu:64:8

Up RUNNING Pscan Iscan

......

Here will be a list of some of the local Bluetooth interface information, the most important is the BD address interface, the remote Bluetooth device is through this address to access the local.

Use Bluetooth headset

or loading a module

#modprobe Snd_bt_sco

Put the Bluetooth headset in discovery mode and search

#hcitools Scan

Scanning ...

00:0E:07:1C:AE:1D JBR250

Of course, the output you get will not be the same as the above, JBR250 is the headset name, 00:0E:07:1C:AE:1D is the headset's MAC address, note this address, the following will be used.

#hciconfig Hci0 Voice 0x0060

#btsco the MAC address you just wrote down.

The device pairing window will allow you to enter the PIN code, the Bluetooth headset pin is generally fixed, can be found from the manual.

When the connection is established, the audio device corresponding to the Bluetooth headset will be mapped to/DEV/DSP1, and now we can start testing.

In the terminal input aplay--d Plughw:headset sound.wav play a sound file, if you have not heard the sound, please check your headset is not still need to press an answer button.

If all goes well, you can use XMMS or other players to play music to the Bluetooth headset.

Send and receive files

Here's a brief description of how to use the OBEX protocol to transfer files to your phone.

Obex as a general data exchange protocol, is not a Bluetooth-specific protocol, so the Linux basic Bluetooth stack does not provide support for OBEX, we also need third-party tool software to implement file delivery. This kind of tool software is many, take the kdebluetooth in KDE environment as an example to introduce.

Kdebluetooth is a Bluetooth communication tool being developed in the open source community, providing Bluetooth OBEX service, File transfer client, and a set of Bluetooth configuration tools.

First you need to go to Kdebluetooth's official website http://kde-bluetooth.sourceforge.net/download and install the latest kit.

Some specific installation methods are provided here:

Http://docs.kde.org/development/en/extragear-pim/kdebluetooth/download.packages.html offers a suse rpm package, You can use the RPM command to install the RPM package directly, or you can go to http://fred.hexbox.de/debian/to download the latest source code package to compile yourself. Of course, the easiest way to do this is to use Red Flag Linux Desktop 5.0, which is pre-installed with Kdebluetooth and can be used directly.

After installation, the tool can be directly entered in the console KBLUETOOTHD boot, you can click the Start menu-〉 Application-〉 network-〉 bluetooth communication. A Bluetooth image appears in the system tray after startup.

Right click on the icon to select Send file will open the File Send window, at this point the automatic search for remote Bluetooth devices, and the provision of the OBEX Service devices in the window. If the search is over and no device is listed, make sure your phone has Bluetooth turned on.

Drag the file you want to send to the files to be sent window, select the Send object in the Remote Device Selection window (the phone you just mentioned), and then click the Send button. If you're the first to send a file with a mobile phone, at this point need to match, hand opportunity required to enter the PIN code (that is, the pairing code, by the user input, not more than 16 bytes), input confirmation after the host will also appear pin window, will just the phone on the pin again input, two times pin input consistent then paired end, The file begins to transfer.

Receive files from the phone is also very simple, click on the system tray in the Bluetooth icon-〉 local bluetooth configuration-〉 Local Service configuration, to confirm that the Obex file transfer service has been opened, through the "Start" button to open the corresponding services in the list. Then open the phone's file manager, choose to send through Bluetooth, waiting for the phone to search the host, send. This is the host will pop up the window to ask if you agree to receive, select "Yes" to start receiving. Similarly, if you are the first time to receive files from your phone, you need to match, but this time Kdebluetooth will give a pin in advance and display in the window, you can only be displayed in the window of the PIN code correctly input to the phone on it.

In addition to sending files, Kdebluetooth provides a series of graphical configuration management tools instead of command line tools:

To view remote devices: The bluetooth device will be searched periodically to display the results immediately.

View connection information: View the connection status of the current Bluetooth device, or you can manually close an already existing connection.

Serial Communication tools: Kdebluetooth provides a text communication tool based on the serial port, the client can send and receive text messages from each other.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.