1

我正在尝试使用 Windows 套接字来发现范围内的 BT 设备。为此,我正在使用这篇MSDN文章。

该代码有效,我通过调用WSALookupServiceNext(...)获取设备信息。

设备信息由WSAQUERYSETW结构提供。

我如何根据 WSAQUERYSETW 结构中的数据知道设备是否在范围内?

我可以检查WSAQUERYSETW::dwOutputFlags是否具有以下标志之一:

BTHNS_RESULT_DEVICE_CONNECTED
BTHNS_RESULT_DEVICE_AUTHENTICATED
BTHNS_RESULT_DEVICE_REMEMBERED

如果设备已连接,那么它肯定在范围内,但其他状态呢?

REMEMBERED 状态到底是什么?

4

1 回答 1

0

Those flags aren't mutually exclusive - a device may be all three or none.

  • REMEMBERED means it is listed under 'bluetooth devices' in control panel. It may or may not be in range. The only guarantee we have with Remembered devices is that they were at some point in range in the past.

  • AUTHENTICATED means it has been paired with the device - i.e. if a pin is needed, it has been supplied already. A device can be remembered but not authenticated; however any device that has been authenticated (i.e. windows has paired with it) will be remembered

If a device has been previously paired then removed manually, this un-authenticates it and it will be neither remembered nor authenticated.

于 2013-11-15T01:53:19.973 回答