Skip to content

Commit

Permalink
treat 000 parsed versions as null
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamVe committed May 20, 2024
1 parent 70166aa commit bc8d8f0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -266,13 +266,24 @@ static DeviceInfo parseTlvs(Map<Integer, byte[]> data, Version defaultVersion) {
? Version.fromBytes(data.get(TAG_FIRMWARE_VERSION))
: defaultVersion;

Version fpsVersion = data.containsKey(TAG_FPS_VERSION)
? Version.fromBytes(data.get(TAG_FPS_VERSION))
: null;

Version stmVersion = data.containsKey(TAG_STM_VERSION)
? Version.fromBytes(data.get(TAG_STM_VERSION))
: null;
final Version versionZero = new Version(0,0,0);

Version fpsVersion = null;
if (data.containsKey(TAG_FPS_VERSION)) {
Version tempVersion = Version.fromBytes(data.get(TAG_FPS_VERSION));
if (!tempVersion.equals(versionZero)) {
fpsVersion = tempVersion;
}
}

Version stmVersion = null;
if (data.containsKey(TAG_STM_VERSION)) {
Version tempVersion = Version.fromBytes(data.get(TAG_STM_VERSION));
if (!tempVersion.equals(versionZero)) {
stmVersion = tempVersion;
}
}

short autoEjectTimeout = (short) readInt(data.get(TAG_AUTO_EJECT_TIMEOUT));
byte challengeResponseTimeout = (byte) readInt(data.get(TAG_CHALLENGE_RESPONSE_TIMEOUT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,18 @@ public void testParseResetBlocked() {
@Test
public void testParseFpsVersion() {
assertNull(defaultInfo().getFpsVersion());
assertNull(infoOf(0x20, fromHex("000000")).getFpsVersion());
assertNull(infoOf(0x20, fromHex("000000000000000000")).getFpsVersion());
assertEquals(new Version(0,0,1), infoOf(0x20, fromHex("000001")).getFpsVersion());
assertEquals(new Version(5, 6, 6), infoOf(0x20, fromHex("050606")).getFpsVersion());
}

@Test
public void testParseStmVersion() {
assertNull(defaultInfo().getStmVersion());
assertNull(infoOf(0x21, fromHex("000000")).getStmVersion());
assertNull(infoOf(0x21, fromHex("000000000000000000")).getStmVersion());
assertEquals(new Version(0,0,1), infoOf(0x21, fromHex("000001")).getStmVersion());
assertEquals(new Version(7, 0, 5), infoOf(0x21, fromHex("070005")).getStmVersion());
}

Expand Down

0 comments on commit bc8d8f0

Please sign in to comment.