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