mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-11-28 21:06:50 +01:00
Pebble: do not dump all LE traffic, minor code cleanups
This commit is contained in:
parent
ae2c107ed1
commit
3db009e77d
@ -195,7 +195,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
|||||||
}
|
}
|
||||||
BluetoothDevice btDevice = mBtAdapter.getRemoteDevice(deviceAddress);
|
BluetoothDevice btDevice = mBtAdapter.getRemoteDevice(deviceAddress);
|
||||||
if (btDevice.getType() == BluetoothDevice.DEVICE_TYPE_LE) {
|
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();
|
mInStream = new PipedInputStream();
|
||||||
mOutStream = new PipedOutputStream();
|
mOutStream = new PipedOutputStream();
|
||||||
mPebbleLESupport = new PebbleLESupport(this.getContext(), btDevice, (PipedInputStream) mInStream, (PipedOutputStream) mOutStream);
|
mPebbleLESupport = new PebbleLESupport(this.getContext(), btDevice, (PipedInputStream) mInStream, (PipedOutputStream) mOutStream);
|
||||||
@ -238,7 +238,7 @@ class PebbleIoThread extends GBDeviceIoThread {
|
|||||||
public void run() {
|
public void run() {
|
||||||
mIsConnected = connect();
|
mIsConnected = connect();
|
||||||
if (!mIsConnected) {
|
if (!mIsConnected) {
|
||||||
if (GBApplication.getGBPrefs().getAutoReconnect()) {
|
if (GBApplication.getGBPrefs().getAutoReconnect() && !mQuit) {
|
||||||
gbDevice.setState(GBDevice.State.WAITING_FOR_RECONNECT);
|
gbDevice.setState(GBDevice.State.WAITING_FOR_RECONNECT);
|
||||||
gbDevice.sendDeviceUpdateIntent(getContext());
|
gbDevice.sendDeviceUpdateIntent(getContext());
|
||||||
}
|
}
|
||||||
@ -723,16 +723,14 @@ class PebbleIoThread extends GBDeviceIoThread {
|
|||||||
if (mBtSocket != null) {
|
if (mBtSocket != null) {
|
||||||
try {
|
try {
|
||||||
mBtSocket.close();
|
mBtSocket.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException ignored) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
mBtSocket = null;
|
mBtSocket = null;
|
||||||
}
|
}
|
||||||
if (mTCPSocket != null) {
|
if (mTCPSocket != null) {
|
||||||
try {
|
try {
|
||||||
mTCPSocket.close();
|
mTCPSocket.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException ignored) {
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
mTCPSocket = null;
|
mTCPSocket = null;
|
||||||
}
|
}
|
||||||
|
@ -57,15 +57,13 @@ class PebbleGATTServer extends BluetoothGattServerCallback {
|
|||||||
}
|
}
|
||||||
|
|
||||||
synchronized void sendDataToPebble(byte[] data) {
|
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());
|
writeCharacteristics.setValue(data.clone());
|
||||||
|
|
||||||
mBluetoothGattServer.notifyCharacteristicChanged(mBtDevice, writeCharacteristics, false);
|
mBluetoothGattServer.notifyCharacteristicChanged(mBtDevice, writeCharacteristics, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized private void sendAckToPebble(int serial) {
|
synchronized private void sendAckToPebble(int serial) {
|
||||||
LOG.info("send ack to pebble for serial " + serial);
|
|
||||||
|
|
||||||
writeCharacteristics.setValue(new byte[]{(byte) (((serial << 3) | 1) & 0xff)});
|
writeCharacteristics.setValue(new byte[]{(byte) (((serial << 3) | 1) & 0xff)});
|
||||||
|
|
||||||
mBluetoothGattServer.notifyCharacteristicChanged(mBtDevice, writeCharacteristics, false);
|
mBluetoothGattServer.notifyCharacteristicChanged(mBtDevice, writeCharacteristics, false);
|
||||||
@ -109,7 +107,7 @@ class PebbleGATTServer extends BluetoothGattServerCallback {
|
|||||||
mPebbleLESupport.notify();
|
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 header = value[0] & 0xff;
|
||||||
int command = header & 7;
|
int command = header & 7;
|
||||||
int serial = header >> 3;
|
int serial = header >> 3;
|
||||||
|
@ -46,7 +46,7 @@ public class PebbleLESupport {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.close();
|
this.close();
|
||||||
throw new IOException("conntection failed");
|
throw new IOException("connection failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
void writeToPipedOutputStream(byte[] value, int offset, int count) {
|
void writeToPipedOutputStream(byte[] value, int offset, int count) {
|
||||||
|
Loading…
Reference in New Issue
Block a user