获取蓝牙配对设备

发布于 2024-09-01 15:39:33 字数 102 浏览 9 评论 0原文

我想在发现新设备之前扫描配对的蓝牙设备以查找服务。

有没有一种方法可以使用 winsock 来配对蓝牙设备?

你能给我提供一个样品吗?

谢谢!

I would like to scan paired bluetooth devices to look for services before perform a discovery of new devices..

There's a way to get paired bluetooth devices with winsock?

Could you provide me a sample?

Thanks!

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

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

发布评论

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

评论(1

无人问我粥可暖 2024-09-08 15:39:33

回答我自己的问题..

HBLUETOOTH_DEVICE_FIND founded_device;

BLUETOOTH_DEVICE_INFO device_info;
device_info.dwSize = sizeof(device_info);

BLUETOOTH_DEVICE_SEARCH_PARAMS search_criteria;
search_criteria.dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS);
search_criteria.fReturnAuthenticated = TRUE;
search_criteria.fReturnRemembered = FALSE;
search_criteria.fReturnConnected = FALSE;
search_criteria.fReturnUnknown = FALSE;
search_criteria.fIssueInquiry = FALSE;
search_criteria.cTimeoutMultiplier = 0;

founded_device = BluetoothFindFirstDevice(&search_criteria, &device_info);

if (founded_device == NULL)
{
    _tprintf(TEXT("Error: \n%s\n"), getErrorMessage(WSAGetLastError(), error));
    return -1;
}

do
{
    _tprintf(TEXT("founded device: %s\n"), device_info.szName);

} while (BluetoothFindNextDevice(founded_device, &device_info));
return 0;

answering my own question..

HBLUETOOTH_DEVICE_FIND founded_device;

BLUETOOTH_DEVICE_INFO device_info;
device_info.dwSize = sizeof(device_info);

BLUETOOTH_DEVICE_SEARCH_PARAMS search_criteria;
search_criteria.dwSize = sizeof(BLUETOOTH_DEVICE_SEARCH_PARAMS);
search_criteria.fReturnAuthenticated = TRUE;
search_criteria.fReturnRemembered = FALSE;
search_criteria.fReturnConnected = FALSE;
search_criteria.fReturnUnknown = FALSE;
search_criteria.fIssueInquiry = FALSE;
search_criteria.cTimeoutMultiplier = 0;

founded_device = BluetoothFindFirstDevice(&search_criteria, &device_info);

if (founded_device == NULL)
{
    _tprintf(TEXT("Error: \n%s\n"), getErrorMessage(WSAGetLastError(), error));
    return -1;
}

do
{
    _tprintf(TEXT("founded device: %s\n"), device_info.szName);

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