mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-12-26 10:35:50 +01:00
Garmin: implement (some kind of) auth negotiation message
Blindly implemented based on the legacy vivomoveHR code, not tested against real devices.
This commit is contained in:
parent
14478f89ac
commit
1d4c85b732
@ -0,0 +1,59 @@
|
|||||||
|
package nodomain.freeyourgadget.gadgetbridge.service.devices.garmin.messages;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.EnumUtils;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
public class AuthNegotiationMessage extends GFDIMessage {
|
||||||
|
|
||||||
|
private final int unknown;
|
||||||
|
private final EnumSet<AuthFlags> requestedAuthFlags;
|
||||||
|
|
||||||
|
public AuthNegotiationMessage(GarminMessage garminMessage, int unknown, EnumSet<AuthFlags> requestedAuthFlags) {
|
||||||
|
this.garminMessage = garminMessage;
|
||||||
|
this.unknown = unknown;
|
||||||
|
this.requestedAuthFlags = requestedAuthFlags;
|
||||||
|
|
||||||
|
LOG.info("Message {}, unkByte: {}, flags: {}", garminMessage, unknown, requestedAuthFlags);
|
||||||
|
|
||||||
|
this.statusMessage = getStatusMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AuthNegotiationMessage parseIncoming(MessageReader reader, GarminMessage garminMessage) {
|
||||||
|
|
||||||
|
final int unk = reader.readByte();
|
||||||
|
final EnumSet<AuthFlags> authFlags = AuthFlags.fromBitMask(reader.readInt());
|
||||||
|
|
||||||
|
return new AuthNegotiationMessage(garminMessage, unk, authFlags);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean generateOutgoing() {
|
||||||
|
|
||||||
|
final MessageWriter writer = new MessageWriter(response);
|
||||||
|
writer.writeShort(0); // placeholder for packet size
|
||||||
|
writer.writeShort(this.garminMessage.getId());
|
||||||
|
|
||||||
|
//set all to 0 as we don't know what else to do
|
||||||
|
writer.writeByte(0);
|
||||||
|
writer.writeInt((int) EnumUtils.generateBitVector(AuthFlags.class, EnumSet.noneOf(AuthFlags.class)));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum AuthFlags {
|
||||||
|
UNK_00000001, //saw in logs
|
||||||
|
UNK_00000010,
|
||||||
|
UNK_00000100,
|
||||||
|
UNK_00001000,
|
||||||
|
UNK_00010000,
|
||||||
|
UNK_00100000,
|
||||||
|
UNK_01000000,
|
||||||
|
UNK_10000000,
|
||||||
|
;
|
||||||
|
|
||||||
|
public static EnumSet<AuthFlags> fromBitMask(final int code) {
|
||||||
|
return EnumUtils.processBitVector(AuthFlags.class, code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -116,6 +116,7 @@ public abstract class GFDIMessage {
|
|||||||
MUSIC_CONTROL_ENTITY_UPDATE(5049, MusicControlEntityUpdateMessage.class),
|
MUSIC_CONTROL_ENTITY_UPDATE(5049, MusicControlEntityUpdateMessage.class),
|
||||||
CONFIGURATION(5050, ConfigurationMessage.class),
|
CONFIGURATION(5050, ConfigurationMessage.class),
|
||||||
CURRENT_TIME_REQUEST(5052, CurrentTimeRequestMessage.class),
|
CURRENT_TIME_REQUEST(5052, CurrentTimeRequestMessage.class),
|
||||||
|
AUTH_NEGOTIATION(5101, AuthNegotiationMessage.class)
|
||||||
;
|
;
|
||||||
private final Class<? extends GFDIMessage> objectClass;
|
private final Class<? extends GFDIMessage> objectClass;
|
||||||
private final int id;
|
private final int id;
|
||||||
|
Loading…
Reference in New Issue
Block a user