linux 蓝牙pin码 问题

大旺 2012-05-03 09:35:02
我现在遇到一个很烦人的问题,我linux系统用的文件系统就是我编译的linux文件系统,没有图形界面的,我现在想蓝牙连接,但是不知道我linux系统如何输入?目前条件是,我linux系统已经将内核/net/bluetooth功能都打开,还移植了bluez工具到我的linux系统里,我利用hciconfig可以看到我的设备,还能hcitool scan 搜索到我的手机,但是我手机想连接他的时候就需要输入pin码,我想知道我linux内核能不能固定一个pin码?或者通过命令来设置pin码?
...全文
1200 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoxiaokun888 2014-07-14
  • 打赏
  • 举报
回复
楼主,我这面手机能扫描到板子端,
引用 4 楼 shenfawang 的回复:
我现在在纯linux文件系统下搞定连接pin问题了,就是在安卓下面没有实现。在linux下的具体方法是在我们去连接设备之前需要使用hcid -f /etc/bluetooth/hcid.conf 来配置文件,而配置文件hcid.conf里有一个关键点需要解决: options { # Automatically initialize new devices autoinit yes; # Security Manager mode # none - Security manager disabled # auto - Use local PIN for incoming connections # user - Always ask user for a PIN # security auto; # Pairing mode # none - Pairing disabled # multi - Allow pairing with already paired devices # once - Pair once and deny successive attempts pairing multi; pin_helper /usr/bin/bluepin; } 这里有个pin_helper /usr/bin/bluepin。意思是建立一个名字叫pin_helper的线程,这里需要在/usr/bin/bluepin下面建立一个标准输出。也就是说这个线程的功能标准输出一个pin吗。可以以脚本的方式: #!/bin/sh echo "PIN:1234" 也可以是c编译好的文件: #include <stdio.h> int main(int argc, char* argv[]) { printf("PIN:1234"); } 这样再运行: #rfcomm bind /dev/rfcomm0 00:06:66:44:88:F2 1 #cat /dev/rfcomm0 就可以去连接对用的设备了。 上面只是纯linux的实现,但是我现在发现把通用的方式用到android底下就不行,显示拒绝连接。上面两个方法都试过了,都不行,大家帮我想想办法呢?是不是android下面的标准输出和linux下面不一样啊?android大侠们指导下,谢谢!
当手机主动连接板子的时候,板子侧如何获得手机的地址啊? 我按你提供的手顺,配对不上,无反应
effortshc 2013-08-09
  • 打赏
  • 举报
回复
楼主 请问你的这个在android下没有rfkill0文件解决了吗?我现在也遇到了这个问题。。求教
大旺 2012-05-14
  • 打赏
  • 举报
回复
我现在在纯linux文件系统下搞定连接pin问题了,就是在安卓下面没有实现。在linux下的具体方法是在我们去连接设备之前需要使用hcid -f /etc/bluetooth/hcid.conf 来配置文件,而配置文件hcid.conf里有一个关键点需要解决:
options {
# Automatically initialize new devices
autoinit yes;

# Security Manager mode
# none - Security manager disabled
# auto - Use local PIN for incoming connections
# user - Always ask user for a PIN
#
security auto;

# Pairing mode
# none - Pairing disabled
# multi - Allow pairing with already paired devices
# once - Pair once and deny successive attempts
pairing multi;
pin_helper /usr/bin/bluepin;
}
这里有个pin_helper /usr/bin/bluepin。意思是建立一个名字叫pin_helper的线程,这里需要在/usr/bin/bluepin下面建立一个标准输出。也就是说这个线程的功能标准输出一个pin吗。可以以脚本的方式:
#!/bin/sh

echo "PIN:1234"
也可以是c编译好的文件:
#include <stdio.h>

int main(int argc, char* argv[])
{
printf("PIN:1234");
}
这样再运行:
#rfcomm bind /dev/rfcomm0 00:06:66:44:88:F2 1
#cat /dev/rfcomm0
就可以去连接对用的设备了。
上面只是纯linux的实现,但是我现在发现把通用的方式用到android底下就不行,显示拒绝连接。上面两个方法都试过了,都不行,大家帮我想想办法呢?是不是android下面的标准输出和linux下面不一样啊?android大侠们指导下,谢谢!
大旺 2012-05-09
  • 打赏
  • 举报
回复
谁来告诉我啊!
大旺 2012-05-09
  • 打赏
  • 举报
回复
我现在发现我在android下面使有下面的错误:
D/BluetoothDeviceService( 1773): Bluetooth state 0 -> 1
W/bluedroid( 1773): open(/sys/class/rfkill/rfkill0/type) failed: No such file or directory (2)
D/BluetoothDeviceService( 1773): Bluetooth state 1 -> 0
我在网上查了说我内核要配置rfkill,但是我内核已经配置了:
455 CONFIG_IEEE80211_CRYPT_WEP=y
456 CONFIG_IEEE80211_CRYPT_CCMP=y
457 CONFIG_IEEE80211_CRYPT_TKIP=y
458 CONFIG_RFKILL=y
459 # CONFIG_RFKILL_PM is not set
460 CONFIG_RFKILL_INPUT=y
461 # CONFIG_NET_9P is not set
我现在发现就是我的一个目录下没有对对应的文件导致的,是sys/class/rfkill/rfkill0 文件夹。
现在怎么办呢?是不是我内核版本低呢,我的版本是linux 2.6.27的!
大家帮我想想办法呢,谢谢!
我发现我手机的android系统里有sys/class/rfkill/rfkill0 ;
为什么我的板子没有呢!
Liv2005 2012-05-03
  • 打赏
  • 举报
回复
试试看默认pin码 0000 或者 1234 之类的....好吧,没玩过这个,等高人...

4,465

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 内核源代码研究区
社区管理员
  • 内核源代码研究区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧