bluez 5.0以前版本使用范例脚本
-
hciconfig hci0 up
-
hciconfig hci0 piscan
-
hciconfig hci0 name NDCSR
-
hciconfig hci0 noencrypt
-
hciconfig hci0 noauth
-
bluetooth-agent 0000 &
-
-
sdptool add sp
-
sudo rfcomm listen hci0 &
-
hcitool cmd 0x06 0x0003 (Enter Test Mode)
-
hcitool cmd 0x03 0x0005 0x02 0x00 0x02 (Auto Accept All Connections)
-
hcitool cmd 0x03 0x001A 0x03 (Page Inquiry Scans)
-
hcitool cmd 0x03 0x0020 0x00 (Disable Authentication)
-
hcitool cmd 0x03 0x0022 0x00 (Disable Encryption)
最直接的方式就是使用 bluetoothctl 和 bluetoothd 配合,
bluetoothctl 做客户端程序直接使用命令行输出.
要让被链接部分不需要PIN的显示的方法
Open the /usr/bin/bluez-simple-agent
and change KeyboardDisplay
or DisplayYesNo
(based on whatever you have there) to NoInputNoOutput
. Run bluez-simple-agent
in background and foreground.
也有对应的说明方法
Pairing using CLI 部分
# bluetooth-agent 4835
另外
提到
# hciconfig hci0 sspmode 0
bluetoothctl 命令行在以下命令可以类似 wpa_client 的工具.
# power on
# agent on
# default-agent
# scan on
# pair 00:1D:43:6D:03:26
# connect 00:1D:43:6D:03:26
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
mkdir -p /home/w55fa92bsp-2.6.35/custom_rootfs/
ln -s / /home/w55fa92bsp-2.6.35/custom_rootfs/usr_data
以下服务要开起来.
dbus-daemon --system
bluetoothd &
hciconfig hci0 down
hciconfig hci0 up
sdptool add SP
rfcomm bind /dev/rfcomm0 DC:EE:06:C9:8E:A7
rfcomm show DC:EE:06:C9:8E:A7 可以看到通道号.
sdptool browse DC:EE:06:C9:8E:A7 可以看到通道号.
//终端向手机端发起连接请求
rfcomm connect hci0 DC:EE:06:C9:8E:A7 19
// enable iscan and disable pscan:
hcitool cmd 0x03 0x001A 0x01 //能让手机扫描到设备.
// enable both iscan and pscan:
hcitool cmd 0x03 0x001A 0x03 //能让手机扫描到设备.
#修改名字
hciconfig hci0 name NDClient
hciconfig hci0 noauth
hcitool info DC:EE:06:C9:8E:A7
hcitool cc DC:EE:06:C9:8E:A7
-
//后期有个人的 想法
-
http://stackoverflow.com/questions/12888589/linux-command-line-howto-accept-pairing-for-bluetooth-device-without-pin
-
-
# 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
阅读(3523) | 评论(0) | 转发(0) |