Android——蓝牙读写问题?

发布于 2024-10-06 10:37:37 字数 282 浏览 0 评论 0原文

在测试和分析蓝牙聊天代码时,我对自己的程序有疑问。

a) 我的程序向另一个蓝牙设备发送命令。 (我可以使用提供的示例代码来处理它)

b)然后它会收到对我之前的命令的响应。

c) 根据收到的响应,我的设备发送另一个命令。

d) 然后它会收到对我的命令的响应。

相同的过程继续......

我的问题是,在蓝牙聊天程序中有一个接收响应的处理程序。我如何确保收到第一个响应,然后使用它发送另一个命令...然后使用相同的处理程序根据第二个命令再次接收响应。

While testing and analyzing code of Bluetooth Chat, I have questions about my own program.

a) My program sends a command to another bluetooth device. (I can handle it using sample code provided)

b) It then receives a response to my previous command.

c) Based on the response received, my device sends another command.

d) It then receives a response to my command.

and the same procedure continues ...

My question is , in Bluetooth Chat program there is a handler which receives a response. How can I make sure to receive first response and then used that to send another command ... and then receive a response again based on second command, using that same handler.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

稀香 2024-10-13 10:37:37

我的问题是,在蓝牙聊天程序中有一个接收响应的处理程序。我如何确保收到第一个响应,然后使用它发送另一个命令...然后使用相同的处理程序根据第二个命令再次接收响应。

使用状态机怎么样?

My question is , in Bluetooth Chat program there is a handler which receives a response. How can I make sure to receive first response and then used that to send another command ... and then receive a response again based on second command, using that same handler.

How about using a state machine?

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