1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-02 19:36:14 +02:00
Gadgetbridge/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/messages/status/GenericStatusMessage.java
Daniele Gobbetti 7829c5f1fb Garmin protocol: basic file transfer and notification handling
adds synchronization of supported files from watch to external directory
adds support for Activity and Monitoring files (workouts and activity samples), but those are not integrated yet
adds upload functionality (not used ATM and not tested)
adds notification support without actions
introduces centralized processing of "messageHandlers" (protobuf, file transfer, notifications)

also properly dispose of the music timer when disconnecting
2024-04-18 17:50:17 +02:00

31 lines
1.0 KiB
Java

package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages.status;
import nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages.MessageWriter;
public class GenericStatusMessage extends GFDIStatusMessage {
private final Status status;
private int messageType; // for unsupported message types
public GenericStatusMessage(GarminMessage originalMessage, Status status) {
this.garminMessage = originalMessage;
this.status = status;
}
public GenericStatusMessage(int messageType, Status status) {
this.messageType = messageType;
this.status = status;
}
@Override
protected boolean generateOutgoing() {
final MessageWriter writer = new MessageWriter(response);
writer.writeShort(0); // packet size will be filled below
writer.writeShort(GarminMessage.RESPONSE.getId());
writer.writeShort(messageType != 0 ? messageType : garminMessage.getId());
writer.writeByte(status.ordinal());
return true;
}
}