简体   繁体   English

蓝牙RFCOMM连接:在Windows 7中从com端口读取串行数据

[英]Bluetooth RFCOMM connection: read serial data from com port in Windows 7

I am working with the Android Bluetooth Chat sample application. 我正在使用Android蓝牙聊天示例应用程序。 I am trying to read serial data from the Android device in Windows 7. 我正在尝试从Windows 7中的Android设备读取串行数据。

I have been able to pair the Android device to the Bluetooth adapter on my laptop. 我已经能够将Android设备与笔记本电脑上的蓝牙适配器配对。 I replaced the UUID in the sample application with the following per some other discussions: 在其他一些讨论中,我将示例应用程序中的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. 当我运行Android应用程序时,我可以连接到笔记本电脑。 In the "Hardware" properties of my Android device there is a "Device Function" entry called "Standards Serial over Bluetooth link (COM10)". 在我的Android设备的“硬件”属性中,有一个“设备功能”条目,称为“蓝牙标准串行链接(COM10)”。 When I attempt to connect CoolTerm to COM10 I receive "error 1168" (there is no additional description for the error). 当我尝试将CoolTerm连接到COM10时,我收到“错误1168”(该错误没有其他描述)。

Am I misunderstanding something about the process of sending serial data via Bluetooth to a Windows com port? 我是否对通过蓝牙将串行数据发送到Windows com端口的过程有误解?

You have to use the proper Bluetooth API from your Windows application to call and connect to your Android device, that is: 您必须使用Windows应用程序中正确的Bluetooth API来调用并连接到Android设备,即:

  1. do an 'Inquiry' of all nearby devices, discoverable and exposing an SPP service/profile (SPP=Serial Profile Protocole). 对附近的所有设备进行“查询”,以发现并公开SPP服务/配置文件(SPP =串行配置文件协议)。 This profile has the aforementioned GUID {00001101-0000-1000-8000-00805F9B34FB} 该配置文件具有上述GUID {00001101-0000-1000-8000-00805F9B34FB}
  2. once all found, select the one you're searching for (either by Name or MacAdress) 找到所有对象后,选择要搜索的对象(按名称或MacAdress)
  3. at this point, you can do a 'Discovery' of its Services and check out that it has the proper service exposed (SPP or RFCOMM) 此时,您可以对其服务进行“发现”,并检查其是否暴露了适当的服务(SPP或RFCOMM)
  4. then connect to it, using the Bluetooth socket API... 然后使用蓝牙套接字API连接到它...

Be sure that you are selecting the correct COM. 确保选择正确的 COM。 In my last Android application that required SPP (Serial Port Profile) Bluetooth communication, when Windows 7 paired I had several COM's open up. 在我的上一个需要SPP(串行端口配置文件)蓝牙通信的Android应用程序中,当Windows 7配对时,我打开了多个COM。

已创建的所有COM的BT设置图片

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(或者可能是传出的COM,我记不清b / c已经几个月了)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM