1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-15 01:20:16 +02:00
Gadgetbridge/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/messages/UploadRequestMessage.java
Daniele Gobbetti fa8f09e95a 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-05-01 23:35:16 +01:00

46 lines
1.4 KiB
Java

package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages;
public class UploadRequestMessage extends GFDIMessage {
private final int fileIndex;
private final int size;
private final boolean generateOutgoing;
private final int dataOffset;
private final int crcSeed;
public UploadRequestMessage(GarminMessage garminMessage, int fileIndex, int size, int dataOffset, int crcSeed) {
this.garminMessage = garminMessage;
this.fileIndex = fileIndex;
this.size = size;
this.dataOffset = dataOffset;
this.crcSeed = crcSeed;
this.statusMessage = this.getStatusMessage();
this.generateOutgoing = false;
}
public UploadRequestMessage(int fileIndex, int size) {
this.garminMessage = GarminMessage.UPLOAD_REQUEST;
this.fileIndex = fileIndex;
this.size = size;
this.dataOffset = 0;
this.crcSeed = 0;
this.statusMessage = this.getStatusMessage();
this.generateOutgoing = true;
}
@Override
protected boolean generateOutgoing() {
final MessageWriter writer = new MessageWriter(response);
writer.writeShort(0); // packet size will be filled below
writer.writeShort(this.garminMessage.getId());
writer.writeShort(this.fileIndex);
writer.writeInt(this.size);
writer.writeInt(this.dataOffset);
writer.writeShort(this.crcSeed);
return generateOutgoing;
}
}