From e71c7e7689d715f3ea018818faa25fa365be580d Mon Sep 17 00:00:00 2001 From: Adrian Scillato <35405447+ascillato@users.noreply.github.com> Date: Sat, 7 Apr 2018 21:27:50 -0300 Subject: [PATCH] Update esp-knx-ip.cpp --- lib/esp-knx-ip-async-udp/esp-knx-ip.cpp | 86 +++++++++++++------------ 1 file changed, 44 insertions(+), 42 deletions(-) diff --git a/lib/esp-knx-ip-async-udp/esp-knx-ip.cpp b/lib/esp-knx-ip-async-udp/esp-knx-ip.cpp index 7a6cd299f..e5b4cc03a 100644 --- a/lib/esp-knx-ip-async-udp/esp-knx-ip.cpp +++ b/lib/esp-knx-ip-async-udp/esp-knx-ip.cpp @@ -27,61 +27,63 @@ void ESPKNXIP::load() restore_from_eeprom(); } -void ESPKNXIP::start(ESP8266WebServer *srv) +void ESPKNXIP::start(ESP8266WebServer *srv, bool espknxip_webpage) { server = srv; + if (espknxip_webpage) { __start_espknxip_webpage(); } __start(); } void ESPKNXIP::start() { server = new ESP8266WebServer(80); + __start_espknxip_webpage(); __start(); } +void ESPKNXIP::__start_espknxip_webpage() +{ + server->on(ROOT_PREFIX, [this](){ + __handle_root(); + }); + server->on(__ROOT_PATH, [this](){ + __handle_root(); + }); + server->on(__REGISTER_PATH, [this](){ + __handle_register(); + }); + server->on(__DELETE_PATH, [this](){ + __handle_delete(); + }); + server->on(__PHYS_PATH, [this](){ + __handle_set(); + }); +#if !DISABLE_EEPROM_BUTTONS + server->on(__EEPROM_PATH, [this](){ + __handle_eeprom(); + }); +#endif + server->on(__CONFIG_PATH, [this](){ + __handle_config(); + }); + server->on(__FEEDBACK_PATH, [this](){ + __handle_feedback(); + }); +#if !DISABLE_RESTORE_BUTTON + server->on(__RESTORE_PATH, [this](){ + __handle_restore(); + }); +#endif +#if !DISABLE_REBOOT_BUTTON + server->on(__REBOOT_PATH, [this](){ + __handle_reboot(); + }); +#endif + server->begin(); +} + void ESPKNXIP::__start() { - if (server != nullptr) - { - server->on(ROOT_PREFIX, [this](){ - __handle_root(); - }); - server->on(__ROOT_PATH, [this](){ - __handle_root(); - }); - server->on(__REGISTER_PATH, [this](){ - __handle_register(); - }); - server->on(__DELETE_PATH, [this](){ - __handle_delete(); - }); - server->on(__PHYS_PATH, [this](){ - __handle_set(); - }); -#if !DISABLE_EEPROM_BUTTONS - server->on(__EEPROM_PATH, [this](){ - __handle_eeprom(); - }); -#endif - server->on(__CONFIG_PATH, [this](){ - __handle_config(); - }); - server->on(__FEEDBACK_PATH, [this](){ - __handle_feedback(); - }); -#if !DISABLE_RESTORE_BUTTON - server->on(__RESTORE_PATH, [this](){ - __handle_restore(); - }); -#endif -#if !DISABLE_REBOOT_BUTTON - server->on(__REBOOT_PATH, [this](){ - __handle_reboot(); - }); -#endif - server->begin(); - } - udp.listenMulticast(MULTICAST_IP, MULTICAST_PORT); udp.onPacket([this](AsyncUDPPacket &packet) { __loop_knx(packet); }); }