ACTION_ACL_CONNECTED后创建与蓝牙设备的套接字连接
如果我的应用程序在收到 ACTION_ACL_CONNECTED 广播之前等待“接受”调用,我可以从蓝牙设备获得工作连接。如果我发出“接受”调用来响应接收到的广播,我将无法建立套接字连接。
有没有办法实现这种情况,以便我可以设置套接字连接来响应蓝牙事件?
I can get a working connection from a Bluetooth device if my application is waiting on an 'accept' call prior to the ACTION_ACL_CONNECTED broadcast being received. If I issue the 'accept' call in response to the broadcast being received I can't make the socket connection.
Is there a way to make this happen so I can setup the socket connection in response to the Bluetooth event?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不认为有一种方法可以接受对 ACTION_ACL_CONNECTED 的响应,它的设计与常规 TCP 套接字类似,仅进行侦听(用蓝牙术语来说,这意味着在 SDP 记录中注册服务 UUID 并等待传入连接)当调用accept()时。
如果您担心accept调用上的阻塞并且无法负担专用线程来阻塞accept(),则可以尝试accept(timeout)
I dont think there is a way to accept in response to an ACTION_ACL_CONNECTED, this is designed to work similar to regular TCP sockets, the listening only happens (which in bluetooth terms means registering the service UUID in the SDP record and waiting for incoming connections) when the accept() call is made.
You can try accept(timeout) if you are concerned about blocking on the accept call and cant afford to have a dedicated thread to block on the accept()