1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-25 03:16:51 +01:00

Add some code to set the Mi Band latency

This commit is contained in:
cpfeiffer 2015-07-20 21:43:23 +02:00
parent 5d121e6e8f
commit 4aa80c149c

View File

@ -496,6 +496,44 @@ public class MiBandSupport extends AbstractBTLEDeviceSupport {
}
}
private byte[] getHighLatency() {
int minConnectionInterval = 460;
int maxConnectionInterval = 500;
int latency = 0;
int timeout = 500;
int advertisementInterval = 0;
return getLatency(minConnectionInterval, maxConnectionInterval, latency, timeout, advertisementInterval);
}
private byte[] getLatency(int minConnectionInterval, int maxConnectionInterval, int latency, int timeout, int advertisementInterval) {
byte result[] = new byte[12];
result[0] = (byte)(minConnectionInterval & 0xff);
result[1] = (byte)(0xff & minConnectionInterval >> 8);
result[2] = (byte)(maxConnectionInterval & 0xff);
result[3] = (byte) (0xff & maxConnectionInterval >> 8);
result[4] = (byte)(latency & 0xff);
result[5] = (byte)(0xff & latency >> 8);
result[6] = (byte)(timeout & 0xff);
result[7] = (byte) (0xff & timeout >> 8);
result[8] = 0;
result[9] = 0;
result[10] = (byte)(advertisementInterval & 0xff);
result[11] = (byte)(0xff & advertisementInterval >> 8);
return result;
}
private byte[] getLowLatency() {
int minConnectionInterval = 39;
int maxConnectionInterval = 49;
int latency = 0;
int timeout = 500;
int advertisementInterval = 0;
return getLatency(minConnectionInterval, maxConnectionInterval, latency, timeout, advertisementInterval);
}
@Override
public void onInstallApp(Uri uri) {
// not supported