diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index 023b5fb..e21c32e 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -1,3 +1,4 @@ idf_component_register(SRCS "app_main.c" "network_mngr.c" + "gpio.c" INCLUDE_DIRS ".") diff --git a/src/main/app_main.c b/src/main/app_main.c index ec6d001..3bd5e5b 100644 --- a/src/main/app_main.c +++ b/src/main/app_main.c @@ -13,6 +13,9 @@ #include #include +#include "gpio.h" + + static const char *TAG = "app"; @@ -32,8 +35,8 @@ void deviceInit() { void app_main(void) { deviceInit(); - - networkInit(false); + gpioInit(); + networkInit(isGpioForceProv()); /* Start main application now */ diff --git a/src/main/gpio.c b/src/main/gpio.c new file mode 100644 index 0000000..03f1863 --- /dev/null +++ b/src/main/gpio.c @@ -0,0 +1,20 @@ +#include + +#include "gpio.h" + +#include + + + +void gpioInit() { + gpio_config_t io_conf; + io_conf.intr_type = GPIO_INTR_DISABLE; + io_conf.pin_bit_mask = (1ULL << GPIO_FORCE_PROV); + io_conf.mode = GPIO_MODE_INPUT; + io_conf.pull_up_en = 1; + gpio_config(&io_conf); +} + +bool isGpioForceProv() { + return 0 == gpio_get_level(GPIO_FORCE_PROV); +} \ No newline at end of file diff --git a/src/main/gpio.h b/src/main/gpio.h new file mode 100644 index 0000000..09b5800 --- /dev/null +++ b/src/main/gpio.h @@ -0,0 +1,13 @@ +#ifndef _GPIO_H_ +#define _GPIO_H_ + +#include + + +#define GPIO_FORCE_PROV 5 + + +void gpioInit(); +bool isGpioForceProv(); + +#endif // _GPIO_H_