hello everyone,
In 1246 project function vAttemptToSleep (), when u16ActivityCount = = u8ValNumberOfNonSleepPreventingTimers will into the sleep state, I don't know where is this mLPMFlag assignment; I don't know when PWR_AllowDeviceToSleep and PWR_DisallowDeviceToSleep are called
When are these two functions called? I can't tell from the log print where it was called。
Hi, @Tome-mbedded
1.
extern uint8_t mLPMFlag;
is controlled by the Macro:
APP_LOW_POWER_API
K32W148EVK
Please check and make sure the first one is defined and the second one is not defined.
2.I did search in the V2008 JN-AN-1246 source code, but I didn't find these 2 functions.
Can you please let me know the file and file path of these 2 functions?
Can you please let me know where did you download the JN-AN-1246.zip?
Best regards,
Christine.
thanks for your reply.
I'm using the JN5189 chip.Below is the download link for the 1246sensor project. I downloaded it earlier, version 2007.
1、The mLPMFlag variable is defined in JN5189DK6
The PWR_DisallowDeviceToSleep and PWR_AllowDeviceToSleep functions are also defined in JN5189DK6.Here are their paths
JN5189DK6\middleware\wireless\framework\LowPower\Source\jn5189dk6\PWR.c
The APP LOW POWER API is defined in the makefile
2、I don't know when u16ActivityCount u8ValNumberOfNonSleepPreventingTimers equal, they are equal to to sleep. But my sensor codes, sometimes they're not equal, so they don't go to sleep. What's the reason?
Thanks for your reply.
There is another condition to enter sleep mode.
if ((u16ActivityCount == u8ValNumberOfNonSleepPreventingTimers) &&
(0 == u8ValNumberOfTimersTaskTimers))
When the both conditions meet, then can enter to sleep.
And you can also print more logs to see whether is equal.
Best regards,
Christine.
hello,
Sorry for the late reply
The second condition is set up (0 = = u8ValNumberOfTimersTaskTimers), but the first condition is not set up (
(u16ActivityCount == u8ValNumberOfNonSleepPreventingTimers))
Sometimes the Activity is equal to 1, it equals the u8ValNumberOfNonSleepPreventingTimers, it can sleep. What is the reason for this?
Hi, @Tome-mbedded
Are you sure it enters this if condition?
Can you please set bDbug to True or add some logs here to double confirm it enters this "if" condition?
if ((u16ActivityCount == u8ValNumberOfNonSleepPreventingTimers) &&
(0 == u8ValNumberOfTimersTaskTimers))
{
if (bDebug) DBG_vPrintf(TRACE_SLEEP_HANDLER, ", SLEEP YES");
Best regards,
Christine.
thank you,
Can't go to the if condition, because u16ActivityCount U8ValNumberOfNonSleepPreventingTimers is not equal. u16ActivityCount Where does the value of this variable come from? The routine u8ValNumberOfNonSleepPreventingTimers this value is 1 or 2, but print u16ActivityCount this value may be greater than 3. So it can't be equal u8ValNumberOfNonSleepPreventingTimers. So can't go into the if condition
Hi, @Tome-mbedded
u16ActivityCount Where does the value of this variable come from?
==> Please see below for the source of u16ActivityCount.
#ifdef APP_LOW_POWER_API
#ifndef K32W148EVK
u16ActivityCount = mLPMFlag;
#else
u16ActivityCount = PWRM_u16GetActivityCount();
#endif
#else
u16ActivityCount = PWRM_u16GetActivityCount();
#endif
So you need to check the MACRO: APP_LOW_POWER_API and K32W148EVK.
If you are not sure, you can add some wrong method, and try to compile to see whether have compile errors.
And for your information: PWRM_u16GetActivityCount() function is defined in our internal SDK. There is no source code available for us. We only provide this API, you can check docs/wireless/Zigbee/JN-UG-3133-Core-Utilities.pdf in your SDK directory to see explanation of this API.
And mLPMFlag is defined in the middleware/wireless/framework/LowPower/Source/jn5189dk6/PWR.c
uint8_t mLPMFlag = gAllowDeviceToSleep_c;
Then
middleware/wireless/framework/LowPower/Interface/jn5189dk6/PWR_Interface.h
#ifndef gAllowDeviceToSleep_c
#define gAllowDeviceToSleep_c 0
#endif
Best regards,
Christine.