Skip to main content
Senior
October 9, 2024
Question

How to put Matter Device into Sleep Mode

  • October 9, 2024
  • 5 replies
  • 3610 views

We are developing a Matter device using X-CUBE-MATTER.
When we set CFG_FULL_LOW_POWER to 1 to enable sleep mode, pressing B1 for 10 seconds does not enter Factory Reset and BLE advertising is not executed.
When we checked the current consumption, it seems to be in sleep mode, but because BLE advertising is not executed, commissioning is not possible.
Please tell me the solution or the specification.
The development environment is described below.
Hardware: STM32WB5MMG-DK
Firmware: Window-App-SBSFU
X-CUBE-MATTER Version: 1.1
Implementation CFG_FULL_LOW_POWER is set to 1

5 replies

EPASZ.1
ST Employee
October 9, 2024

Hello,

in app_conf.h where you are setting CFG_FULL_LOW_POWER 1, there is also this code below.

2024-10-09 09_22_57-app_conf.h - STM32CubeExpansion_MATTER_V1.1.0 - Visual Studio Code.png

Which means that buttons are not used at all. You can simply change this define to enable them.

AkihiroNAuthor
Senior
October 10, 2024

Thank you very much.
So, if the buttons are not available when CFG_FULL_LOW_POWER is enabled, how does Factory do it? Also, how is Advertising done?

EPASZ.1
ST Employee
October 11, 2024

As I said above you can change the above defines so that the buttons are active with low power. Then after rebuilding, you can use button1 to do factory reset and advertise.

With the default settings, factory reset cannot be done in low power mode.

 

AkihiroNAuthor
Senior
October 12, 2024

Thank you.
I understand.
However, I still cannot commission Window-App-SBSFU.
Is it only possible to use Sleep Mode with Generic-Switch-App?

AkihiroNAuthor
Senior
November 5, 2024

I noticed one thing: even in the xxx-App-SBSFU project, if you comment out UTIL_LPM_SetStopMode(1 << CFG_LPM_APP_THREAD, UTIL_LPM_ENABLE);, you can confirm that commissioning is possible with CFG_FULL_LOW_POWER = 1. However, I think this does not put it into Sleep Mode. Please provide a solution.

EPASZ.1
ST Employee
November 6, 2024

It is possible that in low power modes, the device is not communication fast enough with the OTBR to do the commissioning.

In such case, you can disable the LP modes by commenting out the UTIL_LPM command in app_entry and then enable them again inside AppTask::Init() (if the device is already commissioned on boot)EPASZ1_0-1730880532395.png

+ inside AppTask::MatterEventHandler (when the commissioning is finished)

EPASZ1_1-1730880636153.png

You could go a step further by enabling it at the start and disabling it on BLE connection (that's the start of commissioning) but that's up to you.

AkihiroNAuthor
Senior
November 6, 2024

Thank you for your reply.
If I want to implement it as follows, how should I modify it?

Condition 1: If commissioning has not been performed
When the device starts up, disable Sleep Mode and execute Advertising
When the Advertising time is over, enable Sleep Mode
If commissioning is performed and the connection is successful, enable Sleep Mode

Condition 2: If commissioning has been performed
When the device starts up, enable Sleep Mode

AkihiroNAuthor
Senior
November 6, 2024

Also, isn't the ICD Management Cluster essential for putting the Matter device into Sleep Mode?

EPASZ.1
ST Employee
November 6, 2024

Most is covered by what I wrote in my previous post. To enable LP modes after BLE advertising is over, you need to copy/replace the 3 attached files and then register some callbacks in AppTask::Init()

APP_MATTER_BLE_Set_Advertising_Callback((BLEFastAdvertisingCallback) BleAdvFastHandle, (BLESlowAdvertisingCallback) BleAdvSlowHandle, (BLEStopAdvertisingCallback) BleAdvStopHandle);
Define BleAdvStopHandle callback so that it enable the LP mode like above.
No, ICD cluster only lets the controller know that the device uses LP modes. This is defined inside CHIPProjectConfig.h. Default values are used, but it generally works well because Run/LP modes are managed by FreeRTOS.
AkihiroNAuthor
Senior
November 6, 2024

Thank you for your help.
Is it necessary to comment out (not enable) UTIL_LPM_SetStopMode(1 << CFG_LPM_APP_THREAD, UTIL_LPM_ENABLE); in app_thread.c (not enable here) and add (enable) UTIL_LPM_SetStopMode(1 << CFG_LPM_APP_THREAD, UTIL_LPM_ENABLE); in AppTask .cpp, is it necessary to add (enable) UTIL_LPM_SetStopMode(1 << CFG_LPM_APP_THREAD, UTIL_LPM_ENABLE); when kCommissioningComplete is executed?

EPASZ.1
ST Employee
November 6, 2024

In app_thread.c, you shouldn't modify anything. This handles the LP modes for the stack point of view.

In AppTask, yes you need to enable it under kCommissioningComplete - it is part of my previous post.

AkihiroNAuthor
Senior
November 7, 2024

Thank you for your help.

I have implemented the changes you shared.

I tried commissioning on the Apple platform, but it failed. It seems that the network is participating (up to kCommissioningComplete), but if you put CFG_LPM_APP in stop mode or sleep mode when setting the HomeApp side afterwards, the connection will fail.

As a test, you can comment out UTIL_LPM_SetOffMode(1U << CFG_LPM_APP, UTIL_LPM_ENABLE) and UTIL_LPM_SetStopMode(1U << CFG_LPM_APP, UTIL_LPM_ENABLE) in case DeviceEventType::kCommissioningComplete: to successfully complete the commissioning process.

You may also need to enable Sleep Mode or Stop Mode at a later time. Please tell me how to do this.

 

Also, I have one question. In the Generic Switch App, Sleep Mode is enabled simply by enabling CFG_FULL_LOW_POWER without implementing anything like this, and commissioning is successful. Is there any connection to the fact that SBSFU is implemented?

AkihiroNAuthor
Senior
December 2, 2024

How should I implement it so that it can go into sleep mode after reset?

I turned the power off and then on again, but it didn't go into Sleep Mode.