Use Bluetooth in Linux

Source: Internet
Author: User

Use Bluetooth in Linux


Today we will introduce how to use Bluetooth through commands in Linux:


Because my laptop does not have bluetooth, I bought a Bluetooth adapter for the USB interface. Run the following command to open it to our Bluetooth device (line 2 ):


Lsusb



RunHciconfigYou can see:


We can see that our Bluetooth device is hci0

RunHcitool DevWe can see the hardware address of our Bluetooth device.

RunHcitoo -- HelpYou can view more commands



Then we activate it:

Sudo hciconfig hci0 up


Note that Bluetooth must be enabled before activation.Otherwise, the following error occurs:




Then we started scanning:

Hcitool Scan



As you can see, I found my mobile phone's bluetooth ~~



Then we will start the connection. The main command used in the connection phase is RFCOMM:

RunRFCOMM -- HelpYou can view usage


First, bind the target bluetooth device:

Sudo RFCOMM bind/dev/rfcomm0 E0: A6: 70: 8c: A3: 02

Note: The above address is the hardware address of the target bluetooth device.



Then we connect it:

Sudo cat>/dev/rfcomm0


This is the target Bluetooth host. In the dialog box that appears, enter the PIN code. Enter either of them. Then, a dialog box is displayed on the host,As long as the input is consistent with the previous one, it can pass verification.. Then we found that my cell phone had displayed a matched tag.



After pairing, We need to delete the binding (otherwise, the device will be prompted to be busy next time). The command is as follows:

Sudo RFCOMM release/dev/rfcomm0



Now we are about to start Bluetooth transmission:

This part is still being studied... Next time add



Refer:

Http://blog.csdn.net/baozhongchao/article/details/4486263

Http://lnote.blogbus.com/logs/13223547.html

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.