Skip to content

Commit

Permalink
samples: matter: set External Flash to sleep at init
Browse files Browse the repository at this point in the history
set External Flash to sleep always during initialization.
This ensures that if External Flash is available, it will be
put into deep sleep mode and consume less energy.

Additionaly align with `ExternalFlashManager` refactor.

Signed-off-by: Maciej Baczmanski <[email protected]>
  • Loading branch information
maciejbaczmanski authored and rlubos committed Sep 13, 2024
1 parent 4be89a0 commit d23d847
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 19 deletions.
4 changes: 4 additions & 0 deletions samples/matter/common/src/app/matter_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
#include <app/clusters/network-commissioning/network-commissioning.h>
#include <app/server/OnboardingCodesUtil.h>
#include <credentials/examples/DeviceAttestationCredsExample.h>
#include <platform/nrfconnect/ExternalFlashManager.h>

LOG_MODULE_DECLARE(app, CONFIG_CHIP_APP_LOG_LEVEL);

Expand Down Expand Up @@ -225,6 +226,9 @@ void DoInitChipServer(intptr_t /* unused */)
Nrf::GetDFUOverSMP().ConfirmNewImage();
#endif

/* Set External Flash into sleep mode */
ExternalFlashManager::GetInstance().DoAction(ExternalFlashManager::Action::SLEEP);

/* Initialize CHIP server */
#ifdef CONFIG_CHIP_FACTORY_DATA
if (sLocalInitData.mFactoryDataProvider) {
Expand Down
9 changes: 1 addition & 8 deletions samples/matter/common/src/dfu/ota/ota_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ namespace Nrf::Matter
OTAImageProcessorImpl &GetOTAImageProcessor()
{
#if CONFIG_PM_DEVICE && CONFIG_NORDIC_QSPI_NOR
static OTAImageProcessorBaseImpl sOTAImageProcessor(&GetFlashHandler());
static OTAImageProcessorBaseImpl sOTAImageProcessor(&ExternalFlashManager::GetInstance());
#else
static OTAImageProcessorBaseImpl sOTAImageProcessor;
#endif
Expand All @@ -57,7 +57,6 @@ void InitBasicOTARequestor()
sOTARequestor.Init(Server::GetInstance(), sOTARequestorStorage, sOTARequestorDriver, sBDXDownloader);
chip::SetRequestorInstance(&sOTARequestor);
sOTARequestorDriver.Init(&sOTARequestor, &imageProcessor);
imageProcessor.TriggerFlashAction(ExternalFlashManager::Action::SLEEP);
}

void OtaConfirmNewImage()
Expand Down Expand Up @@ -87,10 +86,4 @@ void OtaConfirmNewImage()

#endif

ExternalFlashManager &GetFlashHandler()
{
static ExternalFlashManager sFlashHandler;
return sFlashHandler;
}

} /* namespace Nrf::Matter */
8 changes: 0 additions & 8 deletions samples/matter/common/src/dfu/ota/ota_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,4 @@ void OtaConfirmNewImage();

#endif /* CONFIG_CHIP_OTA_REQUESTOR */

/**
* Get FlashHandler static instance.
*
* Returned object can be used to control the QSPI external flash,
* which can be introduced into sleep mode and woken up on demand.
*/
chip::DeviceLayer::ExternalFlashManager &GetFlashHandler();

} /* namespace Nrf::Matter */
4 changes: 2 additions & 2 deletions samples/matter/common/src/dfu/smp/dfu_over_smp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ enum mgmt_cb_return CommandHandler(uint32_t event, enum mgmt_cb_return, int32_t
bool *, void *, size_t)
{
if (event == MGMT_EVT_OP_CMD_RECV) {
Nrf::Matter::GetFlashHandler().DoAction(ExternalFlashManager::Action::WAKE_UP);
ExternalFlashManager::GetInstance().DoAction(ExternalFlashManager::Action::WAKE_UP);
} else if (event == MGMT_EVT_OP_CMD_DONE) {
Nrf::Matter::GetFlashHandler().DoAction(ExternalFlashManager::Action::SLEEP);
ExternalFlashManager::GetInstance().DoAction(ExternalFlashManager::Action::SLEEP);
}

return MGMT_CB_OK;
Expand Down
2 changes: 1 addition & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ manifest:
- name: matter
repo-path: sdk-connectedhomeip
path: modules/lib/matter
revision: acb371d0899282622dd6ff0252b48409201bd85a
revision: be30c50987d7bf02815b376785fc6f6256fabc67
west-commands: scripts/west/west-commands.yml
submodules:
- name: nlio
Expand Down

0 comments on commit d23d847

Please sign in to comment.