Temporary commit for X10 conversions fixes

This commit is contained in:
Bertrand Songis
2019-08-23 14:21:02 +02:00
parent 6794212ada
commit a9255e802a
12 changed files with 95 additions and 25 deletions
+26 -15
View File
@@ -101,16 +101,15 @@ const char * openFile(const char * fullpath, FIL * file, uint16_t * size, uint8_
return nullptr;
}
const char * loadFile(const char * fullpath, uint8_t * data, uint16_t maxsize)
const char * loadFile(const char * fullpath, uint8_t * data, uint16_t maxsize, uint8_t * version)
{
FIL file;
UINT read;
uint16_t size;
uint8_t version;
TRACE("loadFile(%s)", fullpath);
const char * err = openFile(fullpath, &file, &size, &version);
const char * err = openFile(fullpath, &file, &size, version);
if (err)
return err;
@@ -121,26 +120,24 @@ const char * loadFile(const char * fullpath, uint8_t * data, uint16_t maxsize)
return SDCARD_ERROR(result);
}
if (version < EEPROM_VER) {
convertModelData(version);
}
f_close(&file);
return nullptr;
}
const char * readModel(const char * filename, uint8_t * buffer, uint32_t size)
const char * readModel(const char * filename, uint8_t * buffer, uint32_t size, uint8_t * version)
{
char path[256];
getModelPath(path, filename);
return loadFile(path, buffer, size);
return loadFile(path, buffer, size, version);
}
const char * loadModel(const char * filename, bool alarms)
{
uint8_t version;
preModelLoad();
const char * error = readModel(filename, (uint8_t *)&g_model, sizeof(g_model));
const char * error = readModel(filename, (uint8_t *)&g_model, sizeof(g_model), &version);
if (error) {
TRACE("loadModel error=%s", error);
}
@@ -150,20 +147,34 @@ const char * loadModel(const char * filename, bool alarms)
storageCheck(true);
alarms = false;
}
else if (version < EEPROM_VER) {
convertModelData(version);
}
postModelLoad(alarms);
return error;
}
const char * loadRadioSettings()
const char * loadRadioSettings(const char * path)
{
const char * error = loadFile(RADIO_SETTINGS_PATH, (uint8_t *)&g_eeGeneral, sizeof(g_eeGeneral));
uint8_t version;
const char * error = loadFile(path, (uint8_t *)&g_eeGeneral, sizeof(g_eeGeneral), &version);
if (error) {
TRACE("loadRadioSettings error=%s", error);
return error;
}
return error;
if (version < EEPROM_VER) {
convertRadioData(version);
}
return nullptr;
}
const char * loadRadioSettings()
{
return loadRadioSettings(RADIO_SETTINGS_PATH);
}
const char * writeGeneralSettings()
@@ -174,7 +185,7 @@ const char * writeGeneralSettings()
void storageCheck(bool immediately)
{
if (storageDirtyMsk & EE_GENERAL) {
TRACE("eeprom write general");
TRACE("Storage write general");
storageDirtyMsk -= EE_GENERAL;
const char * error = writeGeneralSettings();
if (error) {
@@ -183,7 +194,7 @@ void storageCheck(bool immediately)
}
if (storageDirtyMsk & EE_MODEL) {
TRACE("eeprom write model");
TRACE("Storage write current model");
storageDirtyMsk -= EE_MODEL;
const char * error = writeModel();
if (error) {