1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-25 19:36:50 +01:00

Zepp OS: Fix reminder creation

Regression introduced by 9d3c480414
This commit is contained in:
José Rebelo 2023-07-12 23:27:14 +01:00
parent 525f1567c1
commit 258023a05d

View File

@ -139,9 +139,11 @@ public class ZeppOsRemindersService extends AbstractZeppOsService {
return;
}
// Send the reminders, skipping the reserved slots for calendar events
// Send the reminders
for (int i = 0; i < reminders.size(); i++) {
LOG.debug("Sending reminder at position {}", i);
sendReminderToDevice(builder, i, reminders.get(i));
}
// Delete the remaining slots, skipping the sent reminders
@ -223,13 +225,15 @@ public class ZeppOsRemindersService extends AbstractZeppOsService {
}
private void decodeAndUpdateReminders(final byte[] payload) {
final int numReminders = payload[1];
final int numReminders = payload[1] & 0xff;
if (payload.length < 3 + numReminders * 11) {
LOG.warn("Unexpected payload length of {} for {} reminders", payload.length, numReminders);
return;
}
LOG.debug("Got {} reminders from band", numReminders);
int i = 3;
while (i < payload.length) {
if (payload.length - i < 11) {
@ -252,7 +256,7 @@ public class ZeppOsRemindersService extends AbstractZeppOsService {
i += reminderText.length() + 1;
LOG.info("Reminder {}, {}, {}, {}", reminderPosition, String.format("0x%04x", reminderFlags), reminderDate, reminderText);
LOG.info("Reminder[{}]: {}, {}, {}", reminderPosition, String.format("0x%04x", reminderFlags), reminderDate, reminderText);
}
if (i != payload.length) {
LOG.error("Unexpected reminders payload trailer, {} bytes were not consumed", payload.length - i);