mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-06-05 21:49:48 +02:00
TLW64: Wiretap operation
* let's log some packets to make sure we send the right things
This commit is contained in:
@@ -23,6 +23,7 @@ public final class TLW64Constants {
|
||||
|
||||
public static final UUID UUID_SERVICE_NO1 = UUID.fromString("000055ff-0000-1000-8000-00805f9b34fb");
|
||||
public static final UUID UUID_CHARACTERISTIC_CONTROL = UUID.fromString("000033f1-0000-1000-8000-00805f9b34fb");
|
||||
public static final UUID UUID_CHARACTERISTIC_NOTIFY = UUID.fromString("000033f2-0000-1000-8000-00805f9b34fb");
|
||||
|
||||
// Command bytes
|
||||
public static final byte CMD_DISPLAY_SETTINGS = (byte) 0xa0;
|
||||
|
@@ -19,6 +19,7 @@
|
||||
|
||||
package nodomain.freeyourgadget.gadgetbridge.service.devices.tlw64;
|
||||
|
||||
import android.bluetooth.BluetoothGatt;
|
||||
import android.bluetooth.BluetoothGattCharacteristic;
|
||||
import android.net.Uri;
|
||||
import android.text.format.DateFormat;
|
||||
@@ -29,6 +30,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.UUID;
|
||||
@@ -60,6 +62,7 @@ public class TLW64Support extends AbstractBTLEDeviceSupport {
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TLW64Support.class);
|
||||
|
||||
public BluetoothGattCharacteristic ctrlCharacteristic = null;
|
||||
public BluetoothGattCharacteristic notifyCharacteristic = null;
|
||||
|
||||
public TLW64Support() {
|
||||
super(LOG);
|
||||
@@ -73,6 +76,10 @@ public class TLW64Support extends AbstractBTLEDeviceSupport {
|
||||
builder.add(new SetDeviceStateAction(getDevice(), GBDevice.State.INITIALIZING, getContext()));
|
||||
|
||||
ctrlCharacteristic = getCharacteristic(TLW64Constants.UUID_CHARACTERISTIC_CONTROL);
|
||||
notifyCharacteristic = getCharacteristic(TLW64Constants.UUID_CHARACTERISTIC_NOTIFY);
|
||||
|
||||
builder.setGattCallback(this);
|
||||
builder.notify(notifyCharacteristic, true);
|
||||
|
||||
setTime(builder);
|
||||
setDisplaySettings(builder);
|
||||
@@ -90,6 +97,45 @@ public class TLW64Support extends AbstractBTLEDeviceSupport {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
|
||||
if (super.onCharacteristicChanged(gatt, characteristic)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
UUID characteristicUUID = characteristic.getUuid();
|
||||
byte[] data = characteristic.getValue();
|
||||
if (data.length == 0)
|
||||
return true;
|
||||
|
||||
switch (data[0]) {
|
||||
case TLW64Constants.CMD_DISPLAY_SETTINGS:
|
||||
LOG.info("Display settings updated");
|
||||
return true;
|
||||
case TLW64Constants.CMD_DATETIME:
|
||||
LOG.info("Time is set to: " + (data[1] * 256 + ((int) data[2] & 0xff)) + "-" + data[3] + "-" + data[4] + " " + data[5] + ":" + data[6] + ":" + data[7]);
|
||||
return true;
|
||||
case TLW64Constants.CMD_USER_DATA:
|
||||
LOG.info("User data updated");
|
||||
return true;
|
||||
case TLW64Constants.CMD_ALARM:
|
||||
LOG.info("Alarm updated");
|
||||
return true;
|
||||
case TLW64Constants.CMD_FACTORY_RESET:
|
||||
LOG.info("Factory reset requested");
|
||||
return true;
|
||||
case TLW64Constants.CMD_NOTIFICATION:
|
||||
LOG.info("Notification is displayed");
|
||||
return true;
|
||||
case TLW64Constants.CMD_ICON:
|
||||
LOG.info("Icon is displayed");
|
||||
return true;
|
||||
default:
|
||||
LOG.warn("Unhandled characteristic change: " + characteristicUUID + " code: " + Arrays.toString(data));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNotification(NotificationSpec notificationSpec) {
|
||||
switch (notificationSpec.type) {
|
||||
|
Reference in New Issue
Block a user