1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-04 09:17:29 +01:00

Send more settings to device (with hardcoded values, for now).

Now bracelet should work correctly without ever connecting to native app.
This commit is contained in:
protomors 2017-09-01 21:12:09 +03:00 committed by Andreas Shimokawa
parent c97136e4fe
commit e7fff32fb8
2 changed files with 46 additions and 1 deletions

View File

@ -8,13 +8,17 @@ public final class No1F1Constants {
public static final UUID UUID_CHARACTERISTIC_MEASURE = UUID.fromString("000033f2-0000-1000-8000-00805f9b34fb");
public static final UUID UUID_SERVICE_NO1 = UUID.fromString("000055ff-0000-1000-8000-00805f9b34fb");
public static final byte CMD_DISPLAY_SETTINGS = (byte) 0xa0;
public static final byte CMD_FIRMWARE_VERSION = (byte) 0xa1;
public static final byte CMD_BATTERY = (byte) 0xa2;
public static final byte CMD_DATETIME = (byte) 0xa3;
public static final byte CMD_USER_DATA = (byte) 0xa9;
public static final byte CMD_ALARM = (byte) 0xab;
public static final byte CMD_FACTORY_RESET = (byte) 0xad;
public static final byte CMD_NOTIFICATION = (byte) 0xc1;
public static final byte CMD_ICON = (byte) 0xc3;
public static final byte CMD_DEVICE_SETTINGS = (byte) 0xd3;
public static final byte CMD_HEARTRATE_SETTINGS = (byte) 0xd6;
public static final byte NOTIFICATION_HEADER = (byte) 0x01;
public static final byte NOTIFICATION_CALL = (byte) 0x02;

View File

@ -101,6 +101,7 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
return true;
case No1F1Constants.CMD_NOTIFICATION:
case No1F1Constants.CMD_ICON:
case No1F1Constants.CMD_DEVICE_SETTINGS:
return true;
default:
LOG.warn("Unhandled characteristic change: " + characteristicUUID + " code: " + Arrays.toString(data));
@ -205,7 +206,15 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
@Override
public void onReboot() {
try {
TransactionBuilder builder = performInitialized("clearNotification");
byte[] msg = new byte[]{
(byte) 0xad
};
builder.write(ctrlCharacteristic, msg);
performConnected(builder.getTransaction());
} catch (IOException e) {
}
}
@Override
@ -311,7 +320,39 @@ public class No1F1Support extends AbstractBTLEDeviceSupport {
userBytes[14] = 2; // female
else
userBytes[14] = 1; // male
builder.write(ctrlCharacteristic, userBytes);
// more settings
builder.write(ctrlCharacteristic, new byte[]{
No1F1Constants.CMD_DEVICE_SETTINGS,
0x00, // 1 - turns on inactivity alarm
0x3c,
0x02,
0x03,
0x01,
0x00
});
// display settings
builder.write(ctrlCharacteristic, new byte[]{
No1F1Constants.CMD_DISPLAY_SETTINGS,
0x01, // 1 - display distance in kilometers, 2 - in miles
0x01 // 1 - display 24-hour clock, 2 - for 12-hour with AM/PM
});
// heart rate measurement mode
builder.write(ctrlCharacteristic, new byte[]{
No1F1Constants.CMD_HEARTRATE_SETTINGS,
0x02, // 1 - static (measure for 15 seconds), 2 - realtime
});
// periodic heart rate measurement
builder.write(ctrlCharacteristic, new byte[]{
No1F1Constants.CMD_HEARTRATE_SETTINGS,
0x01,
0x02 // measure heart rate every 2 hours (0 to turn off)
});
}
private void setVibration(int duration, int count) {