Begin with fetching versions of downloaded json-files.

This commit is contained in:
Gerhard Hoffmann 2024-04-26 13:03:10 +02:00
parent 0d268a1d9d
commit 9ca394db46
2 changed files with 60 additions and 0 deletions

View File

@ -230,6 +230,64 @@ bool Update::doUpdate(QStringList const &filesToWorkOn) {
return res;
}
bool Update::checkDownloadedJsonVersions(QStringList const& jsonFileNames) {
for (QStringList::size_type i=0; i < jsonFileNames.size(); ++i) {
uint8_t jsonNr = 0;
QString const &fName = jsonFileNames[i];
if (fName.endsWith("conf.json")) {
jsonNr = 1;
} else
if (fName.endsWith("device.json")) {
jsonNr = 2;
} else
if (fName.endsWith("cash.json")) {
jsonNr = 3;
} else {
QRegularExpressionMatch match;
static const QRegularExpression re("^(.*print)([0-3][0-9])\\.json\\s*$");
int idx = fName.indexOf(re, 0, &match);
if (idx != -1) {
QString captured = match.captured(match.lastCapturedIndex());
bool ok = false;
int n = captured.toInt(&ok);
if (ok) {
jsonNr = n + 4;
}
}
}
if (jsonNr != 0) {
#if 0
m_hw->sys_requestJsonVersions(jsonNr);
QThread::msleep(500);
char buf[64];
memset(buf, 0x00, sizeof(buf));
m_hw->sys_getJsonVersions(jsonNr, buf);
buf[sizeof(buf)-1] = '\0';
QString const installedVersion(buf);
QString const fileVersion = getFileVersion(jsonFileNames[i]);
qCritical() << "installed version:" << installedVersion;
qCritical() << " file version:" << fileVersion;
if (installedVersion == fileVersion) {
}
#endif
} else {
qCritical() << "CANNOT FIND JSON-NR FOR" << fName;
}
}
return false;
}
bool Update::downloadJson(enum FileTypeJson type,
int templateIdx,
QString jsFileToSendToDC) const {

View File

@ -66,6 +66,8 @@ public:
bool downloadJson(enum FileTypeJson type, int templateIdx,
QString jsFileToSendToDC) const;
bool checkDownloadedJsonVersions(QStringList const& jsonFileNames);
/*
bool checkDownloadedJsonVersions(QStringList const& jsonFileNames);