diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/ActivityPointGetRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/ActivityPointGetRequest.java new file mode 100644 index 000000000..8015e8f23 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/ActivityPointGetRequest.java @@ -0,0 +1,28 @@ +package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests; + +import android.bluetooth.BluetoothGattCharacteristic; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +public class ActivityPointGetRequest extends Request { + public int activityPoint; + + @Override + public byte[] getStartSequence() { + return new byte[]{1, 6}; + } + + @Override + public void handleResponse(BluetoothGattCharacteristic characteristic) { + super.handleResponse(characteristic); + + byte[] value = characteristic.getValue(); + + if (value.length != 6) return; + + ByteBuffer wrap = ByteBuffer.wrap(value); + wrap.order(ByteOrder.LITTLE_ENDIAN); + activityPoint = wrap.getInt(2) >> 8; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/GoalTrackingGetRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/GoalTrackingGetRequest.java new file mode 100644 index 000000000..f3d9189fb --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/GoalTrackingGetRequest.java @@ -0,0 +1,26 @@ +package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests; + +import android.bluetooth.BluetoothGattCharacteristic; + +import java.nio.ByteBuffer; +import java.nio.ByteOrder; + +public class GoalTrackingGetRequest extends Request { + @Override + public void handleResponse(BluetoothGattCharacteristic characteristic) { + byte[] value = characteristic.getValue(); + if(value.length != 5) return; + + ByteBuffer buffer = ByteBuffer.wrap(value); + buffer.order(ByteOrder.LITTLE_ENDIAN); + + short id = buffer.get(3); + + boolean state = buffer.get(4) == 1; + } + + @Override + public byte[] getStartSequence() { + return new byte[]{01, 20, 01}; + } +} diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/GoalTrackingSetRequest.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/GoalTrackingSetRequest.java new file mode 100644 index 000000000..84ade3c75 --- /dev/null +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/qhybrid/requests/GoalTrackingSetRequest.java @@ -0,0 +1,17 @@ +package nodomain.freeyourgadget.gadgetbridge.service.devices.qhybrid.requests; + +public class GoalTrackingSetRequest extends Request { + public GoalTrackingSetRequest(int id, boolean state) { + + } + + @Override + public byte[] getStartSequence() { + return new byte[]{02, 20, 01}; + } + + @Override + public int getPayloadLength() { + return 5; + } +}