Skip to content

Commit

Permalink
[Telink] Fix NotifyUpdateApplied issue TC-SU-2.6 (#29435)
Browse files Browse the repository at this point in the history
* [Telink] Fix NotifyUpdateApplied issue TC-SU-2.6

* Restyled by clang-format

---------

Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
2 people authored and pull[bot] committed Jan 15, 2024
1 parent 5867357 commit 7f913e7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
25 changes: 25 additions & 0 deletions examples/platform/telink/common/src/AppTaskCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
#include "OTAUtil.h"
#endif

#ifdef CONFIG_BOOTLOADER_MCUBOOT
#include <app/clusters/ota-requestor/OTARequestorInterface.h>
#include <zephyr/dfu/mcuboot.h>
#endif /* CONFIG_BOOTLOADER_MCUBOOT */

#include <zephyr/fs/nvs.h>
#include <zephyr/settings/settings.h>

Expand Down Expand Up @@ -311,6 +316,26 @@ CHIP_ERROR AppTaskCommon::InitCommonParts(void)
InitBasicOTARequestor();
#endif

#ifdef CONFIG_BOOTLOADER_MCUBOOT
#if CONFIG_CHIP_OTA_REQUESTOR
if (GetRequestorInstance()->GetCurrentUpdateState() == Clusters::OtaSoftwareUpdateRequestor::OTAUpdateStateEnum::kIdle &&
mcuboot_swap_type() == BOOT_SWAP_TYPE_REVERT)
#else
if (mcuboot_swap_type() == BOOT_SWAP_TYPE_REVERT)
#endif
{
int img_confirmation = boot_write_img_confirmed();
if (img_confirmation)
{
LOG_ERR("Image not confirmed %d. Will be reverted!", img_confirmation);
}
else
{
LOG_INF("Image confirmed");
}
}
#endif /* CONFIG_BOOTLOADER_MCUBOOT */

ConfigurationMgr().LogDeviceConfig();
PrintOnboardingCodes(chip::RendezvousInformationFlags(chip::RendezvousInformationFlag::kBLE));

Expand Down
19 changes: 0 additions & 19 deletions examples/platform/telink/common/src/mainCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
#include "Rpc.h"
#endif

#ifdef CONFIG_BOOTLOADER_MCUBOOT
#include <zephyr/dfu/mcuboot.h>
#endif /* CONFIG_BOOTLOADER_MCUBOOT */

LOG_MODULE_REGISTER(app, CONFIG_CHIP_APP_LOG_LEVEL);

using namespace ::chip;
Expand Down Expand Up @@ -157,21 +153,6 @@ int main(void)
goto exit;
}

#ifdef CONFIG_BOOTLOADER_MCUBOOT
if (mcuboot_swap_type() == BOOT_SWAP_TYPE_REVERT)
{
int img_confirmation = boot_write_img_confirmed();
if (img_confirmation)
{
LOG_ERR("Image not confirmed %d. Will be reverted!", img_confirmation);
}
else
{
LOG_INF("Image confirmed");
}
}
#endif /* CONFIG_BOOTLOADER_MCUBOOT */

err = GetAppTask().StartApp();

exit:
Expand Down

0 comments on commit 7f913e7

Please sign in to comment.