mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-25 10:05:49 +01:00
Huami: add unused and untested co to send upcoming calender events as notifications
This commit is contained in:
parent
81aef0dd52
commit
71b76c8e8f
@ -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.CalendarEvent> 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;
|
||||
|
Loading…
Reference in New Issue
Block a user