Hi all,

I’m using a Nokia 6670 to connect to a GPS receiver through bluetooth. I have a thread that connects, gets data, disconnects, waits for 15 seconds and does it again and again. I have two problems:
- I f I connect, read data and disconnect, the application shuts down after a couple of minutes.
- If I connect, just count the number of connections and disconnect, the application does not shut down, but after a couple of hours the phone disables the bluetooth connections (If I go to connections using the menu, the bluetooth connection is switched to off).

Does anybody know what’s going on here?

Code:
public void run()
    {
        StreamConnection conn = null;
        InputStream is = null;
        
        try{
            
            conn = (StreamConnection)Connector.open(url);
            is = conn.openInputStream();

            int i = 0;
            char c;
            String s = "";
            

            // Start reading the data from the GPS
            //  If I leave this do while this way, the applications shuts down in
            // a few minutes, but if I comment it out, the bluetooth connections
            // on the phone get disabled after a few hours
            do{
                i = is.read(); // read one byte at the time.
                c = (char)i;
               s += c;

            }while(i != -1);            
            
            this.GPS.deleteAll();
            this.GPS.append("" + LoopThread.count, null);
            this.GPS.append(s, null);
            
            //  closing the connection
            is.close();
            conn.close();
            is = null;
            conn = null;
            
        }catch(Exception e)
        {
            try
            {
                //  closing the connection
                is.close();
                conn.close();
                is = null;
                conn = null;
            }
            catch(Exception ee)
            {
                is = null;
                conn = null;
            }
            //  displaying error message
            Alert alert = new Alert("Error");
            alert.setType(AlertType.ERROR);
            alert.setString(e.toString());
            display.setCurrent(alert);
        }
    }