Hi.
I'm new to Bluetooth and am discovering quite quickly how to lose 90% of
one's hair in less than a week.
I have an iPAQhx2700 PPC. I will soon also have a Dell PPC. Both with
bluetooth and Wifi.
I am trying to discover the bluetooth devices that the iPAQ sees. So, I
tried out the sample code in MSDN :
#define MAX_NAME 248
WSAQUERYSET wsaq;
HANDLE hLookup;
FILE *file;
int tries=0;
union {
CHAR buf[5000];
double __unused; // ensure proper alignment
};
file=_tfopen(_T("/Temp/dump.txt"), _T("w"));
LPWSAQUERYSET pwsaResults = (LPWSAQUERYSET) buf;
DWORD dwSize = sizeof(buf);
BOOL bHaveName;
pwsaResults = (LPWSAQUERYSET) buf;
dwSize = sizeof(buf);
ZeroMemory(&wsaq, sizeof(wsaq));
wsaq.dwSize = sizeof(wsaq);
wsaq.dwNameSpace = NS_BTH;
wsaq.lpcsaBuffer = NULL;
if (ERROR_SUCCESS != WSALookupServiceBegin (&wsaq, LUP_CONTAINERS,
&hLookup))
{
_ftprintf(file, L"WSALookupServiceBegin failed %d\r\n", GetLastError());
if (tries == 10) {
fclose(file);
return FALSE;
} else {
Sleep(100);
}
}
ZeroMemory(pwsaResults, sizeof(WSAQUERYSET));
pwsaResults->dwSize = sizeof(WSAQUERYSET);
pwsaResults->dwNameSpace = NS_BTH;
pwsaResults->lpBlob = NULL;
while (ERROR_SUCCESS == WSALookupServiceNext (hLookup,
LUP_RETURN_NAME | LUP_RETURN_ADDR, &dwSize, pwsaResults))
{
ASSERT (pwsaResults->dwNumberOfCsAddrs == 1);
BT_ADDR b = ((SOCKADDR_BTH
*)pwsaResults->lpcsaBuffer->RemoteAddr.lpSockaddr)->btAddr;
bHaveName = pwsaResults->lpszServiceInstanceName &&
*(pwsaResults->lpszServiceInstanceName);
_ftprintf (file, _T("%s%s%04x%08x%s\n"), bHaveName ?
pwsaResults->lpszServiceInstanceName : L"",
bHaveName ? L"(" : L"", GET_NAP(b), GET_SAP(b), bHaveName ? L")" :
L"");
}
fclose(file);
WSALookupServiceEnd(hLookup);
return TRUE;
Systematically the WSALookupServiceBegin() function fails with error
10108. From what I read, I'm not the only one encountering this error.
The problem is that I don't understand *why* I'm getting this error.
Is it because the iPAQ has a Widcomm BT stack? In this case, is there
some other way to discover BT devices without having to buy the SDK? And
especially, is there some way of detecting the devices that would work
on *ALL* PPCs? With Widcomm or Microsoft stack?
In advance, thanks.