2

How do I find MAC address (hardware address) of Bluetooth network interface in Windows? The problem is not to find out an address, the problem is to identify if network interface type is Bluetooth.

Both approaches I tried does not distinguish between ethernet card and bluetooth (at least I don't see a difference) - GetAdaptersAddresses returns bluetooth interface as IF_TYPE_ETHERNET_CSMACD and WMI as AdapterTypeID of Ethernet 802.3 (same as WiFi, eventhough Wireless type exists).

Only possibility I currently see is to search a name or description string for text "bluetooth" but this does not seem as OK solution ;-)

Neel Basu
  • 12,638
  • 12
  • 82
  • 146
Martin
  • 165
  • 1
  • 15
  • Do you want to detect whenever a Bluetooth dongle is plugged into the machine ? – Neel Basu Aug 14 '12 at 07:33
  • have you tried `WSAQUERYSET` with `NS_BTH` ? – Neel Basu Aug 14 '12 at 07:41
  • The thing is that I need HW address of classic eth interface and I need to remove all other interfaces from the list. I can find out what interfaces are virtual (tunnels, etc.) by WMI (Win32_NetworkAdapter and PhysicalAdapter). And I can also find out what is wifi interface by GetAdaptersAddresses (because WMI returns Ethernet type for WiFi for some reason). Currently in my list there is only normal Ethernet interface and Bluetooth and I need to detect that "bluetooth is bluetooth" and not for example another classic card. WSAQUERYSET sounds good, I need to check how it works, thanks. – Martin Aug 14 '12 at 07:52
  • I don't want to check if something is plugged/connected into bluetooth, I just need MAC addresses to identify the HW configuration and I don't want to use Bluetooth interfaces for that (for example they disappear from the list completely if you turn the bluetooth off). – Martin Aug 14 '12 at 07:53

1 Answers1

1

You can use BluetoothFindFirstRadio, BluetoothFindNextRadio and BluetoothGetRadioInfo. The local MAC adress of the adapter is then in the field address of BLUETOOTH_RADIO_INFO:

BLUETOOTH_FIND_RADIO_PARAMS btfrp;
btfrp.dwSize = sizeof(btfrp);
HANDLE hRadio;
HBLUETOOTH_RADIO_FIND hFind = BluetoothFindFirstRadio(&btfrp, &hRadio);

if(hFind == NULL)
{
    DWORD err = GetLastError();
    switch(err)
    {
    case ERROR_NO_MORE_ITEMS:
        // No bluetooth radio found
        break;
    default:
        // Error finding radios
    }

    return;
}
do
{
    BLUETOOTH_RADIO_INFO radioInfo;
    radioInfo.dwSize = sizeof(radioInfo);
    DWORD err = BluetoothGetRadioInfo(hRadio, &radioInfo);
    if(err != ERROR_SUCCESS)
    {
       // Error during BluetoothGetRadioInfo
        continue;
    }
    // The mac address is in radioInfo.address

}
while(BluetoothFindNextRadio(hFind, &hRadio));


BluetoothFindRadioClose(hFind);
Eric Lemanissier
  • 357
  • 2
  • 15