nn::applet::CTR::GetSleepNotificationState Function

Syntax

AppletSleepNotificationState GetSleepNotificationState(
     void
);

Arguments

None.

Return Values

Returns the state.

Description

Gets the sleep notification state.

This function may return the following values to the application.

ValueDescription
applet::NOTIFY_NONENormal Use
applet::NOTIFY_SLEEP_QUERYAfter SLEEP_QUERY notification (deferred).
applet::NOTIFY_SLEEP_ACCEPTAfter SLEEP_QUERY notification (accepted).
applet::NOTIFY_SLEEP_REJECTAfter SLEEP_QUERY notification (rejected).
applet::NOTIFY_SLEEP_ACCEPTEDAfter SLEEP confirmed.
applet::NOTIFY_AWAKEAfter AWAKE notification.

This function returns applet::NOTIFY_SLEEP_QUERY when the application's sleep query callback returned applet::REPLY_LATER.

In this case, the ReplySleepQuery function must immediately return either nn::applet::CTR::REPLY_ACCEPT or nn::applet::CTR::REPLY_REJECT.

This function returns applet::NOTIFY_SLEEP_ACCEPT when the query callback return value or the nn::applet::CTR:ReplySleepQuery return value is applet::REPLY_ACCEPT.

This function returns applet::NOTIFY_SLEEP_REJECT when the query callback return value or the nn::applet::CTR:ReplySleepQuery return value is applet::REPLY_REJECT.

This function returns applet::NOTIFY_SLEEP_ACCEPTED when all applications and applets reply "accept" to the sleep query and confirm sleep mode. However, in such cases, the system immediately transitions to sleep mode, so it is almost impossible to actually use this value in the application.

This function returns applet::NOTIFY_AWAKE after the system wakes up and the AWAKE callback is called.

This function returns applet::NOTIFY_NONE after a call to the nn::applet::CTR::ClearSleepNotificationState function.

This function is intended to be used to check if the application needs to reply to sleep queries using the main thread. The API also includes the inline nn::applet::CTR::IsExpectedToReplySleepQuery function for this purpose. That function simply checks whether the sleep notification state is NOTIFY_SLEEP_QUERY.

Example

  // Okay to write this way too:
  if ( applet::GetSleepNotificationState() == applet::NOTIFY_SLEEP_QUERY )
  {
     applet::ReplySleepQuery( applet::REPLY_ACCEPT );
     awakeEvent.Wait(); // Sleep
  }

  // Or write it this way:
  if ( applet::IsExpectedToReplySleepQuery() )
  {
     applet::ReplySleepQuery( applet::REPLY_ACCEPT );
     awakeEvent.Wait(); // Sleep
  }

Revision History

2010/12/22
Corrected mistakes.
2010/12/01
Added details about return values.
2010/11/10
Initial version.

CONFIDENTIAL