Sleep - SystemSleepResult class

wakeupReason() (SystemSleepResult)

// PROTOTYPE
SystemSleepWakeupReason wakeupReason() const;

// EXAMPLE
SystemSleepConfiguration config;
config.mode(SystemSleepMode::STOP)
      .gpio(D2, FALLING)
      .duration(15min);
SystemSleepResult result = System.sleep(config);
if (result.wakeupReason() == SystemSleepWakeupReason::BY_GPIO) {
  // Waken by pin 
  pin_t whichPin = result.wakeupPin();
}

Returns the reason for wake. Constants include:

Constant Purpose
SystemSleepWakeupReason::UNKNOWN Unknown reason
SystemSleepWakeupReason::BY_GPIO GPIO pin
SystemSleepWakeupReason::BY_RTC Time-based
SystemSleepWakeupReason::BY_LPCOMP Analog value
SystemSleepWakeupReason::BY_USART Serial
SystemSleepWakeupReason::BY_CAN CAN bus
SystemSleepWakeupReason::BY_BLE BLE
SystemSleepWakeupReason::BY_NETWORK Network (cellular or Wi-Fi)