diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java index cee8549e9..7835b392e 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/huami/HuamiSupport.java @@ -818,7 +818,6 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport { } - private void sendMusicStateToDevice() { if (characteristicChunked == null) { return; @@ -1323,8 +1322,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport { if ((currentButtonPressTime == 0) || (timeSinceLastPress < buttonPressMaxDelay)) { currentButtonPressCount++; - } - else { + } else { currentButtonPressCount = 1; currentButtonActionId = 0; } @@ -1352,8 +1350,6 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport { } - - @Override public boolean onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) { @@ -1703,6 +1699,45 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport { return this; } + private HuamiSupport sendCalendarEventsAsReminder(TransactionBuilder builder) { + CalendarEvents upcomingEvents = new CalendarEvents(); + List calendarEvents = upcomingEvents.getCalendarEventList(getContext()); + Calendar calendar = Calendar.getInstance(); + + int iteration = 0; + + for (CalendarEvents.CalendarEvent calendarEvent : calendarEvents) { + if (iteration > 8) { // limit ? + break; + } + calendar.setTimeInMillis(calendarEvent.getBegin()); + byte[] title = calendarEvent.getTitle().getBytes(); + byte[] body = calendarEvent.getDescription().getBytes(); + + int length = 18 + title.length + 1 + body.length + 1; + ByteBuffer buf = ByteBuffer.allocate(length); + + buf.order(ByteOrder.LITTLE_ENDIAN); + buf.put((byte) 0x0b); // always 0x0b? + buf.put((byte) 0); // îd + buf.putInt(0x08 | 0x04 | 0x01); // flags 0x01 = enable, 0x04 = end date present, 0x08 = has text + calendar.setTimeInMillis(calendarEvent.getBegin()); + buf.put(BLETypeConversions.shortCalendarToRawBytes(calendar)); + calendar.setTimeInMillis(calendarEvent.getEnd()); + buf.put(BLETypeConversions.shortCalendarToRawBytes(calendar)); + buf.put(title); + buf.put((byte) 0); // 0 Terminated + buf.put(body); + buf.put((byte) 0); // 0 Terminated + writeToChunked(builder, 2, buf.array()); + builder.queue(getQueue()); + + iteration++; + } + + return this; + } + @Override public void onSendConfiguration(String config) { TransactionBuilder builder;