39

有没有一种方法可以在不需要引脚的情况下在 linux 中配对设备(出于测试目的,所以我需要在没有人工交互的情况下完成它,假设您具有 root 访问权限)?

bluez-simple-agent 似乎需要一个别针,除了一些简单的设备(例如鼠标)。

4

7 回答 7

34

输入 PIN 实际上是一种过时的配对方法,现在称为Legacy Pairing。安全简单配对模式适用于蓝牙 v2.1 及更高版本,包括大多数现代蓝牙设备。SSPMode 身份验证由蓝牙协议栈处理,因此无需用户交互即可工作。

以下是连接设备的方法:

# hciconfig hci0 sspmode 1
# hciconfig hci0 sspmode
hci0:   Type: BR/EDR  Bus: USB
BD Address: AA:BB:CC:DD:EE:FF  ACL MTU: 1021:8  SCO MTU: 64:1
Simple Pairing mode: Enabled
# hciconfig hci0 piscan
# sdptool add SP
# hcitool scan
    00:11:22:33:44:55    My_Device
# rfcomm connect /dev/rfcomm0 00:11:22:33:44:55 1 &
Connected /dev/rfcomm0 to 00:11:22:33:44:55 on channel 1
Press CTRL-C for hangup

这将建立与设备的串行连接。

于 2012-10-24T17:31:47.660 回答
19

follow steps (CentOs):

  1. bluetoothctl
  2. devices
  3. scan on
  4. pair 34:88:5D:51:5A:95 (34:88:5D:51:5A:95 is my device code,replace it with yours)
  5. trust 34:88:5D:51:5A:95
  6. connect 34:88:5D:51:5A:95

If you want more details https://www.youtube.com/watch?v=CB1E4Ir3AV4

于 2017-04-15T11:27:09.337 回答
11

尝试在 /etc/bluetooth/hcid.conf 中将安全设置为无

http://linux.die.net/man/5/hcid.conf

这可能仅适用于 HCI 设备(鼠标、键盘、太空球等)。如果您有不同类型的设备,则可能需要更改不同但相似的设置。

于 2012-10-24T00:03:47.557 回答
8

这对我来说就像一个魅力,当然它需要超级用户权限:-)

# hcitool cc <target-bdaddr>; hcitool auth <target-bdaddr>

为了让<target-bdaddr>你可以发出以下命令:
$ hcitool scan

注意:排除#&$因为它们是命令行提示符。

礼貌

于 2014-03-22T09:32:10.650 回答
7

对于 Ubuntu 14.04 和 Android 尝试:

hcitool scan #get hardware address
sudo bluetooth-agent PIN HARDWARE-ADDRESS

Android 设备上会弹出 PIN 对话框。输入相同的 PIN。

注意:sudo apt-get install bluez-utils可能是必要的。

Note2: If PIN dialog does not appear, try pairing from Android first (will fail because of wrong PIN). Then try again as described above.

于 2015-05-16T18:50:24.037 回答
1
~ $ hciconfig noauth

This should do the trick (I'm using bluez 5.23 and there's no more simple-egent and blue-utils). However, I'm trying to look for a way to make changes hciconfig permanent because after power out and then power on, authentication is needed again. So far, the changes in hciconfig still stays the same when you reboot it. it reverts back only when power out. If anybody has found a way to make hciconfig permanent, do let me know!

于 2016-11-09T03:28:04.110 回答
0
~ $ hciconfig noauth

It worked for me in "Linux mx 4.19"

The exact steps are:

1) open a terminal - run: "hciconfig noauth"
2) use the blueman-manager gui to pair the device (in my case it was a keyboard)
3) from the blueman-manager choose "connect to HID"

step(3) is normally asking for a password - the "hciconfig noauth" makes step(3) passwordless

于 2020-05-13T06:25:37.237 回答