mirror of
https://github.com/UtilitechAS/amsreader-firmware.git
synced 2026-02-01 22:51:58 +00:00
Move version constants into its own compile-unit
Speeds up the build by moving those constants into a separate compile-unit. Currently, since the version header is auto regenerated on each build, all modules that include it, also have to be recompiled every time.
This commit is contained in:
@@ -36,8 +36,7 @@ ADC_MODE(ADC_VCC);
|
||||
#include <driver/uart.h>
|
||||
#endif
|
||||
|
||||
#include "version.h"
|
||||
|
||||
#include "FirmwareVersion.h"
|
||||
#include "AmsToMqttBridge.h"
|
||||
#include "AmsStorage.h"
|
||||
#include "AmsDataStorage.h"
|
||||
@@ -309,7 +308,7 @@ void setup() {
|
||||
}
|
||||
flashed = Update.end(true);
|
||||
}
|
||||
config.setUpgradeInformation(flashed ? 2 : 0, 0xFF, VERSION, "");
|
||||
config.setUpgradeInformation(flashed ? 2 : 0, 0xFF, FirmwareVersion::VersionString, "");
|
||||
firmwareFile.close();
|
||||
} else {
|
||||
debugW_P(PSTR("AP button pressed, skipping firmware update and deleting firmware file."));
|
||||
@@ -1126,15 +1125,15 @@ void handleDataSuccess(AmsData* data) {
|
||||
}
|
||||
|
||||
time_t now = time(nullptr);
|
||||
if(now < BUILD_EPOCH && data->getListType() >= 3) {
|
||||
if(data->getMeterTimestamp() > BUILD_EPOCH) {
|
||||
if(now < FirmwareVersion::BuildEpoch && data->getListType() >= 3) {
|
||||
if(data->getMeterTimestamp() > FirmwareVersion::BuildEpoch) {
|
||||
debugI_P(PSTR("Using timestamp from meter"));
|
||||
now = data->getMeterTimestamp();
|
||||
} else if(data->getPackageTimestamp() > BUILD_EPOCH) {
|
||||
} else if(data->getPackageTimestamp() > FirmwareVersion::BuildEpoch) {
|
||||
debugI_P(PSTR("Using timestamp from meter (DLMS)"));
|
||||
now = data->getPackageTimestamp();
|
||||
}
|
||||
if(now > BUILD_EPOCH) {
|
||||
if(now > FirmwareVersion::BuildEpoch) {
|
||||
timeval tv { now, 0};
|
||||
settimeofday(&tv, nullptr);
|
||||
}
|
||||
@@ -1143,7 +1142,7 @@ void handleDataSuccess(AmsData* data) {
|
||||
meterState.apply(*data);
|
||||
|
||||
bool saveData = false;
|
||||
if(!ds.isHappy() && now > BUILD_EPOCH) {
|
||||
if(!ds.isHappy() && now > FirmwareVersion::BuildEpoch) {
|
||||
debugD_P(PSTR("Its time to update data storage"));
|
||||
tmElements_t tm;
|
||||
breakTime(now, tm);
|
||||
@@ -1619,7 +1618,7 @@ void MQTT_connect() {
|
||||
|
||||
time_t epoch = time(nullptr);
|
||||
if(mqttConfig.ssl) {
|
||||
if(epoch < BUILD_EPOCH) {
|
||||
if(epoch < FirmwareVersion::BuildEpoch) {
|
||||
debugI_P(PSTR("NTP not ready for MQTT SSL"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
|
||||
#ifndef VERSION
|
||||
#define VERSION "538de5e"
|
||||
#endif
|
||||
#define BUILD_EPOCH 1668532199
|
||||
Reference in New Issue
Block a user