Added option to select firmware channel (#1060)

This commit is contained in:
Gunnar Skjold
2025-11-13 15:14:52 +01:00
committed by GitHub
parent c648546b61
commit 61f0356a10
10 changed files with 120 additions and 37 deletions

View File

@@ -50,6 +50,11 @@
#define LED_BEHAVIOUR_ERROR_ONLY 3
#define LED_BEHAVIOUR_OFF 9
#define FIRMWARE_CHANNEL_STABLE 0
#define FIRMWARE_CHANNEL_EARLY 1
#define FIRMWARE_CHANNEL_RC 2
#define FIRMWARE_CHANNEL_SNAPSHOT 3
struct ResetDataContainer {
uint8_t cause;
uint8_t last_cause;
@@ -63,6 +68,7 @@ struct SystemConfig {
uint8_t dataCollectionConsent; // 0 = unknown, 1 = accepted, 2 = declined
char country[3];
uint8_t energyspeedometer;
uint8_t firmwareChannel;
}; // 8
struct NetworkConfig {

View File

@@ -15,6 +15,11 @@ bool AmsConfiguration::getSystemConfig(SystemConfig& config) {
uint8_t configVersion = EEPROM.read(EEPROM_CONFIG_ADDRESS);
EEPROM.get(CONFIG_SYSTEM_START, config);
EEPROM.end();
if(config.firmwareChannel > 3) {
config.firmwareChannel = 0;
}
if(configVersion == EEPROM_CHECK_SUM) {
return true;
} else {
@@ -27,6 +32,7 @@ bool AmsConfiguration::getSystemConfig(SystemConfig& config) {
}
config.userConfigured = false;
config.dataCollectionConsent = 0;
config.firmwareChannel = 0;
config.energyspeedometer = 0;
memset(config.country, 0, 3);
return false;
@@ -42,6 +48,9 @@ bool AmsConfiguration::setSystemConfig(SystemConfig& config) {
sysChanged |= config.dataCollectionConsent != existing.dataCollectionConsent;
sysChanged |= strcmp(config.country, existing.country) != 0;
sysChanged |= config.energyspeedometer != existing.energyspeedometer;
sysChanged |= config.firmwareChannel != existing.firmwareChannel;
} else {
sysChanged = true;
}
EEPROM.begin(EEPROM_SIZE);
stripNonAscii((uint8_t*) config.country, 2);
@@ -979,6 +988,7 @@ void AmsConfiguration::clear() {
EEPROM.get(CONFIG_SYSTEM_START, sys);
sys.userConfigured = false;
sys.dataCollectionConsent = 0;
sys.firmwareChannel = 0;
sys.energyspeedometer = 0;
memset(sys.country, 0, 3);
EEPROM.put(CONFIG_SYSTEM_START, sys);