Author Topic: Selecting and connecting to a specific Bluetooth HID  (Read 7736 times)

TL

  • Guest
Selecting and connecting to a specific Bluetooth HID
« on: January 05, 2012, 07:44:54 PM »
What is the recommended method to connect to a specific Bluetooth HID?

This question refers to code in WiimoteDemo under Visual C++ 2008 (Bluesolei driver, Win 7 64).

I am using OnDiscoveryComplete to accumulate a list of available devices and storing the name and device address of each into my own list of objects.  To connect to a specific device, call EnumHID(wcl::CwclStringList& LIST) to obtain a list of devices.

(1) My first question is what does each string retrieved by LIST.GetItems(i) where LIST is the wcl::CwclStringList populated by EnumHID represent?  I would like to compare each of these strings to either the names or device addresses found by OnDiscoveryComplete.

(2) My second question is about the following loop inside OnDiscoveryComplete().
Why does this loop repeat up to 5 times if we are getting the name of one device in list position I?

CAtlString aName = L"";
J = 0;
while (aName == L"" && J < 5)
{
          // GetItems returns type CwclBluetoothDevice*
          // int GetName(CwclBluetoothRadio& rRadio, CAtlStringW& rsValue);
          pDevices->GetItems(I)->GetName(*pRadio, aName);
          J++;
}// end while J loop.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3675
  • Karma: 1000
    • Wireless Communication Libraries
Re: Selecting and connecting to a specific Bluetooth HID
« Reply #1 on: January 05, 2012, 09:39:50 PM »
Hello,

1. EnumHID returns device's name as it appears in system (it is PNP device indetification string). Unfortunately there is no easy way to compare each HID string with device's address/name. With BlueSoleil you have to connect to Wiimote before use it with WCL. However with other Bluetooth driver (MS/Toshiba/WidComm) WCL supports native Bluetooth connection so you don't need to use EnumHID there. The problem is that BlueSoleil doesn't provide any way to communicate directly with HID devices except using standard windows HID functions when device is already connected.

2. It is because device's name recognition appears after discovering is done. Discovering returns only device's address. After that devices may be busy and few times reading its name avoid this time when device is busy.

TL

  • Guest
Re: Selecting and connecting to a specific Bluetooth HID
« Reply #2 on: January 06, 2012, 12:42:12 AM »
Thank you for the detailed and prompt reply.  I will just try to connect to all discovered wiimotes to gather their names.  Then on handling data update events, I will use the names to route input to the appropriate player.  My objective is to write code that will produce the similar behavior on different bluetooth drivers.  So if for this application bluesolei provides the least functionality then that is what I will assume.

Thanks for clarifying the behavior of the loop to collect device names.

 

Sitemap 1 2 3 4 5 6 7