安卓2.2。如何设置串口(com、rfcomm)端口?

发布于 2024-10-09 00:00:06 字数 604 浏览 0 评论 0原文

我尝试将 Android 版本 2.2.1 的 Nexus One 与我的电脑连接,并使用 Windows 终端或超级终端等终端程序进行通信。为此,我认为我需要设置一个传出串行 com 端口。我已配对设备。当我在电脑上连接蓝牙时 ->设置-> Android 设备不显示“添加 com 端口”。

我缺少什么?

android 2.2.1支持spp吗?文档说确实如此。

我需要 root 安卓才能添加 spp 吗?

有人成功做到这一点吗?

我的最终目标是编写一个 Android 应用程序,与需要 com 端口的老式蓝牙设备进行通信?让 Android 与 PC 通信是一个临时步骤。

我已经在我的 Android 应用程序中尝试了所有我能想到的方法来连接到我的电脑和 Android 设备,但没有成功。我的 Android 应用程序本质上与 xCaffeniated 提交的 Serial over Bluetooth< 相同/a> 但评论较少。有什么建议吗?

I a trying to connect my Nexus One with Android version 2.2.1 with my pc and use a terminal program such as windows terminal or hyper terminal to communicate. To do this I believe I need to set up an outgoing serial com port. I have paired the devices. When I go on my PC to Bluetooth -> settings -> "add com port" the android device does not display.

What am I missing?

Does android 2.2.1 support spp? The documentation says it does.

Do I need to root the android to add spp?

Has anyone succeeded in this?

My final goal is to write an android app that communicates with an old school bluetooth device that requires com ports? Getting the android to communicate with the pc is an interim step.

I have tried everything I can think of in my android app to connect to my pc and android device but have not been successful. My android app is essentially the same as Serial over Bluetooth submitted by xCaffeniated but with fewer comments. Any suggestions?

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

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

发布评论

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

评论(3

翻身的咸鱼 2024-10-16 00:00:06

尝试从 BluetoothChat 示例应用程序开始。然后,您必须将用于通用 SPP UUID 的 UUID 更改为

00001101-0000-1000-8000-00805F9B34FB

从此时起,您几乎拥有了所需的一切。

我在 BluetoothChat 程序中配对时遇到问题。因此,我需要使用设置菜单与我的计算机配对,然后进入蓝牙聊天程序。在 BTChat 中,转到菜单并点击“连接到设备”,选择您的计算机。我只能说我正在使用的Windows XP SP3。此时,在我的计算机上,我收到一个弹出的任务栏,询问我是否允许我的设备作为串行端口进行连接。我允许它。现在您的手机已关联为计算机上的串行端口配置文件,您可以将其与特定的 com 端口关联。

Try beginning with the BluetoothChat sample application. You will then have to alter the UUID used to the generic SPP UUID,

00001101-0000-1000-8000-00805F9B34FB

From this point you pretty much have everything you need.

I have had issues pairing in the BluetoothChat program. So I was required to pair to my computer using the settings menu and then entering the BluetoothChat Program. In BTChat go to the menu and hit connect to a device, choose your computer. I can only speak for windows XP SP3 which is what I'm using. At this point on my machine I receive a task bar pop up asking me if I would like to allow my device to connect as a serial port. I allow it to. Now your phone is associated as the serial port profile on the computer, which you can associate with a specific com port.

愿与i 2024-10-16 00:00:06

基于蓝牙规范,

http://www.bluetooth.com/SiteCollectionDocuments/SPP_SPEC_V12.pdf,

2.3 用户要求,“...任何遗留应用程序都可以在任一设备上运行,使用虚拟串行端口,就好像有一条真实的串行电缆连接两个设备(具有 RS232 控制信号)。”在 4.3 远程端口协商中,“...如果 RFCOMM 适配层的 API 暴露于这些设置(例如波特率、奇偶校验),则需要这样做...RFCOMM 本身不会人为地限制基于以下内容的吞吐量:波特率设置,...”

在我看来,由于 Android (2.2) 没有提供用于设置和打开串行端口的 API,因此只要您可以发现远程 BT 设备并与其建立连接,它们可能就不是必需的。我已经尝试过了,它似乎可以使用:

...

sock = device.createRfcommSocketToServiceRecord(myUUID);
sock.connect();

...

最终 UUID myUUID= UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); 中所述处理应用程序中的蓝牙权限和设置:

您可能需要按照http: //developer.android.com/guide/topics/wireless/bluetooth.html

connect() 调用可能会出现一些问题,即服务不可用或连接被拒绝,这可以通过确保解决:

  1. 发现远程 BT 设备,并且
  2. 必须将其设置为使用 PIN 码(例如 0000),并且
  3. 必须与您的 Android 设备成功配对

这些步骤必须在运行您的应用程序(具有连接调用)之前完成。

希望这有帮助。

乔治

Based on bluetooth spec,

http://www.bluetooth.com/SiteCollectionDocuments/SPP_SPEC_V12.pdf,

2.3 User Requirement, "... Any legacy application may be run on either device, using the virtual serial port as if there were a real serial cable connecting the two devices (with RS232 control signalling)." In 4.3 Remote Port Negotiation, "...There is a requirement to do so if the API to the RFCOMM adaptation layer exposes to those settings (e.g. baud rate, parity)... RFCOMM as such will not artificially limit the throughput based on baud rate settings,..."

In my opinion, since Android (2.2) offers no APIs to set up and open a serial port, they may not be necessary as long as you can discover the remote BT device and make a connection to it. I have tried it and it seems working with:

...

sock = device.createRfcommSocketToServiceRecord(myUUID);
sock.connect();

...

where final UUID myUUID= UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"); You may need to take care of Bluetooth Permission and Setup in your application as described in

http://developer.android.com/guide/topics/wireless/bluetooth.html

There might be some issues with the connect() call, i.e. Service is not available or connect is refused, which could be resolved by making sure:

  1. The remote BT device be discovered, and
  2. It must be set to use PIN code (for instance 0000), and
  3. It must be paired successfully with your Android device

These steps must be completed prior to running your application (which has connect call).

Hope this help.

George

单调的奢华 2024-10-16 00:00:06

关于 AT 集如何在 AOS 上实现,肯定有一些有趣的事情。问题是很难知道您实际上是直接与调制解调器通信还是通过几个抽象层(更有可能)。有关 AOS 平台上可用的 AT 命令以及硬件的最新最佳回顾,请参阅帖子:

“如何使用 AT 命令与调制解调器对话”
http://forum.xda-developers.com/showthread.php?t=1471241

There is definitely some funny business regarding how the AT set is implemented on the AOS. The problem is that it is hard to know if you're actually talking directly to Modem or through several abstraction layers (more likely). For a best up-to-date review of the AT Commands available on the AOS platform, plus HW, please see the post:

"How to talk to the Modem with AT commands"
http://forum.xda-developers.com/showthread.php?t=1471241

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