2
votes

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!

1

1 Answers

4
votes

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;