首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Raspberry Pi中将android- bluez连接到bluez

在Raspberry Pi中将android- bluez连接到bluez
EN

Stack Overflow用户
提问于 2019-06-24 03:28:30
回答 1查看 290关注 0票数 0

我需要将android-BluetoothChat连接到树莓派B+,最好是无头的。我安装了脚本here来让Pi自动接受配对请求,我的安卓平板电脑(一台沃尔玛ONN)显示它与我的Pi配对。正确的MAC地址显示在BluetoothAdapter.getDefaultAdapter().getBondedDevices()的列表中。

当我运行rfcomm-server.py示例脚本时,它最终显示为Accepted connection from ('B4:4B:D6:EE:A2:1C', 1)

但是android-BluetoothChat应用程序中的mmSocket.connect()行失败了,出现了可怕的错误java.io.IOException: read failed, socket might closed or timeout, read ret: -1

当我invoke秘密方法createRfcommSocket()时,我仍然得不到连接,StackOverflow推荐这个方法来消除这个错误。

那么接下来我应该尝试什么呢?

另一个问题:接口中的UUID是用来做什么的?服务器( Pi)是否需要匹配此UUID?我没有看到android-BluetoothChat程序随机生成一个的原因。

这是一些日志,在任何人不得不要求它之前:

代码语言:javascript
复制
D/BluetoothChatService: connect to: B8:27:EB:8D:DC:E7
D/BluetoothChatService: updateUserInterfaceTitle() 1 -> 2
I/BluetoothChatService: BEGIN mConnectThread SocketType:Insecure
W/BluetoothAdapter: getBluetoothService() called with no BluetoothManagerCallback
V/PhoneWindow: DecorView setVisiblity: visibility = 0, Parent = android.view.ViewRootImpl@d4eebde, this = DecorView@22c41bf[MainActivity]
D/Surface: Surface::disconnect(this=0x7c9bc96000,api=1)
D/Surface: Surface::disconnect(this=0x7c9bc96000,api=1)
W/libEGL: EGLNativeWindowType 0x7c9bc96010 disconnect failed
V/PhoneWindow: DecorView setVisiblity: visibility = 4, Parent = android.view.ViewRootImpl@5720682, this = DecorView@7351cf7[DeviceListActivity]
D/View: [Warning] assignParent to null: this = DecorView@7351cf7[DeviceListActivity]
D/BluetoothSocket: close() this: android.bluetooth.BluetoothSocket@53c843d, channel: -1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@f3d1432, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@9d50583mSocket: android.net.LocalSocket@db37300 impl:android.net.LocalSocketImpl@4722739 fd:java.io.FileDescriptor@ba4417e, mSocketState: INIT
D/BluetoothChatService: updateUserInterfaceTitle() 2 -> 0
D/BluetoothChatService: start
D/BluetoothSocket: close() this: android.bluetooth.BluetoothSocket@53c843d, channel: -1, mSocketIS: android.net.LocalSocketImpl$SocketInputStream@f3d1432, mSocketOS: android.net.LocalSocketImpl$SocketOutputStream@9d50583mSocket: null, mSocketState: CLOSED
D/BluetoothChatService: updateUserInterfaceTitle() 0 -> 0
D/ViewRootImpl[Toast]: hardware acceleration = true , fakeHwAccelerated = false, sRendererDisabled = false, forceHwAccelerated = false, sSystemRendererDisabled = false
D/Surface: Surface::connect(this=0x7c8b558000,api=1)
D/Surface: Surface::allocateBuffers(this=0x7c8b558000)
D/mali_winsys: EGLint new_window_surface(egl_winsys_display *, void *, EGLSurface, EGLConfig, egl_winsys_surface **, EGLBoolean) returns 0x3000
D/Surface: Surface::disconnect(this=0x7c8b558000,api=1)
D/Surface: Surface::disconnect(this=0x7c8b558000,api=1)
W/libEGL: EGLNativeWindowType 0x7c8b558010 disconnect failed
D/View: [Warning] assignParent to null: this = android.widget.LinearLayout{3348471 V.E...... ......ID 0,0-202,49}
I/d.bluetoothcha: Compiler allocated 5MB to compile void android.view.ViewRootImpl.performTraversals()
EN

回答 1

Stack Overflow用户

发布于 2019-06-25 01:16:33

解决方案是根据How to connect to Raspberry pi with an android app over bluetooth将MY_UUID_INSECURE更改为00001101-0000-1000-8000-00805F9B34FB

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56727146

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档