From 17b70a1b82a261ee9ab114c86d024419a4da5be5 Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Sun, 23 Oct 2016 23:05:54 +0200 Subject: [PATCH] Support for more than one alarm #323 Smart alarms not supported yet. --- .../service/devices/miband/MiBand2Support.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBand2Support.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBand2Support.java index 54a184db..026a186f 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBand2Support.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/miband/MiBand2Support.java @@ -1056,9 +1056,10 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport { Calendar calendar = alarm.getAlarmCal(); int daysMask = 0; - if (alarm.getIndex() != 0) { + int maxAlarms = 5; // arbitrary at the moment... + if (alarm.getIndex() >= maxAlarms) { if (alarm.isEnabled()) { - GB.toast(getContext(), "Only the first alarm is currently supported.", Toast.LENGTH_LONG, GB.WARN); + GB.toast(getContext(), "Only 5 alarms are currently supported.", Toast.LENGTH_LONG, GB.WARN); } return; } @@ -1068,8 +1069,8 @@ public class MiBand2Support extends AbstractBTLEDeviceSupport { } byte[] alarmMessage = new byte[] { - (byte) 0x2, // TODO what is this? 0x1 does not work - (byte) 128, // TODO: what is this? + (byte) 0x2, // TODO what is this? + (byte) (128 + alarm.getIndex()), // 128 is the base, alarm slot is added (byte) calendar.get(Calendar.HOUR_OF_DAY), (byte) calendar.get(Calendar.MINUTE), (byte) daysMask,