×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Aug 2010
    Posts
    7

    Application looses pairing on second restart of the phone.

    Hi, I have an j2me application that is working fine with most of the Symbian platforms except the 9.4 version. Application makes use of bluetooth connections and PushRegistry in order to be started and receive data. Application uses the next piece of code to register for a bluetooth connection and push:
    Code:
    	String url = null;
        String activeConn[] = PushRegistry.listConnections(true);
        for (int i = 0; i < activeConn.length; i++) {
          if (-1 < activeConn[i].indexOf("btspp")) {
            url = activeConn[i];
            break;
          }
        }
        if (null == url) {
          url = "btspp://:102030405060708090A1B1C1D1D1E100;name=My%20OBEX";
          String regConns[] = PushRegistry.listConnections(false);
          int i = 0;
          for (; null != regConns && i < regConns.length; i++) {
            if (url.equals(regConns[i])) {
              // already registered
              break;
            }
          }
          if (regConns.length == i) {
            try {
              PushRegistry.registerConnection(url, MidletJSR82.class.getName(), "*");
            } catch (Exception e) {
              url = "btspp://localhost:102030405060708090A1B1C1D1D1E100;name=My OBEX";
              e.printStackTrace();
            }
          }
        }
        while (null == service) {
          try {
            LocalDevice.getLocalDevice().setDiscoverable(DiscoveryAgent.GIAC);
            service = (StreamConnectionNotifier) Connector.open(url);
          } catch (Exception e) {
            service = null;
            System.out.println("Error! Bluetooth is unavailable.");
            try {
              Thread.sleep(5 * 1000);
            } catch (InterruptedException ire) {
    
            }
          }
        }
    and the next piece iof code to obtain the connection:
    Code:
        System.out.println("RfComm openStreamConnection");
        StreamConnection c = service.acceptAndOpen();
        System.out.println("finished RfComm openStreamConnection");
    Connection is also registered in the jad file:
    MIDlet-Push-1: btspp://:102030405060708090A1B1C1D1D1E100;name=My OBEX, com.MidletJSR82, *

    The program works fine during initial OTA install. Then after first restart of the phone everything works fine.
    then on the second phone restart we have exactly one application start so that bluetooth data is being received. After that the pairing is lost and there is no way to restore it other then to reinstall the app. Icn provide any other code need.
    Any suggestion on why this might be happening?

  2. #2
    Registered User
    Join Date
    Aug 2010
    Posts
    7

    Re: Application looses pairing on second restart of the phone.

    Noone?
    I have figured out few things since:
    first of all here is how this code works:
    1.app installed
    2.Pushregistry works(app is started on BT data push)
    2.1 PushRegistry.listConnections(true) does not return the connection
    2.2 Code tries to register another connection (with %20 in url) - and fails

    3. phone restarted

    3.1 Pushregistry is not working(app is started on BT data push)
    3.2 On app start PushRegistry.listConnections(true) does not return the connection
    3.3 PushRegistry.listConnections(false); returns the URL with space int "My OBEX"
    3.4 app still registers a new connection (with %20 in url) - and succeeds
    3.5 after that PushRegistry works. and PushRegistry.listConnections(true) returns the connection url

    4. phone restarted

    4.1 Pushregistry is not working(app is started on BT data push)
    4.2 PushRegistry.listConnections(true) does not return the connection
    4.3 PushRegistry.listConnections(false) return 2 urls (with " " and "%20")
    4.4 nothing is registered
    4.5 Connector.open(url); fails with exceptions thus pairing looks lost.

  3. #3
    Registered User
    Join Date
    Aug 2010
    Posts
    7

    Re: Application looses pairing on second restart of the phone.

    I tweaked the code so that it uses one URL(without "%20") and thus I've been able to quit app loosing pairing. However PushRegistry is still not working ofter restart and if I try to register it manually - it returns the IOException with no inner message. Is there a bug that PushRegistry settings are lost after phone restart? but I think they are not doe to PushRegistry.listConnections(false) returns the connection. It is for some reason "not live".

  4. #4
    Registered User
    Join Date
    Aug 2010
    Posts
    7

    Re: Application looses pairing on second restart of the phone.

    I also do not get why and if "localhost" has to be present on the URL, cause when I get the URL from PushRegistry.listConnections(true) it is the one without localhost. AlthoughConnector.open(url) opens either way.

  5. #5
    Registered User
    Join Date
    Aug 2010
    Posts
    7

    Re: Application looses pairing on second restart of the phone.

    so far from my tests I see that adding localhost just enables PushRegistry to work(probably due to URL is different from the one in JAD) the first phone restart. After the second phone restart this is affectively dead too. Can anyone give some advice/info on how this is supposed to work? Adding localhost to the JAD's Midlet-Push-1 doesn't change anything.
    From my experience PushRegistry works only in the session that the application was installed -> then PushRegistry.listConnections(true) returns the connection. After phone restart connection can be found only with PushRegistry.listConnections(false).
    Re-registering the connection gives an IOException with no message. Any info is appreciated.

  6. #6
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105

    Re: Application looses pairing on second restart of the phone.

    Instead of pairing, you mean registering, don’t you? Does this answer your question?

  7. #7
    Registered User
    Join Date
    Aug 2010
    Posts
    7

    Re: Application looses pairing on second restart of the phone.

    Well, yes. Just from the user perspective it looks like the BT device and the phone are not paired anymore.
    The article answers my question, in a sad way though.
    Thanks for the info.

  8. #8
    Registered User
    Join Date
    Mar 2003
    Posts
    4,105

    Smile

    Quote Originally Posted by Revenge_one View Post
    From the user perspective it looks like the BT device and the phone are not paired anymore.
    OK. I had problems to understand your issue. Pairing is a word used in the Bluetooth specification. That word has a definition. When you discuss issues, you should use words as defined only – just to avoid confusion in the context of Bluetooth.

  9. #9
    Registered User
    Join Date
    Aug 2010
    Posts
    7

    Re: Application looses pairing on second restart of the phone.

    Although I admit that the title of my issue is slightly misleading, from bluetooth spec(http://en.wikipedia.org/wiki/Bluetooth#Pairing) "To resolve this conflict, Bluetooth uses a process called pairing, ... Two devices need to be paired to communicate with each other ... Once a pairing has been established it is remembered by the devices, which can then connect to each without user intervention ...".
    From an application point of view connection is not established until application is reinstalled. And although it turned out that the pairing is OK I didn't know that at the time I posted this thread.
    Once again, sorry for misleading title.

Similar Threads

  1. Replies: 14
    Last Post: 2009-10-29, 04:46
  2. application restart when phone is rebooted.........
    By chandra1234 in forum Symbian Signed Support, Application Packaging and Distribution and Security
    Replies: 3
    Last Post: 2009-05-04, 11:14
  3. How to restart the phone?
    By microsoft2 in forum Symbian
    Replies: 6
    Last Post: 2007-02-27, 13:51
  4. Phone restarts, looses connection, firmware?
    By jdm1216 in forum Bluetooth Technology
    Replies: 0
    Last Post: 2006-07-14, 10:19
  5. restart phone
    By acquariusoft in forum Symbian
    Replies: 1
    Last Post: 2005-09-09, 10:54

Posting Permissions

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