ACTION_ACL_CONNECTED后创建与蓝牙设备的套接字连接

发布于 2024-10-05 01:37:07 字数 142 浏览 2 评论 0原文

如果我的应用程序在收到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

无边思念无边月 2024-10-12 01:37:07

我不认为有一种方法可以接受对 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()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文