1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-20 12:00:51 +02:00

Mi Band 8: Save number of pending alarm acks (wip)

This commit is contained in:
José Rebelo 2023-10-06 23:57:14 +01:00
parent 29fe3bc6ae
commit 18fc29fae7

View File

@ -75,6 +75,8 @@ public class XiaomiScheduleService extends AbstractXiaomiService {
// Map of alarm position to Alarm, as returned by the band
private final Map<Integer, Alarm> watchAlarms = new HashMap<>();
private int pendingAlarmAcks = 0;
public XiaomiScheduleService(final XiaomiSupport support) {
super(support);
}
@ -85,6 +87,14 @@ public class XiaomiScheduleService extends AbstractXiaomiService {
case CMD_ALARMS_GET:
handleAlarms(cmd.getSchedule().getAlarms());
break;
case CMD_ALARMS_CREATE:
pendingAlarmAcks--;
if (pendingAlarmAcks <= 0) {
final TransactionBuilder builder = getSupport().createTransactionBuilder("request alarms after all acks");
requestAlarms(builder);
builder.queue(getSupport().getQueue());
}
break;
case CMD_WORLD_CLOCKS_GET:
handleWorldClocks(cmd.getSchedule().getWorldClocks());
break;
@ -208,6 +218,7 @@ public class XiaomiScheduleService extends AbstractXiaomiService {
.build()
);
} else {
pendingAlarmAcks++;
schedule.setCreateAlarm(alarmDetails);
}