J
jeffzzang
I'm programming using Visual Studio 2005 (C#) on a PocketPC with
Windows Mobile 5.0. I have downloaded the Windows Mobile Shared Source
Bluetooth libraries from microsoft and noticed that their libraries
only support connecting to devices that are in the registry (already
paired devices).
In my application, I need to survey the surrounding area for bluetooth
devices and for each device that is found, see if it's running a
service with a particular GUID. I use PInvoke to call the
WSALookupServiceBegin and WSALookupServiceNext methods to achieve
this. At this point, I am finding devices correctly, but it seems that
the service discovery fails.
I set the WSAQUERYSET members lpServiceClassId equal to the Guid I'm
looking for and the lpszContext to the string version of the bluetooth
address (eg. "XX:XX:XX:XX:XX:XX").
I then call WSALookupServiceBegin with 0x0002 (LUP_CONTAINERS) and
then call WSALookupServiceNext using LUP_RETURN_NAME and
LUP_RETURN_ADDRESS (0x0010 | 0x0100). By the way, if you try to call
WsaLookupServiceXXXX with anything but these flags, the call fails
with 10014 (WSAEFAULT).
I am testing with 3 bluetooth devices.
Device A: The one running my program. This device is trying to
discover.
Device B: This one is just sitting there with bluetooth enabled. No
programs are running on here.
Device C: This one is running the service I am interested in. It is
just listening for connections.
I am noticing some strange behavior:
1) If I turn the program off on Device C, Device A will still identify
it as running the service (the call from WSALookupServiceNext)
2) Sometimes it says that Device B is running the service I'm
interested in, but Device B has no knowledge of the service I'm
interested in.
My questions are as follows:
1) Am I doing service discovery correctly? (eg looking for devices,
then looking for services on these devices)
2) Am I using the correct flags? A lot of the other ones like
LUP_FLUSHCACHE fail for some reason
3) Is there a better way to do what I'm trying to do?
Thanks in advance.
Windows Mobile 5.0. I have downloaded the Windows Mobile Shared Source
Bluetooth libraries from microsoft and noticed that their libraries
only support connecting to devices that are in the registry (already
paired devices).
In my application, I need to survey the surrounding area for bluetooth
devices and for each device that is found, see if it's running a
service with a particular GUID. I use PInvoke to call the
WSALookupServiceBegin and WSALookupServiceNext methods to achieve
this. At this point, I am finding devices correctly, but it seems that
the service discovery fails.
I set the WSAQUERYSET members lpServiceClassId equal to the Guid I'm
looking for and the lpszContext to the string version of the bluetooth
address (eg. "XX:XX:XX:XX:XX:XX").
I then call WSALookupServiceBegin with 0x0002 (LUP_CONTAINERS) and
then call WSALookupServiceNext using LUP_RETURN_NAME and
LUP_RETURN_ADDRESS (0x0010 | 0x0100). By the way, if you try to call
WsaLookupServiceXXXX with anything but these flags, the call fails
with 10014 (WSAEFAULT).
I am testing with 3 bluetooth devices.
Device A: The one running my program. This device is trying to
discover.
Device B: This one is just sitting there with bluetooth enabled. No
programs are running on here.
Device C: This one is running the service I am interested in. It is
just listening for connections.
I am noticing some strange behavior:
1) If I turn the program off on Device C, Device A will still identify
it as running the service (the call from WSALookupServiceNext)
2) Sometimes it says that Device B is running the service I'm
interested in, but Device B has no knowledge of the service I'm
interested in.
My questions are as follows:
1) Am I doing service discovery correctly? (eg looking for devices,
then looking for services on these devices)
2) Am I using the correct flags? A lot of the other ones like
LUP_FLUSHCACHE fail for some reason
3) Is there a better way to do what I'm trying to do?
Thanks in advance.