1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-24 19:06:53 +01:00

TLW64: Support factory reset

This commit is contained in:
115ek 2020-06-30 16:52:50 +02:00
parent 654019e2c0
commit 1e6146f4aa
2 changed files with 14 additions and 1 deletions

View File

@ -29,6 +29,7 @@ public final class TLW64Constants {
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;

View File

@ -50,6 +50,7 @@ import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
import nodomain.freeyourgadget.gadgetbridge.service.btle.AbstractBTLEDeviceSupport;
import nodomain.freeyourgadget.gadgetbridge.service.btle.TransactionBuilder;
import nodomain.freeyourgadget.gadgetbridge.service.btle.actions.SetDeviceStateAction;
import nodomain.freeyourgadget.gadgetbridge.service.serial.GBDeviceProtocol;
import nodomain.freeyourgadget.gadgetbridge.util.GB;
import static org.apache.commons.lang3.math.NumberUtils.min;
@ -196,7 +197,18 @@ public class TLW64Support extends AbstractBTLEDeviceSupport {
@Override
public void onReset(int flags) {
if (flags == GBDeviceProtocol.RESET_FLAGS_FACTORY_RESET){
try {
TransactionBuilder builder = performInitialized("factoryReset");
byte[] msg = new byte[]{
TLW64Constants.CMD_FACTORY_RESET,
};
builder.write(ctrlCharacteristic, msg);
builder.queue(getQueue());
} catch (IOException e) {
GB.toast(getContext(), "Error during factory reset: " + e.getLocalizedMessage(), Toast.LENGTH_LONG, GB.ERROR);
}
}
}
@Override