1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-25 03:16:51 +01:00

Pebble: do not dump all LE traffic, minor code cleanups

This commit is contained in:
Andreas Shimokawa 2016-12-02 23:38:54 +01:00
parent ae2c107ed1
commit 3db009e77d
3 changed files with 7 additions and 11 deletions

View File

@ -195,7 +195,7 @@ class PebbleIoThread extends GBDeviceIoThread {
}
BluetoothDevice btDevice = mBtAdapter.getRemoteDevice(deviceAddress);
if (btDevice.getType() == BluetoothDevice.DEVICE_TYPE_LE) {
LOG.info("Ok this seems to be a LE Pebble, try LE Support, trouble ahead!");
LOG.info("This is a Pebble 2 or Pebble-LE/Pebble Time LE, will use BLE");
mInStream = new PipedInputStream();
mOutStream = new PipedOutputStream();
mPebbleLESupport = new PebbleLESupport(this.getContext(), btDevice, (PipedInputStream) mInStream, (PipedOutputStream) mOutStream);
@ -238,7 +238,7 @@ class PebbleIoThread extends GBDeviceIoThread {
public void run() {
mIsConnected = connect();
if (!mIsConnected) {
if (GBApplication.getGBPrefs().getAutoReconnect()) {
if (GBApplication.getGBPrefs().getAutoReconnect() && !mQuit) {
gbDevice.setState(GBDevice.State.WAITING_FOR_RECONNECT);
gbDevice.sendDeviceUpdateIntent(getContext());
}
@ -723,16 +723,14 @@ class PebbleIoThread extends GBDeviceIoThread {
if (mBtSocket != null) {
try {
mBtSocket.close();
} catch (IOException e) {
e.printStackTrace();
} catch (IOException ignored) {
}
mBtSocket = null;
}
if (mTCPSocket != null) {
try {
mTCPSocket.close();
} catch (IOException e) {
e.printStackTrace();
} catch (IOException ignored) {
}
mTCPSocket = null;
}

View File

@ -57,15 +57,13 @@ class PebbleGATTServer extends BluetoothGattServerCallback {
}
synchronized void sendDataToPebble(byte[] data) {
LOG.info("send data to pebble " + GB.hexdump(data, 0, -1));
//LOG.info("send data to pebble " + GB.hexdump(data, 0, -1));
writeCharacteristics.setValue(data.clone());
mBluetoothGattServer.notifyCharacteristicChanged(mBtDevice, writeCharacteristics, false);
}
synchronized private void sendAckToPebble(int serial) {
LOG.info("send ack to pebble for serial " + serial);
writeCharacteristics.setValue(new byte[]{(byte) (((serial << 3) | 1) & 0xff)});
mBluetoothGattServer.notifyCharacteristicChanged(mBtDevice, writeCharacteristics, false);
@ -109,7 +107,7 @@ class PebbleGATTServer extends BluetoothGattServerCallback {
mPebbleLESupport.notify();
}
}
LOG.info("write request: offset = " + offset + " value = " + GB.hexdump(value, 0, -1));
//LOG.info("write request: offset = " + offset + " value = " + GB.hexdump(value, 0, -1));
int header = value[0] & 0xff;
int command = header & 7;
int serial = header >> 3;

View File

@ -46,7 +46,7 @@ public class PebbleLESupport {
}
}
this.close();
throw new IOException("conntection failed");
throw new IOException("connection failed");
}
void writeToPipedOutputStream(byte[] value, int offset, int count) {