From f0174d904a2a02d542dff1a844d8e701e24248c1 Mon Sep 17 00:00:00 2001 From: Sebastian Kranz Date: Fri, 13 Jul 2018 10:10:41 +0200 Subject: [PATCH] Bugfix: calendar needs the date as number. Add comment about converting date digits to characters. --- .../service/devices/zetime/ZeTimeDeviceSupport.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java index d8a5897ab..95535c76e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java @@ -201,6 +201,8 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { byte[] subject = null; byte[] notification = null; Calendar time = GregorianCalendar.getInstance(); + // convert every single digit of the date to ascii characters + // we do it like so: use the base chrachter of '0' and add the digit byte[] datetimeBytes = new byte[]{ (byte) ((time.get(Calendar.YEAR) / 1000) + '0'), (byte) (((time.get(Calendar.YEAR) / 100)%10) + '0'), @@ -352,10 +354,10 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { CalendarEvent[7] = (byte)(time.get(Calendar.YEAR) >> 8); CalendarEvent[8] = (byte)(time.get(Calendar.MONTH)+1); CalendarEvent[9] = (byte)time.get(Calendar.DAY_OF_MONTH); - CalendarEvent[10] = (byte) ((time.get(Calendar.HOUR_OF_DAY)/10) + '0'); - CalendarEvent[11] = (byte) ((time.get(Calendar.HOUR_OF_DAY)%10) + '0'); - CalendarEvent[12] = (byte) ((time.get(Calendar.MINUTE)/10) + '0'); - CalendarEvent[13] = (byte) ((time.get(Calendar.MINUTE)%10) + '0'); + CalendarEvent[10] = (byte) (time.get(Calendar.HOUR_OF_DAY) & 0xff); + CalendarEvent[11] = (byte) (time.get(Calendar.HOUR_OF_DAY) >> 8); + CalendarEvent[12] = (byte) (time.get(Calendar.MINUTE) & 0xff); + CalendarEvent[13] = (byte) (time.get(Calendar.MINUTE) >> 8); CalendarEvent[14] = (byte) calendarEventSpec.title.getBytes(StandardCharsets.UTF_8).length; System.arraycopy(calendarEventSpec.title.getBytes(StandardCharsets.UTF_8), 0, CalendarEvent, 15, calendarEventSpec.title.getBytes(StandardCharsets.UTF_8).length); CalendarEvent[CalendarEvent.length-1] = ZeTimeConstants.CMD_END; @@ -469,6 +471,8 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport { byte[] subject = null; byte[] notification = null; Calendar time = GregorianCalendar.getInstance(); + // convert every single digit of the date to ascii characters + // we do it like so: use the base chrachter of '0' and add the digit byte[] datetimeBytes = new byte[]{ (byte) ((time.get(Calendar.YEAR) / 1000) + '0'), (byte) (((time.get(Calendar.YEAR) / 100)%10) + '0'),