mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-26 00:21:45 +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() {
|
private void sendMusicStateToDevice() {
|
||||||
if (characteristicChunked == null) {
|
if (characteristicChunked == null) {
|
||||||
return;
|
return;
|
||||||
@ -1323,8 +1322,7 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
|
|
||||||
if ((currentButtonPressTime == 0) || (timeSinceLastPress < buttonPressMaxDelay)) {
|
if ((currentButtonPressTime == 0) || (timeSinceLastPress < buttonPressMaxDelay)) {
|
||||||
currentButtonPressCount++;
|
currentButtonPressCount++;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
currentButtonPressCount = 1;
|
currentButtonPressCount = 1;
|
||||||
currentButtonActionId = 0;
|
currentButtonActionId = 0;
|
||||||
}
|
}
|
||||||
@ -1352,8 +1350,6 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCharacteristicChanged(BluetoothGatt gatt,
|
public boolean onCharacteristicChanged(BluetoothGatt gatt,
|
||||||
BluetoothGattCharacteristic characteristic) {
|
BluetoothGattCharacteristic characteristic) {
|
||||||
@ -1703,6 +1699,45 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
|
|||||||
return this;
|
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
|
@Override
|
||||||
public void onSendConfiguration(String config) {
|
public void onSendConfiguration(String config) {
|
||||||
TransactionBuilder builder;
|
TransactionBuilder builder;
|
||||||
|
Loading…
Reference in New Issue
Block a user