Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Mobile Development
  3. Mobile
  4. java ME + bluetooth problem with device discovery [modified]

java ME + bluetooth problem with device discovery [modified]

Scheduled Pinned Locked Moved Mobile
helpquestionjava
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mk_4
    wrote on last edited by
    #1

    Hello I'm writing bluetooth client application for my mobile phone and I got stuck on device discovery. My app can't discover any device, although in-built bluetooth app works fine. How can I make it work? My code for device discovery:

    localDevice = LocalDevice.getLocalDevice();
    discoveryAgent = localDevice.getDiscoveryAgent();
    discoveryAgent.startInquiry(DiscoveryAgent.GIAC,this);

    modified on Sunday, February 27, 2011 1:50 PM

    P 1 Reply Last reply
    0
    • M mk_4

      Hello I'm writing bluetooth client application for my mobile phone and I got stuck on device discovery. My app can't discover any device, although in-built bluetooth app works fine. How can I make it work? My code for device discovery:

      localDevice = LocalDevice.getLocalDevice();
      discoveryAgent = localDevice.getDiscoveryAgent();
      discoveryAgent.startInquiry(DiscoveryAgent.GIAC,this);

      modified on Sunday, February 27, 2011 1:50 PM

      P Offline
      P Offline
      Peter_in_2780
      wrote on last edited by
      #2

      What you have done so far is initiate a search, which can take a long time. You have two ways to get the results: 1. write inquiryCompleted() in your DiscoveryListener implementation, and, when (or after) it is called, use discoveryAgent.retrieveDevices() to get an array of devices that have been discovered. 2. write deviceDiscovered() in your DiscoveryListener implementation, and, each time it is called, see if the device is what you are looking for. I tried both ways (and they both work), but settled on #1 for production code. Peter If you like the answer, vote for it

      Software rusts. Simon Stephenson, ca 1994.

      M 1 Reply Last reply
      0
      • P Peter_in_2780

        What you have done so far is initiate a search, which can take a long time. You have two ways to get the results: 1. write inquiryCompleted() in your DiscoveryListener implementation, and, when (or after) it is called, use discoveryAgent.retrieveDevices() to get an array of devices that have been discovered. 2. write deviceDiscovered() in your DiscoveryListener implementation, and, each time it is called, see if the device is what you are looking for. I tried both ways (and they both work), but settled on #1 for production code. Peter If you like the answer, vote for it

        Software rusts. Simon Stephenson, ca 1994.

        M Offline
        M Offline
        mk_4
        wrote on last edited by
        #3

        Thank you for reply but I have these methods implemented. The problem is that my app can't find any device, though at least one - my laptop - is on and is discoverable. I can easily connect with it through in-built bluetooth app. Yet, another thing that puzzles me is why I can't get bluetooth address and friendly name from LocalDevice object. The only thing I get is empty string or null and my app suspends. Well it seems that the problem is caused by my phone. I rebooted it, launched my app and it worked but only once. Anyway I think that this topic can be considered as closed.

        P 1 Reply Last reply
        0
        • M mk_4

          Thank you for reply but I have these methods implemented. The problem is that my app can't find any device, though at least one - my laptop - is on and is discoverable. I can easily connect with it through in-built bluetooth app. Yet, another thing that puzzles me is why I can't get bluetooth address and friendly name from LocalDevice object. The only thing I get is empty string or null and my app suspends. Well it seems that the problem is caused by my phone. I rebooted it, launched my app and it worked but only once. Anyway I think that this topic can be considered as closed.

          P Offline
          P Offline
          Peter_in_2780
          wrote on last edited by
          #4

          In my experience, the phone's bluetooth manager can get totally confused if you do something it doesn't expect. The result is as you describe - reboot, your code works once (but the BT manager is locked up). I've found that you need to try and get "inside it's head" and imagine what state various BT internals might be in. Then avoid anything that might upset it. It took me a long time to develop code that could reliably switch the phone's BT connection back and forth between two external devices (PC, printer). Then when I tried it on a different brand of phone, I had to modify it again... Peter

          Software rusts. Simon Stephenson, ca 1994.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups