mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2025-01-01 05:25:50 +01:00
added different requests
This commit is contained in:
parent
e2a573e3e2
commit
7d015e3275
@ -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;
|
||||
}
|
||||
}
|
@ -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};
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user