蓝牙 RFCOMM 连接:从 Windows 7 中的 com 端口读取串行数据
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8291088/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bluetooth RFCOMM connection: read serial data from com port in Windows 7
提问by gavinmh
I am working with the Android Bluetooth Chat sample application. I am trying to read serial data from the Android device in Windows 7.
我正在使用 Android 蓝牙聊天示例应用程序。我正在尝试从 Windows 7 中的 Android 设备读取串行数据。
I have been able to pair the Android device to the Bluetooth adapter on my laptop. I replaced the UUID in the sample application with the following per some other discussions:
我已经能够将 Android 设备与笔记本电脑上的蓝牙适配器配对。根据其他一些讨论,我用以下内容替换了示例应用程序中的 UUID:
private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
When I run the Android application I am able to connect to the laptop. In the "Hardware" properties of my Android device there is a "Device Function" entry called "Standards Serial over Bluetooth link (COM10)". When I attempt to connect CoolTerm to COM10 I receive "error 1168" (there is no additional description for the error).
当我运行 Android 应用程序时,我能够连接到笔记本电脑。在我的 Android 设备的“硬件”属性中,有一个名为“蓝牙链接标准串行 (COM10)”的“设备功能”条目。当我尝试将 CoolTerm 连接到 COM10 时,我收到“错误 1168”(没有对该错误的额外描述)。
Am I misunderstanding something about the process of sending serial data via Bluetooth to a Windows com port?
我是否误解了通过蓝牙将串行数据发送到 Windows com 端口的过程?
采纳答案by Hyman
Be sure that you are selecting the correctCOM. In my last Android application that required SPP (Serial Port Profile) Bluetooth communication, when Windows 7 paired I had several COM's open up.
确保您选择了正确的COM。在我上一个需要 SPP(串行端口配置文件)蓝牙通信的 Android 应用程序中,当 Windows 7 配对时,我打开了几个 COM。
If COM10 is not working, verify that it is the "incoming" COM (or maybe it's outgoing, I can't remember b/c it's been a few months).
如果 COM10 不工作,请确认它是“传入”COM(或者它可能是传出的,我不记得 b/c 已经几个月了)。
回答by adanteny
You have to use the proper Bluetooth API from your Windows application to call and connect to your Android device, that is:
您必须使用 Windows 应用程序中正确的蓝牙 API 来调用并连接到您的 Android 设备,即:
- do an 'Inquiry' of all nearby devices, discoverable and exposing an SPP service/profile (SPP=Serial Profile Protocole). This profile has the aforementioned GUID {00001101-0000-1000-8000-00805F9B34FB}
- once all found, select the one you're searching for (either by Name or MacAdress)
- at this point, you can do a 'Discovery' of its Services and check out that it has the proper service exposed (SPP or RFCOMM)
- then connect to it, using the Bluetooth socket API...
- 对附近的所有设备进行“查询”,可发现并公开 SPP 服务/配置文件(SPP=串行配置文件协议)。此配置文件具有上述 GUID {00001101-0000-1000-8000-00805F9B34FB}
- 全部找到后,选择您要搜索的那个(按名称或 MacAdress)
- 此时,您可以对其服务进行“发现”并检查它是否公开了适当的服务(SPP 或 RFCOMM)
- 然后使用蓝牙套接字 API 连接到它...