Skip to content

Commit

Permalink
[NXP][platform][examples] Low power changes (#36389)
Browse files Browse the repository at this point in the history
* [nxp][examples][common] Add low-power app callbacks default implementation

 * Add AppMatter_(Allow/Disallow)DeviceToSleep default implementation
   in AppTaskBase.

Signed-off-by: Andrei Menzopol <[email protected]>

* [nxp][examples][common][contact-sensor-app] Remove low-power app callbacks

Signed-off-by: Andrei Menzopol <[email protected]>

* [nxp][platform][common][ble] Change CHIP_DEVICE_K32W1 define to NXP_DEVICE_K32W1_MCXW7X

Signed-off-by: Andrei Menzopol <[email protected]>

* Restyled by clang-format

---------

Signed-off-by: Andrei Menzopol <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
  • Loading branch information
2 people authored and pull[bot] committed Nov 7, 2024
1 parent 072b89f commit 3754660
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 23 deletions.
16 changes: 0 additions & 16 deletions examples/contact-sensor-app/nxp/common/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@

#include "AppTask.h"

#if CONFIG_LOW_POWER
#include "PWR_Interface.h"
#endif

#include <app-common/zap-generated/attributes/Accessors.h>
#include <platform/CHIPDeviceLayer.h>

Expand All @@ -36,18 +32,6 @@ void ContactSensorApp::AppTask::PreInitMatterStack()
ChipLogProgress(DeviceLayer, "Welcome to NXP Contact Sensor Demo App");
}

#if CONFIG_LOW_POWER
void ContactSensorApp::AppTask::AppMatter_DisallowDeviceToSleep()
{
PWR_DisallowDeviceToSleep();
}

void ContactSensorApp::AppTask::AppMatter_AllowDeviceToSleep()
{
PWR_AllowDeviceToSleep();
}
#endif

ContactSensorApp::AppTask & ContactSensorApp::AppTask::GetDefaultInstance()
{
static ContactSensorApp::AppTask sAppTask;
Expand Down
4 changes: 0 additions & 4 deletions examples/contact-sensor-app/nxp/common/include/AppTask.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@ class AppTask : public chip::NXP::App::AppTaskFreeRTOS

// AppTaskFreeRTOS virtual methods
void PreInitMatterStack() override;
#if CONFIG_LOW_POWER
void AppMatter_DisallowDeviceToSleep() override;
void AppMatter_AllowDeviceToSleep() override;
#endif

// This returns an instance of this class.
static AppTask & GetDefaultInstance();
Expand Down
4 changes: 2 additions & 2 deletions examples/platform/nxp/common/app_task/include/AppTaskBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ class AppTaskBase
* This function can be overridden in order to implement a specific disallow mechanism.
*
*/
virtual void AppMatter_DisallowDeviceToSleep(void) {}
virtual void AppMatter_DisallowDeviceToSleep(void);

/**
* \brief Allow entering low power mode.
*
* This function can be overridden in order to implement a specific allow mechanism.
*
*/
virtual void AppMatter_AllowDeviceToSleep(void) {}
virtual void AppMatter_AllowDeviceToSleep(void);

/**
* \brief Print onboarding information.
Expand Down
15 changes: 15 additions & 0 deletions examples/platform/nxp/common/app_task/source/AppTaskBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@

#if CONFIG_LOW_POWER
#include "LowPower.h"
#include "PWR_Interface.h"
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_OTA_REQUESTOR
Expand Down Expand Up @@ -431,6 +432,20 @@ void chip::NXP::App::AppTaskBase::FactoryResetHandler(void)
chip::Server::GetInstance().ScheduleFactoryReset();
}

void chip::NXP::App::AppTaskBase::AppMatter_DisallowDeviceToSleep(void)
{
#if CONFIG_LOW_POWER
PWR_DisallowDeviceToSleep();
#endif
}

void chip::NXP::App::AppTaskBase::AppMatter_AllowDeviceToSleep(void)
{
#if CONFIG_LOW_POWER
PWR_AllowDeviceToSleep();
#endif
}

void chip::NXP::App::AppTaskBase::PrintOnboardingInfo()
{
#if CONFIG_NETWORK_LAYER_BLE
Expand Down
2 changes: 1 addition & 1 deletion src/platform/nxp/common/ble/BLEManagerCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ void BLEManagerCommon::blekw_gap_connection_cb(deviceId_t deviceId, gapConnectio

if (pConnectionEvent->eventType == gConnEvtConnected_c)
{
#if CHIP_DEVICE_K32W1
#if NXP_DEVICE_K32W1_MCXW7X
#if defined(nxp_use_low_power) && (nxp_use_low_power == 1)
/* Disallow must be called here for K32W1, otherwise an assert will be reached.
* Disclaimer: this is a workaround until a better cross platform solution is found. */
Expand Down

0 comments on commit 3754660

Please sign in to comment.