简体   繁体   English

如何让bluez 5接受固定引脚?

[英]How do I get bluez 5 to accept a fixed pin?

I can find nothing on how to do this. 我怎么也找不到如何做到这一点。 I am programming an Intel Edison in C and an Android phone in Java. 我正在使用C语言编写英特尔Edison和使用Java编写Android手机。 I want to pair the Edison from the Android phone. 我想从Android手机配对爱迪生。 I would think simple pairing (sspmode 1) would work but I get an error message on the phone about a wrong pin where no pin was requested. 我认为简单的配对(sspmode 1)可以工作,但我在手机上收到一条错误消息,指出没有请求引脚的错误引脚。 With sspmode 0 I get asked for a password but have no idea what it is as it is randomly generated in my NoInputNoOutput Edison. 使用sspmode 0我会被要求输入密码但不知道它是什么,因为它是在我的NoInputNoOutput Edison中随机生成的。 We have everything else working. 我们还有其他一切工作。 If we pair from Edison manually, the rest of the code can connect and send bluetooth messages back and forth from the Edison to the phone. 如果我们手动配对爱迪生,其余的代码可以连接并从爱迪生到手机来回发送蓝牙信息。 But pairing from Edison to any random phone that walks by is not acceptable. 但是,从爱迪生到任何随机电话的配对都是不可接受的。 I think it is called Bluejacking. 我认为这叫做Bluejacking。

I have seen some posts about using simple-agent but frankly what I understand is that BlueZ security changed so much between 4 and 5 that most all that I see doesn't work. 我看过一些关于使用简单代理的帖子,但坦率地说,我理解的是BlueZ安全性在4到5之间变化很大,我看到的大多数都不起作用。 I also see that the switch from 4 to 5 broke a lot of systems so I don't feel alone. 我也看到从4到5的切换打破了很多系统,所以我不觉得孤单。 I would try it but simple-agent is not on Edison and I have not found a procedure to install it. 我会尝试,但简单代理不在爱迪生,我没有找到安装它的程序。 And as I don't know if the little I can find applies to version 5 as it all references version 4 I am feeling a little lost. 而且我不知道我能找到的小版本是否适用于版本5,因为它都引用了版本4,我感觉有点迷失。

Can anyone point me in the right direction to something that will work on BlueZ 5? 任何人都可以指出我正确的方向可以在BlueZ 5上运行吗? I am on 5.18. 我在5.18。

The solution presented on the last post of this article does work http://www.linuxquestions.org/questions/linux-wireless-networking-41/setting-up-bluez-with-a-passkey-pin-to-be-used-as-headset-for-iphone-816003/ 本文最后一篇文章中提供的解决方案可以正常工作http://www.linuxquestions.org/questions/linux-wireless-networking-41/setting-up-bluez-with-a-passkey-pin-to-be-使用-AS-耳机换iphone-816003 /

Edit simple-agent, put it somewhere, make it executable, put the missing files in the same directory and run it. 编辑简单代理,将其放在某处,使其可执行,将丢失的文件放在同一目录中并运行它。 It must stay running for it to be active. 必须保持运行才能使其处于活动状态。

In my case, the missing file was bluezutils.py. 就我而言,丢失的文件是bluezutils.py。

Run hciconfig hci0 sspmode 0 first 首先运行hciconfig hci0 sspmode 0

Pl use Bluz5.30. Pl使用Bluz5.30。 Initially it was really difficult to bring up bluetooth using Bluez 5. It seems it was okay with Bluez 4.I have tried different versions of Bluez 5 on my LFS build. 最初使用Bluez 5开启蓝牙真的很难。看起来Bluez 4没问题。我在LFS版本上尝试过不同版本的Bluez 5。 Even up to Bluez 5.28 it was not satisfactory. 即使达到Bluez 5.28也不尽如人意。 Now it is Bluz5.30, with this, LFS doc and lot of trail, I could manage. 现在它是Bluz5.30,有了这个,LFS doc和很多路径,我可以管理。 I feel Bluez is one of the most badly documented user unfriendly software. 我觉得Bluez是最糟糕的用户不友好软件之一。 I also feel it is very buggy. 我也觉得这很麻烦。 It can hang machines forcing to hard boot the system. 它可以挂起机器强制硬启动系统。 I have seen bluetooth forcing the Android phone also to reboot. 我见过蓝牙强迫Android手机重启。 So it is important to get the latest version of the software. 因此,获取最新版本的软件非常重要。 But to make the bluetooth speaker work Pulseaudio was needed. 但要使蓝牙音箱工作需要Pulseaudio。 It is better to get the latest version; 最好是获得最新版本; here also LFS doc was fine. 这里也LFS文件很好。 So the process of connecting speaker was using bluetoothctl is as follows; 所以连接扬声器的过程是使用bluetoothctl如下;

>> power on
>> scan on
>> pairable on
>> pair <device>

>> agent on
>> default-agent

Now the actual sound. 现在实际的声音。 Here pactl and pacmd are useful. 这里pactl和pacmd很有用。 paplay -d can test the devices. paplay -d可以测试设备。 using pacmd with command 'list-sinks' can show the devices. 使用pacmd和命令'list-sinks'可以显示设备。

pacmd ->list-modules can show the modules loaded. pacmd - > list-modules可以显示加载的模块。

How to change automatically the audio output to bluetooth speaker when it is connected? 如何在连接时自动将音频输出更改为蓝牙音箱?

For me in one machine it was working fine, with an identical LFS in another machine it was not working. 对于我在一台机器上它工作正常,在另一台机器上使用相同的LFS它不能正常工作。 Finally it was identified as a missing module module-device-manager with arg do_routing=1. 最后,它被确定为缺少模块模块 - 设备管理器,arg do_routing = 1。

Once it was loaded everything was fine. 一旦装好,一切都很好。 This particular module was not shown in the pulse configurations. 脉冲配置中未显示该特定模块。 So I have to find that and load, pacmd 所以我必须找到并加载,pacmd

load-module module-device-manager do_routing=1 One can add a line in the default configuration file available in /etc/pulse.or one can add it in the user configuration file also.Now to make the new bluetooth speaker being used to play sound. load-module module-device-manager do_routing = 1可以在/etc/pulse中的默认配置文件中添加一行。或者也可以在用户配置文件中添加一行。现在可以使用新的蓝牙音箱播放声音。 For that issue the command 'move-sink-input ' using pacmd. 对于那个问题,命令'move-sink-input'使用pacmd。 You can find the sink names my issuing the command 'list-sinks'. 你可以找到我发出命令'list-sinks'的接收器名称。 If your speaker is not connecting, it may be that it is already connected elsewhere. 如果您的扬声器没有连接,可能是它已连接到其他地方。 If it is not so, remove-device; 如果不是这样,请删除设备; scan on; 扫描; pair; 对; and connect using bluetoothctl. 并使用bluetoothctl连接。 I was worrying how to make file transfer using bluetooth (Bluez5). 我担心如何使用蓝牙进行文件传输(Bluez5)。 Actually very little information is available in LFS documention or in general in the NET. 实际上,LFS文档或NET中的一般信息很少。 This very true and unfortunate about Bluez in general. 对于Bluez来说,这是非常不幸的。 They do not provide any real user doc or nothing is available in net. 他们不提供任何真实的用户文档或网络中没有任何内容。 So the steps are as follows: You need to install OBEX library. 所以步骤如下:您需要安装OBEX库。 Then you build Bluez5 (if it not done already). 然后你构建Bluez5(如果还没有完成)。 It will install obexd. 它将安装obexd。 After installation you can find obexd in $PREFIX/libexec/bluetooth/obexd.This is where you find bluetoothd also. 安装完成后,您可以在$ PREFIX / libexec / bluetooth / obexd中找到obexd。这也是您找到bluetoothd的地方。 One generally makes a link for bluetoothd in /usr/sbin. 一般在/ usr / sbin中为bluetoothd建立链接。 A similar link can be made for obexd also. 也可以为obexd建立类似的链接。 Once you start bluetoothd and obexd you can find object transfer profiles in bluetoothctl->show.If you need a phone to push objects to the computer, you need to run obexd with options '-a' and '-r '. 一旦启动bluetoothd和obexd,你可以在bluetoothctl-> show中找到对象传输配置文件。如果你需要一个手机将对象推送到计算机,你需要使用选项'-a'和'-r'运行obexd。 if '-a' is not given phone will fail to send the file. 如果'-a'没有给出电话将无法发送文件。 Now how to push a file from Computer to Phone. 现在如何将文件从计算机推送到手机。 For this you need obexctl, I do not think it is a finished tool, and it will not be installed while we build Bluez 5. I have seen it in the source tree and copied to /usr/bin/. 为此你需要obexctl,我不认为它是一个完成的工具,并且在我们构建Bluez 5时它不会被安装。我在源代码树中看到它并复制到/ usr / bin /。 It should be used to connect the Phone and when the connection is established one can 'send ' and you have to accept the request in the phone. 它应该用于连接电话,当建立连接时,可以“发送”,你必须接受电话中的请求。

Starting obexd as a deamon was a problem. 作为deamon开始obexd是一个问题。 When obexd was tried on a text terminal (init 3) it was not possible to start since it needs a dbus session which in turn needs X display. 当在文本终端(init 3)上尝试obexd时,它无法启动,因为它需要一个dbus会话,而后者又需要X显示。 It means one need to login an X seession before you start obexd. 这意味着在启动obexd之前需要登录X seession。 If you dissable X while building DBUS (--without-x) then Window Managers will not work. 如果您在构建DBUS(--without-x)时不能使用X,那么Window Managers将无法工作。 But there is solution with 'dus-run-session < command> [args]'. 但是有'dus-run-session <command> [args]'的解决方案。 That means you can start a service obexd (like bluetoothd) in the system start-up. 这意味着您可以在系统启动时启动服务obexd(如bluetoothd)。 So just by switching on the Computer ( if pairing, trusting etc... was done earlier) one can push files from Phone to computer. 因此,只需打开计算机(如果配对,信任等.​​..之前已完成),就可以将文件从手机推送到计算机。

>> connect <device>

Second time onwards just connection is fine. 第二次以后连接就好了。 Probably you can trust the device. 可能你可以相信这个设备。

>> trust <device>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM