From: Emmanuel Viollet on
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.
From: Peter Foot [MVP] on
Sorry to say but there isn't a single method which works on all stacks, the
IPaq range all use Widcomm/Broadcom, the winsock APIs only work with the
Microsoft stack, depending on which OS your dell has it could have either -
the latest model with WM5 has the MS stack, previously they used Broadcom.

Peter

--
Peter Foot
Windows Embedded MVP
www.peterfoot.net | www.inthehand.com

"Emmanuel Viollet" <Emmanuel.Viollet(a)webdyn.com> wrote in message
news:%239bVoHKKGHA.3260(a)TK2MSFTNGP11.phx.gbl...
> 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.


From: Emmanuel Viollet on
Peter Foot [MVP] a ?crit :
> Sorry to say but there isn't a single method which works on all stacks, the
> IPaq range all use Widcomm/Broadcom, the winsock APIs only work with the
> Microsoft stack, depending on which OS your dell has it could have either -
> the latest model with WM5 has the MS stack, previously they used Broadcom.
>

OK. Thanks.
Unfortunately, I was expecting this answer, but hoping for something else.
I suppose my client will have to do without Bluetooth device
detection... ;-)

It's incredible to see that this sort of incompatibility still exists... :-(