From 00c99e512b3a35de491c9f87cd02683eecca4a0e Mon Sep 17 00:00:00 2001 From: ascillato Date: Wed, 24 Oct 2018 14:20:34 -0300 Subject: [PATCH] KNX: Updated ESP-KNX-IP Lib to use only WIFIUDP Lib --- lib/esp-knx-ip-0.5.1/esp-knx-ip-send.cpp | 5 +---- lib/esp-knx-ip-0.5.1/esp-knx-ip.cpp | 22 ---------------------- lib/esp-knx-ip-0.5.1/esp-knx-ip.h | 19 ------------------- 3 files changed, 1 insertion(+), 45 deletions(-) diff --git a/lib/esp-knx-ip-0.5.1/esp-knx-ip-send.cpp b/lib/esp-knx-ip-0.5.1/esp-knx-ip-send.cpp index 624e08d18..23ee319e6 100644 --- a/lib/esp-knx-ip-0.5.1/esp-knx-ip-send.cpp +++ b/lib/esp-knx-ip-0.5.1/esp-knx-ip-send.cpp @@ -77,13 +77,10 @@ void ESPKNXIP::send(address_t const &receiver, knx_command_type_t ct, uint8_t da DEBUG_PRINTLN(F("")); #endif -#ifdef USE_ASYNC_UDP - udp.writeTo(buf, len, MULTICAST_IP, MULTICAST_PORT); -#else udp.beginPacketMulticast(MULTICAST_IP, MULTICAST_PORT, WiFi.localIP()); udp.write(buf, len); udp.endPacket(); -#endif + } void ESPKNXIP::send_1bit(address_t const &receiver, knx_command_type_t ct, uint8_t bit) diff --git a/lib/esp-knx-ip-0.5.1/esp-knx-ip.cpp b/lib/esp-knx-ip-0.5.1/esp-knx-ip.cpp index 767fa9752..5917e62f3 100644 --- a/lib/esp-knx-ip-0.5.1/esp-knx-ip.cpp +++ b/lib/esp-knx-ip-0.5.1/esp-knx-ip.cpp @@ -95,13 +95,7 @@ void ESPKNXIP::__start() #endif server->begin(); } - -#ifdef USE_ASYNC_UDP - udp.listenMulticast(MULTICAST_IP, MULTICAST_PORT); - udp.onPacket([this](AsyncUDPPacket &packet) { __loop_knx(packet); }); -#else udp.beginMulticast(WiFi.localIP(), MULTICAST_IP, MULTICAST_PORT); -#endif } void ESPKNXIP::save_to_eeprom() @@ -516,9 +510,7 @@ feedback_id_t ESPKNXIP::feedback_register_action(String name, feedback_action_fp void ESPKNXIP::loop() { - #ifndef USE_ASYNC_UDP __loop_knx(); - #endif if (server != nullptr) { __loop_webserver(); @@ -530,15 +522,9 @@ void ESPKNXIP::__loop_webserver() server->handleClient(); } -#ifdef USE_ASYNC_UDP -void ESPKNXIP::__loop_knx(AsyncUDPPacket &packet) -{ - size_t read = packet.length(); -#else void ESPKNXIP::__loop_knx() { int read = udp.parsePacket(); -#endif if (!read) { @@ -548,23 +534,15 @@ void ESPKNXIP::__loop_knx() DEBUG_PRINT(F("LEN: ")); DEBUG_PRINTLN(read); -#ifdef USE_ASYNC_UDP - uint8_t *buf = packet.data(); -#else uint8_t buf[read]; udp.read(buf, read); udp.flush(); -#endif DEBUG_PRINT(F("Got packet:")); #ifdef ESP_KNX_DEBUG -#ifdef USE_ASYNC_UDP - for (size_t i = 0; i < read; ++i) -#else for (int i = 0; i < read; ++i) -#endif { DEBUG_PRINT(F(" 0x")); diff --git a/lib/esp-knx-ip-0.5.1/esp-knx-ip.h b/lib/esp-knx-ip-0.5.1/esp-knx-ip.h index 5a4082c32..e2346c5a3 100644 --- a/lib/esp-knx-ip-0.5.1/esp-knx-ip.h +++ b/lib/esp-knx-ip-0.5.1/esp-knx-ip.h @@ -45,18 +45,7 @@ #include "Arduino.h" #include #include - -#include // Arduino_Esp8266 version information (ARDUINO_ESP8266_RELEASE and ARDUINO_ESP8266_RELEASE_2_3_0) -#ifndef ARDUINO_ESP8266_RELEASE_2_3_0 -//#define USE_ASYNC_UDP // UDP WIFI Library Selection for Multicast -#endif - -#ifdef USE_ASYNC_UDP -#include -#else #include -#endif - #include #include "DPT.h" @@ -529,11 +518,7 @@ class ESPKNXIP { private: void __start(); -#ifdef USE_ASYNC_UDP - void __loop_knx(AsyncUDPPacket &packet); -#else void __loop_knx(); -#endif // Webserver functions void __loop_webserver(); @@ -569,11 +554,7 @@ class ESPKNXIP { ESP8266WebServer *server; address_t physaddr; -#ifdef USE_ASYNC_UDP - AsyncUDP udp; -#else WiFiUDP udp; -#endif callback_assignment_id_t registered_callback_assignments; callback_assignment_id_t free_callback_assignment_slots;