some internal testing which does not hurt in master

This commit is contained in:
Andreas Shimokawa 2016-11-03 11:07:15 +01:00
parent 0076bbf572
commit 14ef5202e1
1 changed files with 20 additions and 10 deletions

View File

@ -21,6 +21,8 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PipedInputStream;
import java.io.PipedOutputStream;
import java.net.InetAddress;
import java.net.Socket;
import java.nio.ByteBuffer;
@ -177,6 +179,13 @@ class PebbleIoThread extends GBDeviceIoThread {
} else {
mIsTCP = false;
BluetoothDevice btDevice = mBtAdapter.getRemoteDevice(btDeviceAddress);
if (btDevice.getType() == BluetoothDevice.DEVICE_TYPE_LE) {
LOG.info("Ok this seems to be a LE Pebble, will try something that does not work :P");
mInStream = new PipedInputStream(new PipedOutputStream()); // fake so that io blocks
mOutStream = new PipedOutputStream(new PipedInputStream()); // fake so that io blocks
//new PebbleLESupport(this.getContext(),btDeviceAddress); // secret branch :P
}
else {
ParcelUuid uuids[] = btDevice.getUuids();
if (uuids == null) {
return false;
@ -189,6 +198,7 @@ class PebbleIoThread extends GBDeviceIoThread {
mInStream = mBtSocket.getInputStream();
mOutStream = mBtSocket.getOutputStream();
}
}
} catch (IOException e) {
e.printStackTrace();
gbDevice.setState(originalState);
@ -361,7 +371,7 @@ class PebbleIoThread extends GBDeviceIoThread {
e.printStackTrace();
}
} catch (IOException e) {
if (e.getMessage().contains("socket closed")) { //FIXME: this does not feel right
if (e.getMessage() != null && e.getMessage().contains("socket closed")) { //FIXME: this does not feel right
LOG.info(e.getMessage());
mIsConnected = false;
int reconnectAttempts = prefs.getInt("pebble_reconnect_attempts", 10);