.NET Components for Mobility

Device Discovery - DeviceName value not populating

Last post 12-04-2008 7:54 AM by Arch. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 07-25-2007 6:39 PM

    Hmm [^o)] Device Discovery - DeviceName value not populating

    I have what is probably a silly question, but I'm curious anyway -

    Sometimes when I call DiscoverDevices() on the bluetooth client, the DeviceName field for the devices does not populate to the name of the device as it reports itself - it uses the MAC address of the device instead.  I realize that is the fallback behavior for when the device does not successfully report its name.

    In most cases, this issue is overcome by merely calling DiscoverDevices() twice - it will almost always get the actual device name on subsequent discoveries.  Is there some reason this happens?  Is there something I should be doing to avoid this?  I note that Windows and other applications seem to have no problem getting the correct bluetooth device name - is this something specific to the InTheHand library, or my use of it?
     

  • 07-27-2007 7:59 AM In reply to

    Re: Device Discovery - DeviceName value not populating

    See http://32feet.net/forums/p/1081/3177.aspx#3177  As I note there, I see this behaviour when I use Windows' built-in Bluetooth dialogs, it's not specific to the library.

    Alan J. McFarlane
    http://www.alanjmcf.me.uk/
    Please follow-up in the newsgroup for the benefit of all.
    Have I helped? Consider visiting my Amazon wishlist, see my homepage.
  • 07-31-2007 4:40 PM In reply to

    Re: Device Discovery - DeviceName value not populating

    alanjmcf:
    See http://32feet.net/forums/p/1081/3177.aspx#3177  As I note there, I see this behaviour when I use Windows' built-in Bluetooth dialogs, it's not specific to the library.
     

    Hmm.  You're right, I see that in the windows dialogs too.

    I've tried calling refresh and querying the property again, with no improvement.  How long should I wait to call refresh?

    One thing that might be helpful is firing an event each time a device is found while calling DiscoverDevices.  That would allow a) items to show up on a list, grid, etc. dynamically so it doesn't look like the system is frozen, and b) allow the application to wait and query the device name again after a short period as each device is discovered.  In other words, it'd provide a more dynamic system.

    I can download the source off CodePlex and add such an event myself for my own application, but I am wondering what your thoughts on that idea are.
     

  • 08-01-2007 4:37 PM In reply to

    Re: Device Discovery - DeviceName value not populating

    Don't know how long one would need to wait.  I think the Windows' Bluetooth device dialog auto updates when the name arrives, maybe measure that...

    Yup it is something the library should support.  Do you mean using the WM_DEVICECHANGE mechanism (http://msdn2.microsoft.com/en-us/library/aa362912.aspx), or just to do discovery repeatedly and raise an event when a new device appears?  I've a sample app that handles the WM_DEVICECHANGE messages, I'll upload it somewhere tomorrow.  I suspect that one gets an event when the device is first seen and a second when its name is discovered.  It'd be interesting to find out for sure.

    Alan J. McFarlane
    http://www.alanjmcf.me.uk/
    Please follow-up in the newsgroup for the benefit of all.
    Have I helped? Consider visiting my Amazon wishlist, see my homepage.
  • 08-01-2007 8:05 PM In reply to

    Re: Device Discovery - DeviceName value not populating

    alanjmcf:
    Do you mean using the WM_DEVICECHANGE mechanism (http://msdn2.microsoft.com/en-us/library/aa362912.aspx),
     

    Well, I didn't mean that specifically..

    alanjmcf:
    or just to do discovery repeatedly and raise an event when a new device appears?

    That either.  Tongue Tied I really just meant, when the DiscoverDevices() method is called, it appears to execute a loop that does a device lookup.  Each time a device is found and added to the list, raise an event, so the user doesn't have to wait until DiscoverDevices returns, because that can sometimes take several minutes.  This way you can have behavior closer to that of the Windows device dialog, where each item shows up in the list as it is discovered.

    It would be nice to handle the WM_DEVICECHANGE message though.  I looked through the documentation and I didn't find anything that indicated another message is sent when the device name is discovered, though.  I suspect that the windows device dialog simply does what I'm talking about, it gets the new device message and then explicitly queries that device's name.
     

  • 08-02-2007 8:42 AM In reply to

    Re: Device Discovery - DeviceName value not populating

    Just on the last point for now, the docs say the following. :-)

    This message is sent when any of the following attributes of a remote Bluetooth device has changed: the device has been discovered, the class of device, name, connected state, or device remembered state. This message is also sent when these attributes are set or cleared.

    And here's some output from my test program, this is when I'm doing a Bluetooth->AddDevice.  Note that the first event is the device being discovered, then the event in the next second is the event saying "now got the name!".  Subsequent events are pairing and disappearance.

    13:30:58 GUID_BLUETOOTH_HCI_EVENT
    13:30:58 GUID_BLUETOOTH_RADIO_IN_RANGE 0x0009997723F3
        is (Address, Cod, Connected) 0x00000023 was (Address, Cod) 0x00000003
    13:30:58 GUID_BLUETOOTH_L2CAP_EVENT
    13:30:59 GUID_BLUETOOTH_RADIO_IN_RANGE 0x0009997723F3
        is (Address, Cod, Name, Connected) 0x00000027 was (Address, Cod, Connected) 0x00000023
    13:31:16 GUID_BLUETOOTH_RADIO_IN_RANGE 0x0009997723F3
        is (Address, Cod, Name, Paired, Personal, Connected) 0x0000003F was (Address, Cod, Name, Connected) 0x00000027
    13:31:16 GUID_BLUETOOTH_L2CAP_EVENT
    13:31:16 GUID_BLUETOOTH_L2CAP_EVENT
    13:31:16 GUID_BLUETOOTH_L2CAP_EVENT
    13:31:16 GUID_BLUETOOTH_RADIO_IN_RANGE 0x0009997723F3
        is (Address, Cod, Name, Paired, Personal) 0x0000001F was (Address, Cod, Name, Paired, Personal, Connected) 0x0000003F
    13:31:16 GUID_BLUETOOTH_HCI_EVENT

    I want a quick read through of the source before I upload it.  Maybe you want to try your other method first anyway.

    Alan J. McFarlane
    http://www.alanjmcf.me.uk/
    Please follow-up in the newsgroup for the benefit of all.
    Have I helped? Consider visiting my Amazon wishlist, see my homepage.
  • 12-04-2008 7:54 AM In reply to

    • Arch
    • Top 100 Contributor
    • Joined on 10-16-2008
    • Posts 6

    Re: Device Discovery - DeviceName value not populating

    Sometimes I also meet this problem. And I noticed when it happens: if I turn my device off, then call DiscoverDevices(), then turn it on and discover it again, I'll see device's address instead of the name accurate to colons.

    RefreshDevice() doesn't help as well as GetRemoteMachineName(). I just call DiscoverDevices() again.

Page 1 of 1 (7 items)
Copyright © 2001-2008 In The Hand Ltd. All rights reserved. Terms of Use and Privacy Policy.