Tool/software:
Hi,
I'm testing the shutdown mode using zed_sw samples. What I want to do is that when the switch lost parent for more than 10 seconds, it will switch to shutdown mode and can be wake up by BTN-1 (DIO15).
I configured the LED_GREEN that will blink when try to rejoin network, and LED_RED on when the first rejoin request has been sent.
#if ZG_BUILD_ENDDEVICE_TYPE
case BDB_COMMISSIONING_PARENT_LOST:
if(bdbCommissioningModeMsg->bdbCommissioningStatus == BDB_COMMISSIONING_NETWORK_RESTORED)
{
//We did recover from losing parent
if (UtilTimer_isActive(&EndDeviceShutdownClkStruct))
{
UtilTimer_stop(&EndDeviceShutdownClkStruct);
}
LED_setOff(gGreenLedHandle);
LED_setOff(gRedLedHandle);
}
else
{
//Parent not found, attempt to rejoin again after a fixed delay
LED_toggle(gGreenLedHandle);
UtilTimer_setTimeout( EndDeviceRejoinClkHandle, SAMPLEAPP_END_DEVICE_REJOIN_DELAY );
UtilTimer_start(&EndDeviceRejoinClkStruct);
if (!UtilTimer_isActive(&EndDeviceShutdownClkStruct))
{
LED_setOn(gRedLedHandle, 100);
UtilTimer_setTimeout(EndDeviceShutdownClkHandle, SAMPLEAPP_END_DEVICE_SHUTDOWN_DELAY);
UtilTimer_start(&EndDeviceShutdownClkStruct);
}
}
break;
#endif
The code to handle shutdown.
if ( appServiceTaskEvents & SAMPLEAPP_END_DEVICE_SHUTDOWN_EVT )
{
if (UtilTimer_isActive(&EndDeviceRejoinClkStruct))
{
UtilTimer_stop(&EndDeviceRejoinClkStruct);
}
if (UtilTimer_isActive(&EndDeviceShutdownClkStruct))
{
UtilTimer_stop(&EndDeviceShutdownClkStruct);
}
LED_setOff(gRedLedHandle);
LED_setOff(gGreenLedHandle);
IOCIOShutdownSet(CONFIG_GPIO_BTN_LEFT_INPUT, IOC_WAKE_ON_LOW);
PowerCC26X2_sysctrlShutdownWithAbort();
appServiceTaskEvents &= ~SAMPLEAPP_END_DEVICE_SHUTDOWN_EVT;
}
So far, the switch can go to shutdown mode successfully after 10 seconds of parent lost and able to wake-up by pressing BTN-1. But after waking-up (still parent lost), it tries to rejoin network forever (checked by PPK2), I dont see LED_GREEN blinks
This LED_GREEN is configured and setOn in function static void zclSampleSw_initialization(void). So I think it should be ON after waking-up from shutdown mode.
static void zclSampleSw_initialization(void)
{
...
LED_Params ledParams;
LED_Params_init(&ledParams);
gGreenLedHandle = LED_open(CONFIG_LED_GREEN, &ledParams);
gRedLedHandle = LED_open(CONFIG_LED_RED, &ledParams);
LED_setOn(gGreenLedHandle, LED_BRIGHTNESS_MAX);
LED_setOff(gRedLedHandle);
...
}
Does MCU starts at main code after wakeing-up from shutdown mode? If not, where the code it starts to run. Can you provide correct method to manually put device in shutdown mode?