Files
project-vesper/src/Version.hpp
T
bonaminandClaude Sonnet 5 2707594f65 chore(version): bump to 2.1.0
Corrects builds that were incorrectly shipped as 2.0.11 before the
firmware was properly rebuilt. First 2.x release to be tested on the
field.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-17 22:18:51 +03:00

72 lines
3.6 KiB
C++

#pragma once
#include <Arduino.h>
// ═══════════════════════════════════════════════════════════════════════
// FIRMWARE VERSION
// ═══════════════════════════════════════════════════════════════════════
// Format: MAJOR.MINOR.PATCH (e.g. "2.0.0")
// This is the single source of truth. It is compiled into the binary
// and never stored in NVS — the binary IS the version.
//
// VERSION HISTORY:
// v154 (legacy integer) - Last integer-versioned release
// v2.0.0 - First SemVer release
// v2.0.1 - Adds Safemode-OTA during boot.
// v2.0.2 - Fixes Legacy adapter not accepting non designated command versions
// v2.0.3 - Fixes various command and response builder problems
// v2.1.0 - Corrects builds that were incorrectly shipped as 2.0.11 before the firmware was properly rebuilt.
// First 2.x release to be tested on the field
// ═══════════════════════════════════════════════════════════════════════
#define FW_VERSION "2.1.0"
// ═══════════════════════════════════════════════════════════════════════
// SemVer — lightweight 3-part version struct
// ═══════════════════════════════════════════════════════════════════════
struct SemVer {
uint8_t major;
uint8_t minor;
uint8_t patch;
// Parse "2.0.0" or legacy integer "154" (treated as 0.0.154)
static SemVer parse(const String& s) {
SemVer v{0, 0, 0};
int first = s.indexOf('.');
if (first == -1) {
// Legacy integer format: "154" -> {0, 0, 154}
// Clamp to uint8_t range; values > 255 are stored in minor too
uint16_t n = (uint16_t)s.toInt();
v.minor = (uint8_t)(n / 100);
v.patch = (uint8_t)(n % 100);
return v;
}
int second = s.indexOf('.', first + 1);
v.major = (uint8_t)s.substring(0, first).toInt();
if (second == -1) {
v.minor = (uint8_t)s.substring(first + 1).toInt();
} else {
v.minor = (uint8_t)s.substring(first + 1, second).toInt();
v.patch = (uint8_t)s.substring(second + 1).toInt();
}
return v;
}
bool operator==(const SemVer& o) const {
return major == o.major && minor == o.minor && patch == o.patch;
}
bool operator!=(const SemVer& o) const { return !(*this == o); }
bool operator<(const SemVer& o) const {
if (major != o.major) return major < o.major;
if (minor != o.minor) return minor < o.minor;
return patch < o.patch;
}
bool operator>(const SemVer& o) const { return o < *this; }
bool operator<=(const SemVer& o) const { return !(o < *this); }
bool operator>=(const SemVer& o) const { return !(*this < o); }
bool isZero() const { return major == 0 && minor == 0 && patch == 0; }
String toString() const {
return String(major) + "." + String(minor) + "." + String(patch);
}
};