×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    13

    J2ME bluetooth application

    Hello,

    I have got some problems using Bluetooth with Nokia N80 and E50 phones.
    When i start a new discovery to detect bluetooth devices it will always shows the previously discovered devices(located in DiscoveryAgent.CACHED), and this even if the remote bluetooth device is switch off or out of range.
    How can i flush the cache or initialize bluetooth stack with J2ME?

    thanks a lot
    sebastien

  2. #2
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,699

    Re: J2ME bluetooth application

    hi Sebastien,
    are you using startInquiry(....) or retrieveDevices()? the latter alway return either cached or preknown devices (or null if nothing is found),
    the first queries for devices in range,
    btw:
    more proper section for bt topics:
    http://discussion.forum.nokia.com/fo...splay.php?f=38

    regards,
    Peter

  3. #3
    Registered User
    Join Date
    Sep 2006
    Posts
    13

    Re: J2ME bluetooth application

    Hello,

    i use the startInquiry(....) method with DiscoveryAgent:GIAC parameter. if I detect a bluetooth beacon , disconnect it, i will still be able to detect it again at the next inquiry.
    I am using the javax.bluetooth package of SUN.
    how can i basically flush this cache or try to ignore it? I have seen this same kind of problems in other Thread and i did not see any real solutions to that.
    it might be useful to cache previously discovered devices, but why to pop up cache devices when starting inqueries? since we can get cache content using retrieveDevice(DiscoveryAfent.CACHED) ???

    regards
    sebastien

  4. #4
    Registered User
    Join Date
    Sep 2006
    Posts
    13

    Re: J2ME bluetooth application

    Hello

    I really would like to know why the cached bluetooth devices show up when starting a new device discovery inquiries.
    We should not be able to detect a cached device if it is disconnected or our of range,
    How can i overcome this problem?
    regards
    sebastien

  5. #5
    Super Contributor
    Join Date
    Dec 2005
    Location
    Europe/Poland/Warsaw
    Posts
    1,699

    Re: J2ME bluetooth application

    hi Sebastien,

    have you a chance to validate that againts different device?
    have you used test-case which used only inquiry to make sure that results are not mixed?

    regards,
    peter

  6. #6
    Registered User
    Join Date
    Sep 2006
    Posts
    13

    Re: J2ME bluetooth application

    Hello Peter, thanks for your message.

    My application only use Inquiries and do not access the cache devices at all.
    We have tested the software on Nokia E50, N80, 7710,6630,6680. And they all have The same behaviour.
    regards
    sebastien

  7. #7
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    75

    Re: J2ME bluetooth application

    Hello,

    I have exactly the same problem concerning the caching.
    Could you find a solution?


    Regards,

    Kurt

  8. #8
    Registered User
    Join Date
    Oct 2004
    Posts
    16

    Re: J2ME bluetooth application

    Quote Originally Posted by sepi1982
    Hello,

    I have got some problems using Bluetooth with Nokia N80 and E50 phones.
    When i start a new discovery to detect bluetooth devices it will always shows the previously discovered devices(located in DiscoveryAgent.CACHED), and this even if the remote bluetooth device is switch off or out of range.
    How can i flush the cache or initialize bluetooth stack with J2ME?

    thanks a lot
    sebastien
    Please visit http://forum.vietcovo.com and download bluetooth apps at http://vietcovo.sf.net

  9. #9
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    150

    Exclamation Re: J2ME bluetooth application

    Hi, sepi1982!

    I've used javax.bluetooth library in several phones and it worked perfectly!

    It might be a silly thing but in the "deviceDiscovered()" method you can include the "btDevice" parameter into a Vector object. In my snippet of code that Vector object is called "remoteDevices". If you store the devices into a Vector object as me, you MUST clean it before starting a new Inquiry process because you will have devices that might be out of service or which aren't in your BT coverage area in it!

    I use the "clearRemoteDevices()" method before starting a new Inquiry process and you will always find the BT devices that actually are switch on!

    If you have a deviceDiscovered() method like this, I'm absolutely sure that your problem roots in this issue!


    Code:

    public void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod) {
    //Filtered by BTAddress
    if (!remoteDevices.contains((btDevice))){
    remoteDevices.addElement(btDevice);
    }
    }

    public void clearRemoteDevices(){
    if ((remoteDevices!=null)&&(!remoteDevices.isEmpty())){
    remoteDevices.removeAllElements();
    }
    }
    Good luck!

    Summerman.

  10. #10
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    75

    Re: J2ME bluetooth application

    That doesn't work.
    When you discover a phone and then switch off the phone the phone is still discovered. So in your case it is still put into the vector although it's not there.

    Kurt

  11. #11
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    150

    Thumbs up Re: J2ME bluetooth application

    Quote Originally Posted by Kurt Johannes
    That doesn't work.
    When you discover a phone and then switch off the phone the phone is still discovered. So in your case it is still put into the vector although it's not there.
    Kurt
    Yes of course!

    If you make an Inquiry process and you discover some devices and before that all/some of them suddenly are "swithed off" I'm absolutely sure that in the Vector object all those discovered remoteDevices will continue being stored!
    But when you make the ServiceSearch devices you will note that those remoteDevices (all of them or some of them) are "Not Reached Devices" so you have to realize that they are swichted off, they are out of service... and you have to act in consequence!

    If a BT device is switched off after the ServiceSearch process and it was taken place while you were writing to or reading from an OutputStream or InputStream which pointed to that BT connection, an IOException, EOFException... takes place and you have to capture it and to act in consequence!

    You should implement some code to RECONNECT BT devices that are dropped if you want to discover them again because the JSR-82 is not as intelligent as we believe and the developer only knows what he wants to do in each special case like this one!

    Best Regards.

    Summerman.

  12. #12
    Regular Contributor
    Join Date
    Apr 2005
    Posts
    75

    Re: J2ME bluetooth application

    Quote Originally Posted by Summerman
    Yes of course!

    If you make an Inquiry process and you discover some devices and before that all/some of them suddenly are "swithed off" I'm absolutely sure that in the Vector object all those discovered remoteDevices will continue being stored!
    I never doubt that.
    But you haven't mention to use a service search after that (or I didn't recognize).
    The problem in my case is that I have BT-devices which are just BT beacons. They don't have any services to connect to. They are just sending their BT-ID. But I want to recognize them when they are out of reach...

  13. #13
    Regular Contributor
    Join Date
    Feb 2006
    Posts
    150

    Wink Re: J2ME bluetooth application

    Ok, now I understand you better!

    As I know, the only way to realize that a BT device is dropped when you didn't connnect to it, is repeat the Inquiry process continuously or use the "getFriendlyName()" method in the RemoteDevice class in JSR-82 API:

    getFriendlyName
    public java.lang.String getFriendlyName(boolean alwaysAsk)
    throws java.io.IOExceptionReturns the name of this device. The Bluetooth specification calls this name the "Bluetooth device name" or the "user-friendly name". This method will only contact the remote device if the name is not known or alwaysAsk is true.
    Parameters:
    alwaysAsk - if true then the device will be contacted for its name, otherwise, if there exists a known name for this device, the name will be returned without contacting the remote device
    Returns:
    the name of the device, or null if the Bluetooth system does not support this feature; if the local device is able to contact the remote device, the result will never be null; if the remote device does not have a name then an empty string will be returned
    Throws:
    java.io.IOException - if the remote device can not be contacted or the remote device could not provide its name
    It might be useful for you!

    Good luck!

Similar Threads

  1. How can the WAP browser communicate to J2ME application?
    By hbfornies in forum Mobile Java General
    Replies: 20
    Last Post: 2007-03-02, 16:32
  2. develop a application send image from mobile to PC in J2ME via bluetooth
    By livepeterpan in forum [Archived] Other Programming Discussion 关于其他编程技术的讨论
    Replies: 0
    Last Post: 2005-07-31, 09:54
  3. App. Provisioning over Bluetooth, from the Application Itself
    By a_n_k_u_r in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2005-07-24, 23:00
  4. Urgent! ease to port Bluetooth application: J2ME or Symbian???
    By tomspender in forum Bluetooth Technology
    Replies: 0
    Last Post: 2005-07-07, 19:03
  5. Start a J2ME application by OTA
    By hbfornies in forum Mobile Java General
    Replies: 1
    Last Post: 2003-09-23, 10:01

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •