Author: kmorin Date: 2014-03-11 18:30:27 +0100 (Tue, 11 Mar 2014) New Revision: 75 Url: http://forge.codelutin.com/projects/wlo/repository/revisions/75 Log: fix bluetooth connexion once failed Modified: trunk/src/fr/ifremer/wlo/BigFinCommunicationService.java Modified: trunk/src/fr/ifremer/wlo/BigFinCommunicationService.java =================================================================== --- trunk/src/fr/ifremer/wlo/BigFinCommunicationService.java 2014-03-11 17:18:53 UTC (rev 74) +++ trunk/src/fr/ifremer/wlo/BigFinCommunicationService.java 2014-03-11 17:30:27 UTC (rev 75) @@ -378,7 +378,7 @@ */ protected class AcceptThread extends Thread { // The local server socket - private final BluetoothServerSocket mmServerSocket; + private BluetoothServerSocket mmServerSocket; public AcceptThread() { BluetoothServerSocket tmp = null; @@ -400,7 +400,7 @@ BluetoothSocket socket = null; // Listen to the server socket if we're not connected - while (mState != STATE_CONNECTED) { + while (mState != STATE_CONNECTED && mmServerSocket != null) { try { // This is a blocking call and will only return on a // successful connection or an exception @@ -440,6 +440,7 @@ Log.d(TAG, "Socket cancel " + this); try { mmServerSocket.close(); + mmServerSocket = null; } catch (IOException e) { Log.e(TAG, "Socket close() of server failed", e); } @@ -546,7 +547,7 @@ int bytes; // Keep listening to the InputStream while connected - while (true) { + while (!stop) { try { // Read from the InputStream // bytes = mmInStream.read(buffer); @@ -559,9 +560,6 @@ boolean complete = false; while (!complete) { while (mmInStream.available() > 0) { - if (stop) { - break; - } int c = mmInStream.read(); if (c == '@') { complete = true;