Skip to content

Add function getWakeupCause for ESP32 #2359

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions targets/esp32/jswrap_esp32.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,29 @@ void jswrap_ESP32_deepSleep_ext0(Pin pin, int level) {
esp_deep_sleep_start(); // This function does not return.
} // End of jswrap_ESP32_deepSleep_ext0

/*JSON{
"type" : "staticmethod",
"class" : "ESP32",
"ifdef" : "ESP32",
"name" : "getWakeupCause",
"generate" : "jswrap_ESP32_getWakeupCause",
"return" : ["int", "The cause of the ESP32's wakeup from sleep"]
}
Returns a variable identifying the cause of wakeup from deep sleep.
Possible causes include:

* `0: ESP_SLEEP_WAKEUP_UNDEFINED` - reset was not caused by exit from deep sleep
* `2: ESP_SLEEP_WAKEUP_EXT0` - Wakeup caused by external signal using RTC_IO
* `3: ESP_SLEEP_WAKEUP_EXT1` - Wakeup caused by external signal using RTC_CNTL
* `4: ESP_SLEEP_WAKEUP_TIMER` - Wakeup caused by timer
* `5: ESP_SLEEP_WAKEUP_TOUCHPAD` - Wakeup caused by touchpad
* `6: ESP_SLEEP_WAKEUP_ULP` - Wakeup caused by ULP program

*/
int jswrap_ESP32_getWakeupCause() {
return esp_sleep_get_wakeup_cause();
} // End of jswrap_ESP32_getWakeupCause


/*JSON{
"type" : "staticmethod",
Expand Down
1 change: 1 addition & 0 deletions targets/esp32/jswrap_esp32.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ JsVar *jswrap_ESP32_setBoot(JsVar *jsPartitionName);
void jswrap_ESP32_reboot();
void jswrap_ESP32_deepSleep(int us);
void jswrap_ESP32_deepSleep_ext0(Pin pin,int level);
int jswrap_ESP32_getWakeupCause();
void jswrap_ESP32_setAtten(Pin pin,int atten);

#ifdef BLUETOOTH
Expand Down