1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-09 03:37:03 +01:00

Garmin: minor fixes to some messages.

Prevent sending double status messages / ACKs if the actual outgoing message is also a status message.
Prevent sending ACKs for incoming ACK messages.
This commit is contained in:
Daniele Gobbetti 2024-08-20 15:59:32 +02:00
parent f95d85d7e8
commit d0b525f420
5 changed files with 13 additions and 9 deletions

View File

@ -15,7 +15,7 @@ public class CurrentTimeRequestMessage extends GFDIMessage {
public CurrentTimeRequestMessage(int referenceID, GarminMessage garminMessage) {
this.garminMessage = garminMessage;
this.referenceID = referenceID;
this.statusMessage = this.getStatusMessage();
this.statusMessage = null; //our outgoing message is an ACK message
}
public static CurrentTimeRequestMessage parseIncoming(MessageReader reader, GarminMessage garminMessage) {

View File

@ -8,7 +8,7 @@ public class MusicControlCapabilitiesMessage extends GFDIMessage {
public MusicControlCapabilitiesMessage(GarminMessage garminMessage, int supportedCapabilities) {
this.garminMessage = garminMessage;
this.supportedCapabilities = supportedCapabilities;
this.statusMessage = this.getStatusMessage();
this.statusMessage = null; //our outgoing message is an ACK message
}
public static MusicControlCapabilitiesMessage parseIncoming(MessageReader reader, GarminMessage garminMessage) {

View File

@ -43,7 +43,7 @@ public abstract class GFDIStatusMessage extends GFDIMessage {
LOG.warn("Received {} for message {}", status, (null == originalGarminMessage) ? originalMessageType : originalGarminMessage.name());
}
return new GenericStatusMessage(garminMessage, status);
return new GenericStatusMessage(originalGarminMessage, status, false); //don't ack the ack
}
}

View File

@ -6,15 +6,24 @@ public class GenericStatusMessage extends GFDIStatusMessage {
private final Status status;
private int messageType; // for unsupported message types
private boolean sendOutgoing;
public GenericStatusMessage(GarminMessage originalMessage, Status status) {
this.garminMessage = originalMessage;
this.status = status;
this.sendOutgoing = true;
}
public GenericStatusMessage(GarminMessage originalMessage, Status status, boolean sendOutgoing) {
this.garminMessage = originalMessage;
this.status = status;
this.sendOutgoing = sendOutgoing;
}
public GenericStatusMessage(int messageType, Status status) {
this.messageType = messageType;
this.status = status;
this.sendOutgoing = false;
}
@Override
@ -24,7 +33,7 @@ public class GenericStatusMessage extends GFDIStatusMessage {
writer.writeShort(GarminMessage.RESPONSE.getId());
writer.writeShort(messageType != 0 ? messageType : garminMessage.getId());
writer.writeByte(status.ordinal());
return true;
return sendOutgoing;
}
}

View File

@ -30,11 +30,6 @@ public class NotificationDataStatusMessage extends GFDIStatusMessage {
return status.equals(Status.ACK) && transferStatus.equals(TransferStatus.OK);
}
@Override
protected boolean generateOutgoing() {
return false;
}
public enum TransferStatus {
OK,
RESEND,