1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-25 17:25:13 +03:00

Bsongis/access registration id reinit when zero (#6700)

ACCESS registration ID reinitialized when zero (coming from Companion)
Fix incorrect module settings on model load
This commit is contained in:
Bertrand Songis 2019-09-02 17:04:25 +02:00 committed by GitHub
parent 0fe2b8918b
commit 02d07c4d2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 29 additions and 19 deletions

View file

@ -27,7 +27,6 @@
void eeLoadModel(uint8_t index)
{
if (index < MAX_MODELS) {
preModelLoad();
uint16_t size = eeLoadModelData(index);
@ -111,6 +110,8 @@ bool storageReadRadioSettings(bool allowFixes)
}
}
postRadioSettingsLoad();
return true;
}

View file

@ -169,6 +169,8 @@ const char * loadRadioSettings(const char * path)
convertRadioData(version);
}
postRadioSettingsLoad();
return nullptr;
}

View file

@ -49,7 +49,7 @@ void storageReadAll();
void storageDirty(uint8_t msk);
void storageCheck(bool immediately);
void storageFlushCurrentModel();
void postRadioSettingsLoad();
void preModelLoad();
void postModelLoad(bool alarms);

View file

@ -53,20 +53,34 @@ void preModelLoad()
pauseMixerCalculations();
}
#if defined(PCBTARANIS) || defined(PCBHORUS)
static void fixUpModel()
void postRadioSettingsLoad()
{
// Ensure that when rfProtocol is MODULE_SUBTYPE_PXX1_OFF the type of the module is MODULE_TYPE_NONE
if (g_model.moduleData[INTERNAL_MODULE].type == MODULE_TYPE_XJT_PXX1 && g_model.moduleData[INTERNAL_MODULE].rfProtocol == MODULE_SUBTYPE_PXX1_OFF)
g_model.moduleData[INTERNAL_MODULE].type = MODULE_TYPE_NONE;
}
#if defined(PXX2)
if (is_memclear(g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID)) {
setDefaultOwnerId();
}
#endif
}
void postModelLoad(bool alarms)
{
#if defined(PCBTARANIS) || defined(PCBHORUS)
fixUpModel();
#if defined(PXX2)
if (is_memclear(g_model.modelRegistrationID, PXX2_LEN_REGISTRATION_ID)) {
memcpy(g_model.modelRegistrationID, g_eeGeneral.ownerRegistrationID, PXX2_LEN_REGISTRATION_ID);
}
#endif
#if defined(HARDWARE_INTERNAL_MODULE)
if (!isInternalModuleAvailable(g_model.moduleData[INTERNAL_MODULE].type)) {
memclear(&g_model.moduleData[INTERNAL_MODULE], sizeof(ModuleData));
}
#endif
if (!isExternalModuleAvailable(g_model.moduleData[EXTERNAL_MODULE].type)) {
memclear(&g_model.moduleData[EXTERNAL_MODULE], sizeof(ModuleData));
}
AUDIO_FLUSH();
flightReset(false);