1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-27 19:15:50 +01:00

Huawei: SetMediumToStrengthThresholdRequest v2 implemented

This commit is contained in:
Me7c7 2024-09-20 16:56:01 +03:00 committed by José Rebelo
parent fa99ea5831
commit 113f9b87c6
3 changed files with 34 additions and 10 deletions

View File

@ -396,12 +396,14 @@ public class HuaweiCoordinator {
public boolean supportsFitnessThresholdValue() { public boolean supportsFitnessThresholdValue() {
return supportsCommandForService(0x07, 0x29); return supportsCommandForService(0x07, 0x29);
} }
public boolean supportsFitnessThresholdValueV2() { return supportsExpandCapability(0x9a) || supportsExpandCapability(0x9c); }
// 0x1d - SupportTemperature // 0x1d - SupportTemperature
// 0xba - SupportTemperatureClassification // 0xba - SupportTemperatureClassification
// 0x43 - SupportTemperatureStudy // 0x43 - SupportTemperatureStudy
public boolean supportsTemperature() { return supportsExpandCapability(0x1d); } public boolean supportsTemperature() { return supportsExpandCapability(0x1d); }
public boolean supportsEventAlarm() { public boolean supportsEventAlarm() {
return supportsCommandForService(0x08, 0x01); return supportsCommandForService(0x08, 0x01);
} }

View File

@ -550,7 +550,9 @@ public class FitnessData {
byte heartRate, byte heartRate,
byte cycleSpeed, byte cycleSpeed,
byte sample, byte sample,
byte countLength) { byte countLength,
int walkRunSpeed,
int walkRunWithHeartRate) {
super(paramsProvider); super(paramsProvider);
this.serviceId = FitnessData.id; this.serviceId = FitnessData.id;
@ -571,7 +573,12 @@ public class FitnessData {
.put(0x04, cycleSpeed) .put(0x04, cycleSpeed)
.put(0x05, sample) .put(0x05, sample)
.put(0x06, countLength); .put(0x06, countLength);
if(walkRunSpeed != -1) {
this.tlv.put(0x07, (byte)walkRunSpeed);
}
if(walkRunWithHeartRate != -1) {
this.tlv.put(0x08, (byte)walkRunWithHeartRate);
}
this.complete = true; this.complete = true;
} }
} }

View File

@ -44,14 +44,29 @@ public class SetMediumToStrengthThresholdRequest extends Request {
protected List<byte[]> createRequest() throws RequestCreationException { protected List<byte[]> createRequest() throws RequestCreationException {
try { try {
//Hardcoded value till interface enable threshold values //Hardcoded value till interface enable threshold values
if(supportProvider.getHuaweiCoordinator().supportsFitnessThresholdValueV2()) {
return new MediumToStrengthThreshold.Request(paramsProvider,
(byte) 0x6E,
(byte) 0x3C,
(byte) 0x19,
(byte) 0x58,
(byte) 0x01,
(byte) 0x01,
0x28,
0x28
).serialize();
} else {
return new MediumToStrengthThreshold.Request(paramsProvider, return new MediumToStrengthThreshold.Request(paramsProvider,
(byte) 0x6E, (byte) 0x6E,
(byte) 0x3C, (byte) 0x3C,
(byte) 0x05, (byte) 0x05,
(byte) 0x40, (byte) 0x40,
(byte) 0x50, (byte) 0x50,
(byte)0x03 (byte) 0x03,
-1,
-1
).serialize(); ).serialize();
}
} catch (HuaweiPacket.CryptoException e) { } catch (HuaweiPacket.CryptoException e) {
throw new RequestCreationException(e); throw new RequestCreationException(e);
} }