我想在执行新设备发现之前扫描成对的蓝牙设备以寻找服务..
有一种方法可以使用winsock配对蓝牙设备吗?
你能给我一个样品吗?
谢谢!
答案 0 :(得分:4)
回答我自己的问题..
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;