mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 02:25:50 +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:
parent
f95d85d7e8
commit
d0b525f420
@ -15,7 +15,7 @@ public class CurrentTimeRequestMessage extends GFDIMessage {
|
|||||||
public CurrentTimeRequestMessage(int referenceID, GarminMessage garminMessage) {
|
public CurrentTimeRequestMessage(int referenceID, GarminMessage garminMessage) {
|
||||||
this.garminMessage = garminMessage;
|
this.garminMessage = garminMessage;
|
||||||
this.referenceID = referenceID;
|
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) {
|
public static CurrentTimeRequestMessage parseIncoming(MessageReader reader, GarminMessage garminMessage) {
|
||||||
|
@ -8,7 +8,7 @@ public class MusicControlCapabilitiesMessage extends GFDIMessage {
|
|||||||
public MusicControlCapabilitiesMessage(GarminMessage garminMessage, int supportedCapabilities) {
|
public MusicControlCapabilitiesMessage(GarminMessage garminMessage, int supportedCapabilities) {
|
||||||
this.garminMessage = garminMessage;
|
this.garminMessage = garminMessage;
|
||||||
this.supportedCapabilities = supportedCapabilities;
|
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) {
|
public static MusicControlCapabilitiesMessage parseIncoming(MessageReader reader, GarminMessage garminMessage) {
|
||||||
|
@ -43,7 +43,7 @@ public abstract class GFDIStatusMessage extends GFDIMessage {
|
|||||||
LOG.warn("Received {} for message {}", status, (null == originalGarminMessage) ? originalMessageType : originalGarminMessage.name());
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,15 +6,24 @@ public class GenericStatusMessage extends GFDIStatusMessage {
|
|||||||
|
|
||||||
private final Status status;
|
private final Status status;
|
||||||
private int messageType; // for unsupported message types
|
private int messageType; // for unsupported message types
|
||||||
|
private boolean sendOutgoing;
|
||||||
|
|
||||||
public GenericStatusMessage(GarminMessage originalMessage, Status status) {
|
public GenericStatusMessage(GarminMessage originalMessage, Status status) {
|
||||||
this.garminMessage = originalMessage;
|
this.garminMessage = originalMessage;
|
||||||
this.status = status;
|
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) {
|
public GenericStatusMessage(int messageType, Status status) {
|
||||||
this.messageType = messageType;
|
this.messageType = messageType;
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
this.sendOutgoing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -24,7 +33,7 @@ public class GenericStatusMessage extends GFDIStatusMessage {
|
|||||||
writer.writeShort(GarminMessage.RESPONSE.getId());
|
writer.writeShort(GarminMessage.RESPONSE.getId());
|
||||||
writer.writeShort(messageType != 0 ? messageType : garminMessage.getId());
|
writer.writeShort(messageType != 0 ? messageType : garminMessage.getId());
|
||||||
writer.writeByte(status.ordinal());
|
writer.writeByte(status.ordinal());
|
||||||
return true;
|
return sendOutgoing;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,11 +30,6 @@ public class NotificationDataStatusMessage extends GFDIStatusMessage {
|
|||||||
return status.equals(Status.ACK) && transferStatus.equals(TransferStatus.OK);
|
return status.equals(Status.ACK) && transferStatus.equals(TransferStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected boolean generateOutgoing() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum TransferStatus {
|
public enum TransferStatus {
|
||||||
OK,
|
OK,
|
||||||
RESEND,
|
RESEND,
|
||||||
|
Loading…
Reference in New Issue
Block a user