All fixes before Bluetooth

This commit is contained in:
2026-10-14 07:12:24 +08:00
parent fbc92d57ba
commit 1ec485701a
13 changed files with 504 additions and 17 deletions
+20
View File
@@ -42,6 +42,18 @@ public sealed class EcuInfo
public byte UpgradeFuture12 { get; init; }
public byte UpgradeFuture2 { get; init; } // only if buffer > 68
// ── Registration / activation ─────────────────────────────────────────────
/// <summary>
/// ECU activation nibble (legacy <c>Reg1_Reg2</c> = <c>buf[offset+53] &amp; 0x0F</c>,
/// present only on longer info buffers / newer firmware). &gt; 0 means the unit has
/// been activated. Used by the post-unlock status gate as the offline / server-error
/// fallback and to rescue "not registered" verdicts (see EcuStatusInterpreter).
/// </summary>
public byte Reg1Reg2 { get; init; }
/// <summary>True when the ECU reports itself activated (<see cref="Reg1Reg2"/> &gt; 0).</summary>
public bool IsActivated => Reg1Reg2 > 0;
// ── Derived ──────────────────────────────────────────────────────────────
public int RpmLimit => UpgradeRpmMax * 100;
/// <summary>
@@ -153,6 +165,13 @@ public sealed class EcuInfo
hwComp = buf[o + 12];
}
// Registration/activation nibble — legacy Reg1_Reg2 = buf[offset+53] & 0x0F.
// The legacy parser maps offset+37 → FW_Version, which is this parser's o, so
// Reg1_Reg2 lands at o+16. Only present on longer buffers (legacy gate: len >= 84);
// absent on older units → 0 (treated as "not activated", but those are FW < 150
// which the status gate passes anyway).
byte reg1Reg2 = buf.Length > o + 16 ? (byte)(buf[o + 16] & 0x0F) : (byte)0;
var appInfoVersion = buf[^1]; // last byte
var pwdRstCount = buf[^5]; // 4 bytes from end
@@ -182,6 +201,7 @@ public sealed class EcuInfo
UpgradeLogImmo = upgradeLogImmo,
UpgradeFuture12 = upgradeFuture12,
UpgradeFuture2 = upgradeFuture2,
Reg1Reg2 = reg1Reg2,
};
}