1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-28 21:06:50 +01:00

Merge pull request #543 from jpbarraca/hplus-alarm-clear

HPlus: Clear Alarms
This commit is contained in:
Andreas Shimokawa 2017-02-06 18:49:28 +01:00 committed by GitHub
commit 32a326c24b
2 changed files with 18 additions and 5 deletions

View File

@ -36,6 +36,8 @@ public final class HPlusConstants {
public static final byte INCOMING_CALL_STATE_DISABLED_THRESHOLD = 0x7B;
public static final byte INCOMING_CALL_STATE_ENABLED = (byte) 0xAA;
public static final byte ARG_ALARM_DISABLE = (byte) -1;
public static final byte[] CMD_SET_PREF_START = new byte[]{0x4f, 0x5a};
public static final byte[] CMD_SET_PREF_START1 = new byte[]{0x4d};
//public static final byte CMD_SET_ALARM = 0x4c; Unknown

View File

@ -355,9 +355,17 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
private HPlusSupport setAlarm(TransactionBuilder transaction, Calendar t) {
byte hour = HPlusConstants.ARG_ALARM_DISABLE;
byte minute = HPlusConstants.ARG_ALARM_DISABLE;
if(t != null){
hour = (byte) t.get(Calendar.HOUR_OF_DAY);
minute = (byte) t.get(Calendar.MINUTE);
}
transaction.write(ctrlCharacteristic, new byte[]{HPlusConstants.CMD_SET_ALARM,
(byte) t.get(Calendar.HOUR_OF_DAY),
(byte) t.get(Calendar.MINUTE)});
hour,
minute});
return this;
}
@ -429,8 +437,8 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
@Override
public void onSetAlarms(ArrayList<? extends Alarm> alarms) {
if (alarms.size() == 0)
return;
TransactionBuilder builder = new TransactionBuilder("alarm");
for (Alarm alarm : alarms) {
@ -441,7 +449,6 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
continue;
Calendar t = alarm.getAlarmCal();
TransactionBuilder builder = new TransactionBuilder("alarm");
setAlarm(builder, t);
builder.queue(getQueue());
@ -449,6 +456,10 @@ public class HPlusSupport extends AbstractBTLEDeviceSupport {
return; //Only first alarm
}
setAlarm(builder, null);
builder.queue(getQueue());
GB.toast(getContext(), getContext().getString(R.string.user_feedback_all_alarms_disabled), Toast.LENGTH_SHORT, GB.INFO);
}