ESP32.deepsleepExt0() "MJS: called non-calablle"

#1

Iam using JS. My goal is to force the ESP32 to deepsleep and wake up by ext interruption.
add in esp32_mjs.c:
void mgos_esp_deep_sleep_enable_ext0_wakeup_d(int gpio_num, int level) {
esp_deep_sleep_enable_ext0_wakeup(gpio_num, level);
esp_deep_sleep_start();
};

add in api_esp32.js:
deepSleepExt0: ffi('void mgos_esp_deep_sleep_enable_ext0_wakeup_d(int, int)'),

in init.js:
ESP32.deepSleepExt0(26,1);

The result I see is: MJS: called non-calablle

what is wrong?

#2

How did you add mgos_esp_deep_sleep_enable_ext0_wakeup_d in esp32_mjs.c?

It’s simpler to to add the function in src/main.c and ffi it in your init.js:

let deepSleepExt0 = ffi('void mgos_esp_deep_sleep_enable_ext0_wakeup_d(int, int)');

deepSleepExt0(26,1);