Wince蓝牙虚拟串口问题点

首先需要看https://msdn.microsoft.com/zh-cn/library/aa915916.aspx(Creating a Connection to a Remote Device Using a Virtual COM Port)
和https://msdn.microsoft.com/zh-cn/library/aa916259.aspx (Creating a Connection to a Remote Device Using Winsock)英文文档

步骤按照MSDN描述进行

问题:出现CreateFile成功,但是ReadFile收不到数据,并且所有串口操作API都失败,错误值2250(此网络连接不存在)

后来找到是因为Channel问题,另一端蓝牙设备通道为0,但是Wince端通过socket方式确定通道为1,后另一端蓝牙设备修改通道后,传输成功


疑惑在Creating a Connection to a Remote Device Using Winsock文档中

To create a client socket创建服务器端socket

3.Store information about the remote Bluetooth device that the client is connecting to, by configuring a SOCKADDR_BTH structure.

c.If the service identifier is available, then set the serviceClassId member of SOCKADDR_BTH to the GUID of the RFCOMM-based service. In this case, the client performs an SDP query and then uses the resulting server channel. 

- or- 
If you want to use a hard-coded channel number, set the port member of SOCKADDR_BTH to the server channel number as the following example code shows. 


有人知道serviceClassId怎么使用吗?

你可能感兴趣的:(Wince)