Skip to content

Commit

Permalink
Wrap the panic handler to disable the gdo uart pins and prevent door …
Browse files Browse the repository at this point in the history
…openings.
  • Loading branch information
h2zero authored and heythisisnate committed Jul 20, 2024
1 parent f8af4c7 commit d03fd8d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 19 additions & 1 deletion components/secplus_gdo/secplus_gdo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,22 @@ namespace secplus_gdo {
}

} // namespace secplus_gdo
} // namespace esphome
} // namespace esphome

// Need to wrap the panic handler to disable the GDO TX pin and pull the output high to
// prevent spuriously triggering the GDO to open when the ESP32 panics.
extern "C" {
#include "hal/gpio_hal.h"

void __real_esp_panic_handler(void*);

void __wrap_esp_panic_handler(void* info) {
esp_rom_printf("PANIC: DISABLING GDO UART TX PIN!\n");
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[(gpio_num_t)GDO_UART_TX_PIN], PIN_FUNC_GPIO);
gpio_set_direction((gpio_num_t)GDO_UART_TX_PIN, GPIO_MODE_INPUT);
gpio_pulldown_en((gpio_num_t)GDO_UART_TX_PIN);

// Call the original panic handler
__real_esp_panic_handler(info);
}
} //extern "C"
3 changes: 2 additions & 1 deletion garage-door-GDOv2-Q.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,5 @@ esphome:
lib_deps:
- https://github.com/konnected-io/gdolib#76ba232
build_flags:
- -DUART_SCLK_DEFAULT=UART_SCLK_APB
- -DUART_SCLK_DEFAULT=UART_SCLK_APB
- -Wl,--wrap=esp_panic_handler

0 comments on commit d03fd8d

Please sign in to comment.