OTA update continued

This commit is contained in:
Bertrand Songis
2019-04-24 17:23:28 +02:00
parent 1cd8c93455
commit bae1131a1b
6 changed files with 85 additions and 21 deletions
+3 -3
View File
@@ -292,7 +292,7 @@ void onPXX2R9MBindModeMenu(const char * result)
reusableBuffer.moduleSetup.bindInformation.step = BIND_OK;
POPUP_INFORMATION(STR_BIND_OK);
#else
reusableBuffer.moduleSetup.bindInformation.step = BIND_OPTIONS_SELECTED;
reusableBuffer.moduleSetup.bindInformation.step = BIND_START;
#endif
}
@@ -323,7 +323,7 @@ void onPXX2BindMenu(const char * result)
reusableBuffer.moduleSetup.bindInformation.step = BIND_OK;
POPUP_INFORMATION(STR_BIND_OK);
#else
reusableBuffer.moduleSetup.bindInformation.step = BIND_OPTIONS_SELECTED;
reusableBuffer.moduleSetup.bindInformation.step = BIND_START;
#endif
}
}
@@ -1419,7 +1419,7 @@ void menuModelSetup(event_t event)
}
if (moduleState[moduleIdx].mode == MODULE_MODE_BIND) {
if (reusableBuffer.moduleSetup.bindInformation.step == BIND_START && reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount > 0) {
if (reusableBuffer.moduleSetup.bindInformation.step == BIND_INIT && reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount > 0) {
popupMenuItemsCount = min<uint8_t>(reusableBuffer.moduleSetup.bindInformation.candidateReceiversCount, PXX2_MAX_RECEIVERS_PER_MODULE);
for (uint8_t i=0; i<popupMenuItemsCount; i++) {
popupMenuItems[i] = reusableBuffer.moduleSetup.bindInformation.candidateReceiversNames[i];
@@ -87,6 +87,24 @@ void onSdFormatConfirm(const char * result)
}
}
void onUpdateConfirmation(const char * result)
{
if (result == STR_OK) {
// TODO OTA Update
}
else {
moduleState[EXTERNAL_MODULE].mode = MODULE_MODE_NORMAL;
}
}
void onBindStateChanged()
{
if (reusableBuffer.sdManager.otaInformation.step == BIND_INFO_REQUEST) {
POPUP_CONFIRMATION(PXX2receiversModels[reusableBuffer.sdManager.otaInformation.receiverInformation.modelID], onUpdateConfirmation);
// SET_WARNING_INFO(STR_MODEL_STILL_POWERED, sizeof(TR_MODEL_STILL_POWERED), 0);
}
}
void onSdManagerMenu(const char * result)
{
TCHAR lfn[_MAX_LFN+1];
@@ -176,8 +194,7 @@ void onSdManagerMenu(const char * result)
}
else if (result == STR_FLASH_RECEIVER_OTA) {
getSelectionFullPath(lfn);
moduleState[EXTERNAL_MODULE].startBind(&reusableBuffer.sdManager.otaInformation);
moduleState[EXTERNAL_MODULE].startBind(&reusableBuffer.sdManager.otaInformation, onBindStateChanged);
}
#endif
#if defined(LUA)
@@ -188,6 +205,22 @@ void onSdManagerMenu(const char * result)
#endif
}
void onUpdateReceiverSelection(const char * result)
{
if (result != STR_EXIT) {
reusableBuffer.sdManager.otaInformation.selectedReceiverIndex = (result - reusableBuffer.sdManager.otaInformation.candidateReceiversNames[0]) / sizeof(reusableBuffer.sdManager.otaInformation.candidateReceiversNames[0]);
reusableBuffer.sdManager.otaInformation.step = BIND_INFO_REQUEST;
#if defined(SIMU)
reusableBuffer.sdManager.otaInformation.receiverInformation.modelID = 0x01;
onBindStateChanged();
#endif
}
else {
// the user pressed [Exit]
moduleState[EXTERNAL_MODULE].mode = MODULE_MODE_NORMAL;
}
}
void menuRadioSdManager(event_t _event)
{
#if LCD_DEPTH > 1
@@ -434,6 +467,17 @@ void menuRadioSdManager(event_t _event)
}
}
if (moduleState[EXTERNAL_MODULE].mode == MODULE_MODE_BIND) {
if (reusableBuffer.sdManager.otaInformation.step == BIND_INIT && reusableBuffer.sdManager.otaInformation.candidateReceiversCount > 0) {
popupMenuItemsCount = min<uint8_t>(reusableBuffer.sdManager.otaInformation.candidateReceiversCount, PXX2_MAX_RECEIVERS_PER_MODULE);
for (uint8_t i=0; i<popupMenuItemsCount; i++) {
popupMenuItems[i] = reusableBuffer.sdManager.otaInformation.candidateReceiversNames[i];
}
popupMenuTitle = STR_PXX2_SELECT_RX;
POPUP_MENU_START(onUpdateReceiverSelection);
}
}
#if LCD_DEPTH > 1
const char * ext = getFileExtension(reusableBuffer.sdManager.lines[index]);
if (ext && isExtensionMatching(ext, BITMAPS_EXT)) {