From 9f3db3083ada344ffac794d440d7644a411e24e9 Mon Sep 17 00:00:00 2001 From: Gennaro Tortone Date: Fri, 18 May 2018 18:34:56 +0200 Subject: [PATCH 1/4] upgrade of italian language --- sonoff/language/it-IT.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sonoff/language/it-IT.h b/sonoff/language/it-IT.h index 475db6b16..16c11645b 100644 --- a/sonoff/language/it-IT.h +++ b/sonoff/language/it-IT.h @@ -76,7 +76,7 @@ #define D_DARKLIGHT "Scuro" #define D_DEBUG "Debug" #define D_DISABLED "Disabilitato" -#define D_DISTANCE "Distance" +#define D_DISTANCE "Distanza" #define D_DNS_SERVER "DNS Server" #define D_DONE "Fatto" #define D_DST_TIME "DST" @@ -146,14 +146,14 @@ #define D_SUBNET_MASK "Maschera sottorete" #define D_SUBSCRIBE_TO "Sottoscrivi a" #define D_SUCCESSFUL "Riuscito" -#define D_SUNRISE "Sunrise" -#define D_SUNSET "Sunset" +#define D_SUNRISE "Alba" +#define D_SUNSET "Tramonto" #define D_TEMPERATURE "Temperatura" #define D_TO "a" #define D_TOGGLE "Toggle" #define D_TOPIC "Topic" #define D_TRANSMIT "Trasmesso" -#define D_TRUE "True" +#define D_TRUE "Vero" #define D_TVOC "TVOC" #define D_UPGRADE "aggiornamento" #define D_UPLOAD "Invio" @@ -401,7 +401,7 @@ #define D_KNX_COMMAND_OTHER "Altro" #define D_SENT_TO "invia a" #define D_KNX_WARNING "L'indirizzo del gruppo ( 0 / 0 / 0 ) è riservato e non può essere usato." -#define D_KNX_ENHANCEMENT "Communication Enhancement" +#define D_KNX_ENHANCEMENT "Miglioramento Comunicazione" // xdrv_03_energy.ino #define D_ENERGY_TODAY "Energia Oggi" From 21fadca8f0d99e23116bd14b5017f98b10a290f8 Mon Sep 17 00:00:00 2001 From: Adrian Scillato Date: Fri, 18 May 2018 19:57:16 -0300 Subject: [PATCH 2/4] Fix Bug on KNX Menu Fix Bug on KNX Menu that shows Energy Options while there is no energy sensor selected. --- sonoff/xdrv_11_knx.ino | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/sonoff/xdrv_11_knx.ino b/sonoff/xdrv_11_knx.ino index 80d2e2cdf..dfbdbb33b 100644 --- a/sonoff/xdrv_11_knx.ino +++ b/sonoff/xdrv_11_knx.ino @@ -48,9 +48,14 @@ byte Settings.knx_CB_param[MAX_KNX_CB] Type of Output (set relay, t \*********************************************************************************************/ -#include +#include // KNX Library + // Note: Inside the file there is a //#define USE_ASYNC_UDP // UDP WIFI Library Selection for Multicast + // If commented out, the esp-knx-ip library will use WIFI_UDP Library that is compatible with ESP8266 Library Version 2.3.0 and up + // If not commented out, the esp-knx-ip library will use ESPAsyncUDP Library that is compatible with ESP8266 Library Version 2.4.0 and up + // The ESPAsyncUDP Library have a more reliable multicast communication + // Please Use it with Patch (https://github.com/me-no-dev/ESPAsyncUDP/pull/21) ) -//void KNX_CB_Action(message_t const &msg, void *arg); // Define function (action callback) to be called by the KNX_IP Library +//void KNX_CB_Action(message_t const &msg, void *arg); // Define function (action callback) to be called by the Esp-KNX-IP Library // when an action is requested by another KNX Device address_t KNX_physs_addr; // Physical KNX address of this device @@ -58,7 +63,7 @@ address_t KNX_addr; // KNX Address converter variable #define KNX_Empty 255 -#define TOGGLE_INHIBIT_TIME 10 // 10*50mseg = 500mseg (inhibit time for not toggling again relays) +#define TOGGLE_INHIBIT_TIME 15 // 15*50mseg = 750mseg (inhibit time for not toggling again relays by a KNX toggle command) float last_temp; float last_hum; @@ -433,11 +438,7 @@ void KNX_INIT() if (GetUsedInModule(GPIO_SI7021, my_module.gp.io)) { device_param[KNX_HUMIDITY-1].show = true; } // Sonoff 31 or Sonoff Pow or any HLW8012 based device or Sonoff POW R2 or Any device with a Pzem004T - if ( ( SONOFF_S31 == Settings.module ) || - ( (GetUsedInModule(GPIO_HLW_SEL, my_module.gp.io)) && (GetUsedInModule(GPIO_HLW_CF1, my_module.gp.io)) && (GetUsedInModule(GPIO_HLW_CF, my_module.gp.io)) ) || - ( SONOFF_POW_R2 == Settings.module ) || - ( (GetUsedInModule(GPIO_PZEM_RX, my_module.gp.io)) && (GetUsedInModule(GPIO_PZEM_TX, my_module.gp.io)) ) ) - { + if ( ( SONOFF_S31 == Settings.module ) || ( SONOFF_POW_R2 == Settings.module ) || ( energy_flg != ENERGY_NONE ) ) { device_param[KNX_ENERGY_POWER-1].show = true; device_param[KNX_ENERGY_DAILY-1].show = true; device_param[KNX_ENERGY_START-1].show = true; @@ -968,4 +969,4 @@ boolean Xdrv11(byte function) return result; } -#endif // USE_KNX \ No newline at end of file +#endif // USE_KNX From fa12295beb7bb4d6d0b55e515068aca815cef0d2 Mon Sep 17 00:00:00 2001 From: ascillato Date: Fri, 18 May 2018 20:42:23 -0300 Subject: [PATCH 3/4] Updated esp-knx-ip library Updated esp-knx-ip library with a merged version that allows to select multicast library to use: * WIFI UDP (for esp lib 2.3.0 and up) * AsyncUDP (for esp lib 2.4.0 and up) The selection can be done with a definition key in the file esp-knx-ip.h --- lib/ESPAsyncUDP-master/.travis.yml | 37 ++ lib/ESPAsyncUDP-master/README.md | 10 + .../AsyncUDPClient/AsyncUDPClient.ino | 51 +++ .../AsyncUDPMulticastServer.ino | 52 +++ .../AsyncUDPServer/AsyncUDPServer.ino | 50 ++ lib/ESPAsyncUDP-master/keywords.txt | 33 ++ lib/ESPAsyncUDP-master/library.json | 17 + lib/ESPAsyncUDP-master/library.properties | 9 + lib/ESPAsyncUDP-master/src/AsyncUDP.cpp | 427 ++++++++++++++++++ lib/ESPAsyncUDP-master/src/ESPAsyncUDP.h | 130 ++++++ lib/ESPAsyncUDP-master/travis/common.sh | 23 + .../DPT.h | 2 +- .../LICENSE | 0 .../README.md | 0 .../esp-knx-ip-config.cpp | 0 .../esp-knx-ip-conversion.cpp | 0 .../esp-knx-ip-send.cpp | 18 +- .../esp-knx-ip-webserver.cpp | 0 .../esp-knx-ip.cpp | 28 +- .../esp-knx-ip.h | 38 +- .../environment-sensor/environment-sensor.ino | 0 .../examples/sonoff/sonoff.ino | 0 .../examples/static-config/static-config.ino | 0 .../keywords.txt | 0 .../library.properties | 2 +- 25 files changed, 916 insertions(+), 11 deletions(-) create mode 100644 lib/ESPAsyncUDP-master/.travis.yml create mode 100644 lib/ESPAsyncUDP-master/README.md create mode 100644 lib/ESPAsyncUDP-master/examples/AsyncUDPClient/AsyncUDPClient.ino create mode 100644 lib/ESPAsyncUDP-master/examples/AsyncUDPMulticastServer/AsyncUDPMulticastServer.ino create mode 100644 lib/ESPAsyncUDP-master/examples/AsyncUDPServer/AsyncUDPServer.ino create mode 100644 lib/ESPAsyncUDP-master/keywords.txt create mode 100644 lib/ESPAsyncUDP-master/library.json create mode 100644 lib/ESPAsyncUDP-master/library.properties create mode 100644 lib/ESPAsyncUDP-master/src/AsyncUDP.cpp create mode 100644 lib/ESPAsyncUDP-master/src/ESPAsyncUDP.h create mode 100644 lib/ESPAsyncUDP-master/travis/common.sh rename lib/{esp-knx-ip-0.5.0 => esp-knx-ip-0.5.1}/DPT.h (99%) rename lib/{esp-knx-ip-0.5.0 => esp-knx-ip-0.5.1}/LICENSE (100%) rename lib/{esp-knx-ip-0.5.0 => esp-knx-ip-0.5.1}/README.md (100%) rename lib/{esp-knx-ip-0.5.0 => esp-knx-ip-0.5.1}/esp-knx-ip-config.cpp (100%) rename lib/{esp-knx-ip-0.5.0 => esp-knx-ip-0.5.1}/esp-knx-ip-conversion.cpp (100%) rename lib/{esp-knx-ip-0.5.0 => esp-knx-ip-0.5.1}/esp-knx-ip-send.cpp (88%) rename lib/{esp-knx-ip-0.5.0 => esp-knx-ip-0.5.1}/esp-knx-ip-webserver.cpp (100%) rename lib/{esp-knx-ip-0.5.0 => esp-knx-ip-0.5.1}/esp-knx-ip.cpp (97%) rename lib/{esp-knx-ip-0.5.0 => esp-knx-ip-0.5.1}/esp-knx-ip.h (93%) rename lib/{esp-knx-ip-0.5.0 => esp-knx-ip-0.5.1}/examples/environment-sensor/environment-sensor.ino (100%) rename lib/{esp-knx-ip-0.5.0 => esp-knx-ip-0.5.1}/examples/sonoff/sonoff.ino (100%) rename lib/{esp-knx-ip-0.5.0 => esp-knx-ip-0.5.1}/examples/static-config/static-config.ino (100%) rename lib/{esp-knx-ip-0.5.0 => esp-knx-ip-0.5.1}/keywords.txt (100%) rename lib/{esp-knx-ip-0.5.0 => esp-knx-ip-0.5.1}/library.properties (95%) diff --git a/lib/ESPAsyncUDP-master/.travis.yml b/lib/ESPAsyncUDP-master/.travis.yml new file mode 100644 index 000000000..c1ef4ec8f --- /dev/null +++ b/lib/ESPAsyncUDP-master/.travis.yml @@ -0,0 +1,37 @@ +sudo: false +language: bash +os: + - linux + +script: + - /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16 + - sleep 3 + - export DISPLAY=:1.0 + - wget http://downloads.arduino.cc/arduino-1.6.5-linux64.tar.xz + - tar xf arduino-1.6.5-linux64.tar.xz + - mv arduino-1.6.5 $HOME/arduino_ide + - export PATH="$HOME/arduino_ide:$PATH" + - which arduino + - mkdir -p $HOME/Arduino/libraries + - cp -r $TRAVIS_BUILD_DIR $HOME/Arduino/libraries/ESPAsyncUDP + - cd $HOME/arduino_ide/hardware + - mkdir esp8266com + - cd esp8266com + - git clone https://github.com/esp8266/Arduino.git esp8266 + - cd esp8266/tools + - python get.py + - source $TRAVIS_BUILD_DIR/travis/common.sh + - arduino --board esp8266com:esp8266:generic --save-prefs + - arduino --get-pref sketchbook.path + - build_sketches arduino $HOME/Arduino/libraries/ESPAsyncUDP esp8266 + +notifications: + email: + on_success: change + on_failure: change + webhooks: + urls: + - https://webhooks.gitter.im/e/60e65d0c78ea0a920347 + on_success: change # options: [always|never|change] default: always + on_failure: always # options: [always|never|change] default: always + on_start: false # default: false diff --git a/lib/ESPAsyncUDP-master/README.md b/lib/ESPAsyncUDP-master/README.md new file mode 100644 index 000000000..997a7cc26 --- /dev/null +++ b/lib/ESPAsyncUDP-master/README.md @@ -0,0 +1,10 @@ +# ESPAsyncUDP +Async UDP Library for ESP8266 Arduino [![Build Status](https://travis-ci.org/me-no-dev/ESPAsyncUDP.svg?branch=master)](https://travis-ci.org/me-no-dev/ESPAsyncUDP) + +[![Join the chat at https://gitter.im/me-no-dev/ESPAsyncWebServer](https://badges.gitter.im/me-no-dev/ESPAsyncWebServer.svg)](https://gitter.im/me-no-dev/ESPAsyncWebServer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +This is a fully asynchronous UDP library, aimed at enabling trouble-free, multi-connection network environment for Espressif's ESP8266 MCUs. + +The library is easy to use and includes support for Unicast, Broadcast and Multicast environments + +Latest GIT version of ESP8266 Arduino might be required for this library to work diff --git a/lib/ESPAsyncUDP-master/examples/AsyncUDPClient/AsyncUDPClient.ino b/lib/ESPAsyncUDP-master/examples/AsyncUDPClient/AsyncUDPClient.ino new file mode 100644 index 000000000..cf528fe12 --- /dev/null +++ b/lib/ESPAsyncUDP-master/examples/AsyncUDPClient/AsyncUDPClient.ino @@ -0,0 +1,51 @@ +#include +#include "ESPAsyncUDP.h" + +const char * ssid = "***********"; +const char * password = "***********"; + +AsyncUDP udp; + +void setup() +{ + Serial.begin(115200); + WiFi.mode(WIFI_STA); + WiFi.begin(ssid, password); + if (WiFi.waitForConnectResult() != WL_CONNECTED) { + Serial.println("WiFi Failed"); + while(1) { + delay(1000); + } + } + if(udp.connect(IPAddress(192,168,1,100), 1234)) { + Serial.println("UDP connected"); + udp.onPacket([](AsyncUDPPacket packet) { + Serial.print("UDP Packet Type: "); + Serial.print(packet.isBroadcast()?"Broadcast":packet.isMulticast()?"Multicast":"Unicast"); + Serial.print(", From: "); + Serial.print(packet.remoteIP()); + Serial.print(":"); + Serial.print(packet.remotePort()); + Serial.print(", To: "); + Serial.print(packet.localIP()); + Serial.print(":"); + Serial.print(packet.localPort()); + Serial.print(", Length: "); + Serial.print(packet.length()); + Serial.print(", Data: "); + Serial.write(packet.data(), packet.length()); + Serial.println(); + //reply to the client + packet.printf("Got %u bytes of data", packet.length()); + }); + //Send unicast + udp.print("Hello Server!"); + } +} + +void loop() +{ + delay(1000); + //Send broadcast on port 1234 + udp.broadcastTo("Anyone here?", 1234); +} diff --git a/lib/ESPAsyncUDP-master/examples/AsyncUDPMulticastServer/AsyncUDPMulticastServer.ino b/lib/ESPAsyncUDP-master/examples/AsyncUDPMulticastServer/AsyncUDPMulticastServer.ino new file mode 100644 index 000000000..bb3e69c9b --- /dev/null +++ b/lib/ESPAsyncUDP-master/examples/AsyncUDPMulticastServer/AsyncUDPMulticastServer.ino @@ -0,0 +1,52 @@ +#include +#include "ESPAsyncUDP.h" + +const char * ssid = "***********"; +const char * password = "***********"; + +AsyncUDP udp; + +void setup() +{ + Serial.begin(115200); + WiFi.mode(WIFI_STA); + WiFi.begin(ssid, password); + if (WiFi.waitForConnectResult() != WL_CONNECTED) { + Serial.println("WiFi Failed"); + while(1) { + delay(1000); + } + } + if(udp.listenMulticast(IPAddress(239,1,2,3), 1234)) { + Serial.print("UDP Listening on IP: "); + Serial.println(WiFi.localIP()); + udp.onPacket([](AsyncUDPPacket packet) { + Serial.print("UDP Packet Type: "); + Serial.print(packet.isBroadcast()?"Broadcast":packet.isMulticast()?"Multicast":"Unicast"); + Serial.print(", From: "); + Serial.print(packet.remoteIP()); + Serial.print(":"); + Serial.print(packet.remotePort()); + Serial.print(", To: "); + Serial.print(packet.localIP()); + Serial.print(":"); + Serial.print(packet.localPort()); + Serial.print(", Length: "); + Serial.print(packet.length()); + Serial.print(", Data: "); + Serial.write(packet.data(), packet.length()); + Serial.println(); + //reply to the client + packet.printf("Got %u bytes of data", packet.length()); + }); + //Send multicast + udp.print("Hello!"); + } +} + +void loop() +{ + delay(1000); + //Send multicast + udp.print("Anyone here?"); +} diff --git a/lib/ESPAsyncUDP-master/examples/AsyncUDPServer/AsyncUDPServer.ino b/lib/ESPAsyncUDP-master/examples/AsyncUDPServer/AsyncUDPServer.ino new file mode 100644 index 000000000..fc12a7fc3 --- /dev/null +++ b/lib/ESPAsyncUDP-master/examples/AsyncUDPServer/AsyncUDPServer.ino @@ -0,0 +1,50 @@ +#include +#include "ESPAsyncUDP.h" + +const char * ssid = "***********"; +const char * password = "***********"; + +AsyncUDP udp; + +void setup() +{ + Serial.begin(115200); + WiFi.mode(WIFI_STA); + WiFi.begin(ssid, password); + if (WiFi.waitForConnectResult() != WL_CONNECTED) { + Serial.println("WiFi Failed"); + while(1) { + delay(1000); + } + } + if(udp.listen(1234)) { + Serial.print("UDP Listening on IP: "); + Serial.println(WiFi.localIP()); + udp.onPacket([](AsyncUDPPacket packet) { + Serial.print("UDP Packet Type: "); + Serial.print(packet.isBroadcast()?"Broadcast":packet.isMulticast()?"Multicast":"Unicast"); + Serial.print(", From: "); + Serial.print(packet.remoteIP()); + Serial.print(":"); + Serial.print(packet.remotePort()); + Serial.print(", To: "); + Serial.print(packet.localIP()); + Serial.print(":"); + Serial.print(packet.localPort()); + Serial.print(", Length: "); + Serial.print(packet.length()); + Serial.print(", Data: "); + Serial.write(packet.data(), packet.length()); + Serial.println(); + //reply to the client + packet.printf("Got %u bytes of data", packet.length()); + }); + } +} + +void loop() +{ + delay(1000); + //Send broadcast + udp.broadcast("Anyone here?"); +} diff --git a/lib/ESPAsyncUDP-master/keywords.txt b/lib/ESPAsyncUDP-master/keywords.txt new file mode 100644 index 000000000..67c0b97a7 --- /dev/null +++ b/lib/ESPAsyncUDP-master/keywords.txt @@ -0,0 +1,33 @@ +####################################### +# Syntax Coloring Map For Ultrasound +####################################### + +####################################### +# Datatypes (KEYWORD1) +####################################### + +AsyncUDP KEYWORD1 +AsyncUDPPacket KEYWORD1 + +####################################### +# Methods and Functions (KEYWORD2) +####################################### + +connect KEYWORD2 +connected KEYWORD2 +listen KEYWORD2 +listenMulticast KEYWORD2 +close KEYWORD2 +write KEYWORD2 +broadcast KEYWORD2 +onPacket KEYWORD2 +data KEYWORD2 +length KEYWORD2 +localIP KEYWORD2 +localPort KEYWORD2 +remoteIP KEYWORD2 +remotePort KEYWORD2 + +####################################### +# Constants (LITERAL1) +####################################### diff --git a/lib/ESPAsyncUDP-master/library.json b/lib/ESPAsyncUDP-master/library.json new file mode 100644 index 000000000..fe300b6e6 --- /dev/null +++ b/lib/ESPAsyncUDP-master/library.json @@ -0,0 +1,17 @@ +{ + "name":"ESPAsyncUDP", + "description":"Asynchronous UDP Library for ESP8266", + "keywords":"async,udp,server,client,multicast,broadcast", + "authors": + { + "name": "Hristo Gochkov", + "maintainer": true + }, + "repository": + { + "type": "git", + "url": "https://github.com/me-no-dev/ESPAsyncUDP.git" + }, + "frameworks": "arduino", + "platforms":"espressif" +} diff --git a/lib/ESPAsyncUDP-master/library.properties b/lib/ESPAsyncUDP-master/library.properties new file mode 100644 index 000000000..1aa6ef1ad --- /dev/null +++ b/lib/ESPAsyncUDP-master/library.properties @@ -0,0 +1,9 @@ +name=ESP Async UDP +version=1.0.0 +author=Me-No-Dev +maintainer=Me-No-Dev +sentence=Async UDP Library for ESP8266 +paragraph=Async UDP Library for ESP8266 +category=Other +url=https://github.com/me-no-dev/ESPAsyncUDP +architectures=* diff --git a/lib/ESPAsyncUDP-master/src/AsyncUDP.cpp b/lib/ESPAsyncUDP-master/src/AsyncUDP.cpp new file mode 100644 index 000000000..2a538c4c6 --- /dev/null +++ b/lib/ESPAsyncUDP-master/src/AsyncUDP.cpp @@ -0,0 +1,427 @@ +#include "Arduino.h" +#include "ESPAsyncUDP.h" + +extern "C" { +#include "user_interface.h" +#include "lwip/opt.h" +#include "lwip/inet.h" +#include "lwip/udp.h" +#include "lwip/igmp.h" +} + +AsyncUDPMessage::AsyncUDPMessage(size_t size) +{ + _index = 0; + if(size > 1460) { + size = 1460; + } + _size = size; + _buffer = (uint8_t *)malloc(size); +} + +AsyncUDPMessage::~AsyncUDPMessage() +{ + if(_buffer) { + free(_buffer); + } +} + +size_t AsyncUDPMessage::write(const uint8_t *data, size_t len) +{ + if(_buffer == NULL) { + return 0; + } + size_t s = space(); + if(len > s) { + len = s; + } + memcpy(_buffer + _index, data, len); + _index += len; + return len; +} + +size_t AsyncUDPMessage::write(uint8_t data) +{ + return write(&data, 1); +} + +size_t AsyncUDPMessage::space() +{ + if(_buffer == NULL) { + return 0; + } + return _size - _index; +} + +uint8_t * AsyncUDPMessage::data() +{ + return _buffer; +} + +size_t AsyncUDPMessage::length() +{ + return _index; +} + +void AsyncUDPMessage::flush() +{ + _index = 0; +} + + +AsyncUDPPacket::AsyncUDPPacket(AsyncUDP *udp, ip_addr_t *localIp, uint16_t localPort, ip_addr_t *remoteIp, uint16_t remotePort, uint8_t *data, size_t len) +{ + _udp = udp; + _localIp = localIp; + _localPort = localPort; + _remoteIp = remoteIp; + _remotePort = remotePort; + _data = data; + _len = len; +} + +AsyncUDPPacket::~AsyncUDPPacket() +{ + +} + +uint8_t * AsyncUDPPacket::data() +{ + return _data; +} + +size_t AsyncUDPPacket::length() +{ + return _len; +} + +IPAddress AsyncUDPPacket::localIP() +{ + return IPAddress(_localIp->addr); +} + +uint16_t AsyncUDPPacket::localPort() +{ + return _localPort; +} + +IPAddress AsyncUDPPacket::remoteIP() +{ + return IPAddress(_remoteIp->addr); +} + +uint16_t AsyncUDPPacket::remotePort() +{ + return _remotePort; +} + +bool AsyncUDPPacket::isBroadcast() +{ + return _localIp->addr == 0xFFFFFFFF || _localIp->addr == (uint32_t)(0); +} + +bool AsyncUDPPacket::isMulticast() +{ + return ip_addr_ismulticast(_localIp); +} + +size_t AsyncUDPPacket::write(const uint8_t *data, size_t len) +{ + return _udp->writeTo(data, len, _remoteIp, _remotePort); +} + +size_t AsyncUDPPacket::write(uint8_t data) +{ + return write(&data, 1); +} + +size_t AsyncUDPPacket::send(AsyncUDPMessage &message) +{ + return write(message.data(), message.length()); +} + + + +AsyncUDP::AsyncUDP() +{ + _pcb = NULL; + _connected = false; + _handler = NULL; +} + +AsyncUDP::~AsyncUDP() +{ + close(); +} + +AsyncUDP::operator bool() +{ + return _connected; +} + +bool AsyncUDP::connected() +{ + return _connected; +} + +void AsyncUDP::onPacket(AuPacketHandlerFunctionWithArg cb, void * arg) +{ + onPacket(std::bind(cb, arg, std::placeholders::_1)); +} + +void AsyncUDP::onPacket(AuPacketHandlerFunction cb) +{ + _handler = cb; +} + +void AsyncUDP::_recv(udp_pcb *upcb, pbuf *pb, ip_addr_t *addr, uint16_t port) +{ + (void)upcb; // its unused, avoid warning + while(pb != NULL) { + if(_handler) { + uint8_t * data = (uint8_t*)((pb)->payload); + size_t len = pb->len; + + ip_hdr* iphdr = reinterpret_cast(data - UDP_HLEN - IP_HLEN); + ip_addr_t daddr; + daddr.addr = iphdr->dest.addr; + + udp_hdr* udphdr = reinterpret_cast(((uint8_t*)((pb)->payload)) - UDP_HLEN); + uint16_t dport = ntohs(udphdr->dest); + + AsyncUDPPacket packet(this, &daddr, dport, addr, port, data, len); + _handler(packet); + } + + pbuf * this_pb = pb; + pb = pb->next; + this_pb->next = NULL; + pbuf_free(this_pb); + } +} + +#if LWIP_VERSION_MAJOR == 1 +void AsyncUDP::_s_recv(void *arg, udp_pcb *upcb, pbuf *p, ip_addr_t *addr, uint16_t port) +#else +void AsyncUDP::_s_recv(void *arg, udp_pcb *upcb, pbuf *p, const ip_addr_t *addr, uint16_t port) +#endif +{ + reinterpret_cast(arg)->_recv(upcb, p, (ip_addr_t *)addr, port); +} + +bool AsyncUDP::listen(ip_addr_t *addr, uint16_t port) +{ + close(); + _pcb = udp_new(); + if(_pcb == NULL) { + return false; + } + err_t err = udp_bind(_pcb, addr, port); + if(err != ERR_OK) { + close(); + return false; + } + udp_recv(_pcb, &_s_recv, (void *) this); + _connected = true; + return true; +} + +bool AsyncUDP::listenMulticast(ip_addr_t *addr, uint16_t port, uint8_t ttl) +{ + close(); + if(!ip_addr_ismulticast(addr)) { + return false; + } + ip_addr_t multicast_if_addr; + struct ip_info ifIpInfo; + int mode = wifi_get_opmode(); + if(mode & STATION_MODE) { + wifi_get_ip_info(STATION_IF, &ifIpInfo); + multicast_if_addr.addr = ifIpInfo.ip.addr; + } else if (mode & SOFTAP_MODE) { + wifi_get_ip_info(SOFTAP_IF, &ifIpInfo); + multicast_if_addr.addr = ifIpInfo.ip.addr; + } else { + return false; + } + if (igmp_joingroup(&multicast_if_addr, addr)!= ERR_OK) { + return false; + } + if(!listen(IPADDR_ANY, port)) { + return false; + } +#if LWIP_VERSION_MAJOR == 1 + udp_set_multicast_netif_addr(_pcb, multicast_if_addr); +#else + udp_set_multicast_netif_addr(_pcb, &multicast_if_addr); +#endif + udp_set_multicast_ttl(_pcb, ttl); + ip_addr_copy(_pcb->remote_ip, *addr); + _pcb->remote_port = port; + return true; +} + +bool AsyncUDP::connect(ip_addr_t *addr, uint16_t port) +{ + close(); + _pcb = udp_new(); + if(_pcb == NULL) { + return false; + } + err_t err = udp_connect(_pcb, addr, port); + if(err != ERR_OK) { + close(); + return false; + } + udp_recv(_pcb, &_s_recv, (void *) this); + _connected = true; + return true; +} + +void AsyncUDP::close() +{ + if(_pcb != NULL) { + if(_connected) { + udp_disconnect(_pcb); + } + udp_remove(_pcb); + _connected = false; + _pcb = NULL; + } +} + +size_t AsyncUDP::writeTo(const uint8_t *data, size_t len, ip_addr_t *addr, uint16_t port) +{ + if(!_pcb && !connect(addr, port)) { + return 0; + } + if(len > 1460) { + len = 1460; + } + pbuf* pbt = pbuf_alloc(PBUF_TRANSPORT, len, PBUF_RAM); + if(pbt != NULL) { + uint8_t* dst = reinterpret_cast(pbt->payload); + memcpy(dst, data, len); + err_t err = udp_sendto(_pcb, pbt, addr, port); + pbuf_free(pbt); + if(err < ERR_OK) { + return 0; + } + return len; + } + return 0; +} + +bool AsyncUDP::listen(const IPAddress addr, uint16_t port) +{ + ip_addr_t laddr; + laddr.addr = addr; + return listen(&laddr, port); +} + +bool AsyncUDP::listen(uint16_t port) +{ + return listen(IPAddress((uint32_t)INADDR_ANY), port); +} + +bool AsyncUDP::listenMulticast(const IPAddress addr, uint16_t port, uint8_t ttl) +{ + ip_addr_t laddr; + laddr.addr = addr; + return listenMulticast(&laddr, port, ttl); +} + +bool AsyncUDP::connect(const IPAddress addr, uint16_t port) +{ + ip_addr_t daddr; + daddr.addr = addr; + return connect(&daddr, port); +} + +size_t AsyncUDP::writeTo(const uint8_t *data, size_t len, const IPAddress addr, uint16_t port) +{ + ip_addr_t daddr; + daddr.addr = addr; + return writeTo(data, len, &daddr, port); +} + +size_t AsyncUDP::write(const uint8_t *data, size_t len) +{ + //return writeTo(data, len, &(_pcb->remote_ip), _pcb->remote_port); + if(_pcb){ // Patch applied (https://github.com/me-no-dev/ESPAsyncUDP/pull/21) + return writeTo(data, len, &(_pcb->remote_ip), _pcb->remote_port); + } + return 0; +} + +size_t AsyncUDP::write(uint8_t data) +{ + return write(&data, 1); +} + +size_t AsyncUDP::broadcastTo(uint8_t *data, size_t len, uint16_t port) +{ + ip_addr_t daddr; + daddr.addr = 0xFFFFFFFF; + return writeTo(data, len, &daddr, port); +} + +size_t AsyncUDP::broadcastTo(const char * data, uint16_t port) +{ + return broadcastTo((uint8_t *)data, strlen(data), port); +} + +size_t AsyncUDP::broadcast(uint8_t *data, size_t len) +{ + if(_pcb->local_port != 0) { + return broadcastTo(data, len, _pcb->local_port); + } + return 0; +} + +size_t AsyncUDP::broadcast(const char * data) +{ + return broadcast((uint8_t *)data, strlen(data)); +} + + +size_t AsyncUDP::sendTo(AsyncUDPMessage &message, ip_addr_t *addr, uint16_t port) +{ + if(!message) { + return 0; + } + return writeTo(message.data(), message.length(), addr, port); +} + +size_t AsyncUDP::sendTo(AsyncUDPMessage &message, const IPAddress addr, uint16_t port) +{ + //if(!message) { + if((!message) || (!_pcb)) { // Patch applied (https://github.com/me-no-dev/ESPAsyncUDP/pull/21) + return 0; + } + return writeTo(message.data(), message.length(), addr, port); +} + +size_t AsyncUDP::send(AsyncUDPMessage &message) +{ + if(!message) { + return 0; + } + return writeTo(message.data(), message.length(), &(_pcb->remote_ip), _pcb->remote_port); +} + +size_t AsyncUDP::broadcastTo(AsyncUDPMessage &message, uint16_t port) +{ + if(!message) { + return 0; + } + return broadcastTo(message.data(), message.length(), port); +} + +size_t AsyncUDP::broadcast(AsyncUDPMessage &message) +{ + if(!message) { + return 0; + } + return broadcast(message.data(), message.length()); +} diff --git a/lib/ESPAsyncUDP-master/src/ESPAsyncUDP.h b/lib/ESPAsyncUDP-master/src/ESPAsyncUDP.h new file mode 100644 index 000000000..8e5a70b21 --- /dev/null +++ b/lib/ESPAsyncUDP-master/src/ESPAsyncUDP.h @@ -0,0 +1,130 @@ +#ifndef ESPASYNCUDP_H +#define ESPASYNCUDP_H + +#include "IPAddress.h" +#include "Print.h" +#include +#include "lwip/init.h" + +class AsyncUDP; +class AsyncUDPPacket; +class AsyncUDPMessage; +struct udp_pcb; +struct pbuf; +#if LWIP_VERSION_MAJOR == 1 +struct ip_addr; +typedef struct ip_addr ip_addr_t; +#else +struct ip4_addr; +typedef struct ip4_addr ip_addr_t; +#endif + +class AsyncUDPMessage : public Print +{ +protected: + uint8_t *_buffer; + size_t _index; + size_t _size; +public: + AsyncUDPMessage(size_t size=1460); + virtual ~AsyncUDPMessage(); + size_t write(const uint8_t *data, size_t len); + size_t write(uint8_t data); + size_t space(); + uint8_t * data(); + size_t length(); + void flush(); + operator bool() + { + return _buffer != NULL; + } +}; + +class AsyncUDPPacket : public Print +{ +protected: + AsyncUDP *_udp; + ip_addr_t *_localIp; + uint16_t _localPort; + ip_addr_t *_remoteIp; + uint16_t _remotePort; + uint8_t *_data; + size_t _len; +public: + AsyncUDPPacket(AsyncUDP *udp, ip_addr_t *localIp, uint16_t localPort, ip_addr_t *remoteIp, uint16_t remotePort, uint8_t *data, size_t len); + virtual ~AsyncUDPPacket(); + + uint8_t * data(); + size_t length(); + bool isBroadcast(); + bool isMulticast(); + + IPAddress localIP(); + uint16_t localPort(); + IPAddress remoteIP(); + uint16_t remotePort(); + + size_t send(AsyncUDPMessage &message); + + size_t write(const uint8_t *data, size_t len); + size_t write(uint8_t data); +}; + +typedef std::function AuPacketHandlerFunction; +typedef std::function AuPacketHandlerFunctionWithArg; + +class AsyncUDP : public Print +{ +protected: + udp_pcb *_pcb; + bool _connected; + AuPacketHandlerFunction _handler; + + void _recv(udp_pcb *upcb, pbuf *pb, ip_addr_t *addr, uint16_t port); +#if LWIP_VERSION_MAJOR == 1 + static void _s_recv(void *arg, udp_pcb *upcb, pbuf *p, ip_addr_t *addr, uint16_t port); +#else + static void _s_recv(void *arg, udp_pcb *upcb, pbuf *p, const ip_addr_t *addr, uint16_t port); +#endif + +public: + AsyncUDP(); + virtual ~AsyncUDP(); + + void onPacket(AuPacketHandlerFunctionWithArg cb, void * arg=NULL); + void onPacket(AuPacketHandlerFunction cb); + + bool listen(ip_addr_t *addr, uint16_t port); + bool listen(const IPAddress addr, uint16_t port); + bool listen(uint16_t port); + + bool listenMulticast(ip_addr_t *addr, uint16_t port, uint8_t ttl=1); + bool listenMulticast(const IPAddress addr, uint16_t port, uint8_t ttl=1); + + bool connect(ip_addr_t *addr, uint16_t port); + bool connect(const IPAddress addr, uint16_t port); + + void close(); + + size_t writeTo(const uint8_t *data, size_t len, ip_addr_t *addr, uint16_t port); + size_t writeTo(const uint8_t *data, size_t len, const IPAddress addr, uint16_t port); + size_t write(const uint8_t *data, size_t len); + size_t write(uint8_t data); + + size_t broadcastTo(uint8_t *data, size_t len, uint16_t port); + size_t broadcastTo(const char * data, uint16_t port); + size_t broadcast(uint8_t *data, size_t len); + size_t broadcast(const char * data); + + size_t sendTo(AsyncUDPMessage &message, ip_addr_t *addr, uint16_t port); + size_t sendTo(AsyncUDPMessage &message, const IPAddress addr, uint16_t port); + size_t send(AsyncUDPMessage &message); + + size_t broadcastTo(AsyncUDPMessage &message, uint16_t port); + size_t broadcast(AsyncUDPMessage &message); + + bool connected(); + operator bool(); +}; + +#endif diff --git a/lib/ESPAsyncUDP-master/travis/common.sh b/lib/ESPAsyncUDP-master/travis/common.sh new file mode 100644 index 000000000..57bede343 --- /dev/null +++ b/lib/ESPAsyncUDP-master/travis/common.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +function build_sketches() +{ + local arduino=$1 + local srcpath=$2 + local platform=$3 + local sketches=$(find $srcpath -name *.ino) + for sketch in $sketches; do + local sketchdir=$(dirname $sketch) + if [[ -f "$sketchdir/.$platform.skip" ]]; then + echo -e "\n\n ------------ Skipping $sketch ------------ \n\n"; + continue + fi + echo -e "\n\n ------------ Building $sketch ------------ \n\n"; + $arduino --verify $sketch; + local result=$? + if [ $result -ne 0 ]; then + echo "Build failed ($1)" + return $result + fi + done +} diff --git a/lib/esp-knx-ip-0.5.0/DPT.h b/lib/esp-knx-ip-0.5.1/DPT.h similarity index 99% rename from lib/esp-knx-ip-0.5.0/DPT.h rename to lib/esp-knx-ip-0.5.1/DPT.h index 72e0c7f54..71045b103 100644 --- a/lib/esp-knx-ip-0.5.0/DPT.h +++ b/lib/esp-knx-ip-0.5.1/DPT.h @@ -69,4 +69,4 @@ typedef struct __color uint8_t red; uint8_t green; uint8_t blue; -} color_t; \ No newline at end of file +} color_t; diff --git a/lib/esp-knx-ip-0.5.0/LICENSE b/lib/esp-knx-ip-0.5.1/LICENSE similarity index 100% rename from lib/esp-knx-ip-0.5.0/LICENSE rename to lib/esp-knx-ip-0.5.1/LICENSE diff --git a/lib/esp-knx-ip-0.5.0/README.md b/lib/esp-knx-ip-0.5.1/README.md similarity index 100% rename from lib/esp-knx-ip-0.5.0/README.md rename to lib/esp-knx-ip-0.5.1/README.md diff --git a/lib/esp-knx-ip-0.5.0/esp-knx-ip-config.cpp b/lib/esp-knx-ip-0.5.1/esp-knx-ip-config.cpp similarity index 100% rename from lib/esp-knx-ip-0.5.0/esp-knx-ip-config.cpp rename to lib/esp-knx-ip-0.5.1/esp-knx-ip-config.cpp diff --git a/lib/esp-knx-ip-0.5.0/esp-knx-ip-conversion.cpp b/lib/esp-knx-ip-0.5.1/esp-knx-ip-conversion.cpp similarity index 100% rename from lib/esp-knx-ip-0.5.0/esp-knx-ip-conversion.cpp rename to lib/esp-knx-ip-0.5.1/esp-knx-ip-conversion.cpp diff --git a/lib/esp-knx-ip-0.5.0/esp-knx-ip-send.cpp b/lib/esp-knx-ip-0.5.1/esp-knx-ip-send.cpp similarity index 88% rename from lib/esp-knx-ip-0.5.0/esp-knx-ip-send.cpp rename to lib/esp-knx-ip-0.5.1/esp-knx-ip-send.cpp index 72459f922..624e08d18 100644 --- a/lib/esp-knx-ip-0.5.0/esp-knx-ip-send.cpp +++ b/lib/esp-knx-ip-0.5.1/esp-knx-ip-send.cpp @@ -33,10 +33,11 @@ void ESPKNXIP::send(address_t const &receiver, knx_command_type_t ct, uint8_t da cemi_msg->additional_info_len = 0; cemi_service_t *cemi_data = &cemi_msg->data.service_information; cemi_data->control_1.bits.confirm = 0; - cemi_data->control_1.bits.ack = 0; +//cemi_data->control_1.bits.ack = 1; + cemi_data->control_1.bits.ack = 0; // ask for ACK? 0-no 1-yes cemi_data->control_1.bits.priority = B11; cemi_data->control_1.bits.system_broadcast = 0x01; - cemi_data->control_1.bits.repeat = 0x01; + cemi_data->control_1.bits.repeat = 0x01; // 0 = repeated telegram, 1 = not repeated telegram cemi_data->control_1.bits.reserved = 0; cemi_data->control_1.bits.frame_type = 0x01; cemi_data->control_2.bits.extended_frame_format = 0x00; @@ -47,10 +48,13 @@ void ESPKNXIP::send(address_t const &receiver, knx_command_type_t ct, uint8_t da //cemi_data->destination.bytes.high = (area << 3) | line; //cemi_data->destination.bytes.low = member; cemi_data->data_len = data_len; - cemi_data->pci.apci = (ct & 0x0C) >> 2; - cemi_data->pci.tpci_seq_number = 0x00; // ??? - cemi_data->pci.tpci_comm_type = KNX_COT_UDP; // ??? + cemi_data->pci.apci = (ct & 0x0C) >> 2; +//cemi_data->pci.apci = KNX_COT_NCD_ACK; + cemi_data->pci.tpci_seq_number = 0x00; + cemi_data->pci.tpci_comm_type = KNX_COT_UDP; // Type of communication: DATA PACKAGE or CONTROL DATA +//cemi_data->pci.tpci_comm_type = KNX_COT_NCD; // Type of communication: DATA PACKAGE or CONTROL DATA memcpy(cemi_data->data, data, data_len); +//cemi_data->data[0] = (cemi_data->data[0] & 0x3F) | ((KNX_COT_NCD_ACK & 0x03) << 6); cemi_data->data[0] = (cemi_data->data[0] & 0x3F) | ((ct & 0x03) << 6); #if SEND_CHECKSUM @@ -73,9 +77,13 @@ 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.0/esp-knx-ip-webserver.cpp b/lib/esp-knx-ip-0.5.1/esp-knx-ip-webserver.cpp similarity index 100% rename from lib/esp-knx-ip-0.5.0/esp-knx-ip-webserver.cpp rename to lib/esp-knx-ip-0.5.1/esp-knx-ip-webserver.cpp diff --git a/lib/esp-knx-ip-0.5.0/esp-knx-ip.cpp b/lib/esp-knx-ip-0.5.1/esp-knx-ip.cpp similarity index 97% rename from lib/esp-knx-ip-0.5.0/esp-knx-ip.cpp rename to lib/esp-knx-ip-0.5.1/esp-knx-ip.cpp index b572333b9..767fa9752 100644 --- a/lib/esp-knx-ip-0.5.0/esp-knx-ip.cpp +++ b/lib/esp-knx-ip-0.5.1/esp-knx-ip.cpp @@ -96,7 +96,12 @@ void ESPKNXIP::__start() 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() @@ -511,7 +516,9 @@ 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(); @@ -523,9 +530,16 @@ 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) { return; @@ -534,19 +548,31 @@ 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")); DEBUG_PRINT(buf[i], 16); } + #endif + DEBUG_PRINTLN(F("")); knx_ip_pkt_t *knx_pkt = (knx_ip_pkt_t *)buf; diff --git a/lib/esp-knx-ip-0.5.0/esp-knx-ip.h b/lib/esp-knx-ip-0.5.1/esp-knx-ip.h similarity index 93% rename from lib/esp-knx-ip-0.5.0/esp-knx-ip.h rename to lib/esp-knx-ip-0.5.1/esp-knx-ip.h index 538264b3e..d8fde1dc9 100644 --- a/lib/esp-knx-ip-0.5.0/esp-knx-ip.h +++ b/lib/esp-knx-ip-0.5.1/esp-knx-ip.h @@ -7,6 +7,14 @@ #ifndef ESP_KNX_IP_H #define ESP_KNX_IP_H +//#define USE_ASYNC_UDP // UDP WIFI Library Selection for Multicast + // If commented out, the esp-knx-ip library will use WIFI_UDP Library that is compatible with ESP8266 Library Version 2.3.0 and up + // If not commented out, the esp-knx-ip library will use ESPAsyncUDP Library that is compatible with ESP8266 Library Version 2.4.0 and up + // The ESPAsyncUDP Library have a more reliable multicast communication + // Please Use it with Patch (https://github.com/me-no-dev/ESPAsyncUDP/pull/21) ) + // check line 57 on esp-knx-ip.h file is uncommented: #include + // Comment out that line when using UDP WIFI to avoid compiling issues on PlatformIO with ESP8266 Library Version 2.3.0 + /** * CONFIG * All MAX_ values must not exceed 255 (1 byte, except MAC_CONFIG_SPACE which can go up to 2 bytes, so 0xffff in theory) and must not be negative! @@ -25,8 +33,8 @@ #define ALLOW_MULTIPLE_CALLBACKS_PER_ADDRESS 1 // [Default 0] Set to 1 to always test all assigned callbacks. This allows for multiple callbacks being assigned to the same address. If disabled, only the first assigned will be called. // Webserver related -#define USE_BOOTSTRAP 1 // [Default 1] Set to 1 to enable use of bootstrap CSS for nicer webconfig. CSS is loaded from bootstrapcdn.com. Set to 0 to disable -#define ROOT_PREFIX "" // [Default ""] This gets prepended to all webserver paths, default is empty string "". Set this to "/knx" if you want the config to be available on http:///knx +#define USE_BOOTSTRAP 0 // [Default 1] Set to 1 to enable use of bootstrap CSS for nicer webconfig. CSS is loaded from bootstrapcdn.com. Set to 0 to disable +#define ROOT_PREFIX "/knx" // [Default ""] This gets prepended to all webserver paths, default is empty string "". Set this to "/knx" if you want the config to be available on http:///knx #define DISABLE_EEPROM_BUTTONS 1 // [Default 0] Set to 1 to disable the EEPROM buttons in the web ui. #define DISABLE_REBOOT_BUTTON 1 // [Default 0] Set to 1 to disable the reboot button in the web ui. #define DISABLE_RESTORE_BUTTON 1 // [Default 0] Set to 1 to disable the "restore defaults" button in the web ui. @@ -45,7 +53,13 @@ #include "Arduino.h" #include #include + +#ifdef USE_ASYNC_UDP +//#include +#else #include +#endif + #include #include "DPT.h" @@ -157,6 +171,14 @@ typedef enum __knx_communication_type { KNX_COT_NCD = 0x03, // Numbered Control Data } knx_communication_type_t; +/** + * acpi for KNX_COT_NCD + */ +typedef enum __knx_cot_ncd_ack_type { + KNX_COT_NCD_ACK = 0x10, // Inform positively reception of the Previouly received telegram + KNX_COT_NCD_NACK = 0x11, // Inform negatively reception of the Previouly received telegram +} knx_cot_ncd_ack_type_t; + /** * KNX/IP header */ @@ -217,7 +239,7 @@ typedef struct __cemi_service uint8_t ack:1; // 0 = no ack, 1 = ack uint8_t priority:2; // 0 = system, 1 = high, 2 = urgent/alarm, 3 = normal uint8_t system_broadcast:1; // 0 = system broadcast, 1 = broadcast - uint8_t repeat:1; // 0 = repeat on error, 1 = do not repeat + uint8_t repeat:1; // 0 = repeated telegram, 1 = not repeated telegram uint8_t reserved:1; // always zero uint8_t frame_type:1; // 0 = extended, 1 = standard } bits; @@ -509,7 +531,12 @@ class ESPKNXIP { private: void __start(); + +#ifdef USE_ASYNC_UDP + void __loop_knx(AsyncUDPPacket &packet); +#else void __loop_knx(); +#endif // Webserver functions void __loop_webserver(); @@ -544,7 +571,12 @@ 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; diff --git a/lib/esp-knx-ip-0.5.0/examples/environment-sensor/environment-sensor.ino b/lib/esp-knx-ip-0.5.1/examples/environment-sensor/environment-sensor.ino similarity index 100% rename from lib/esp-knx-ip-0.5.0/examples/environment-sensor/environment-sensor.ino rename to lib/esp-knx-ip-0.5.1/examples/environment-sensor/environment-sensor.ino diff --git a/lib/esp-knx-ip-0.5.0/examples/sonoff/sonoff.ino b/lib/esp-knx-ip-0.5.1/examples/sonoff/sonoff.ino similarity index 100% rename from lib/esp-knx-ip-0.5.0/examples/sonoff/sonoff.ino rename to lib/esp-knx-ip-0.5.1/examples/sonoff/sonoff.ino diff --git a/lib/esp-knx-ip-0.5.0/examples/static-config/static-config.ino b/lib/esp-knx-ip-0.5.1/examples/static-config/static-config.ino similarity index 100% rename from lib/esp-knx-ip-0.5.0/examples/static-config/static-config.ino rename to lib/esp-knx-ip-0.5.1/examples/static-config/static-config.ino diff --git a/lib/esp-knx-ip-0.5.0/keywords.txt b/lib/esp-knx-ip-0.5.1/keywords.txt similarity index 100% rename from lib/esp-knx-ip-0.5.0/keywords.txt rename to lib/esp-knx-ip-0.5.1/keywords.txt diff --git a/lib/esp-knx-ip-0.5.0/library.properties b/lib/esp-knx-ip-0.5.1/library.properties similarity index 95% rename from lib/esp-knx-ip-0.5.0/library.properties rename to lib/esp-knx-ip-0.5.1/library.properties index 57cad993c..1adbc402a 100644 --- a/lib/esp-knx-ip-0.5.0/library.properties +++ b/lib/esp-knx-ip-0.5.1/library.properties @@ -1,5 +1,5 @@ name=ESP KNX IP Library -version=0.5 +version=0.5.1 author=Nico Weichbrodt maintainer=Nico Weichbrodt sentence=ESP8266 library for KNX/IP communication. From 65985dc35f3c543e9939d91c587e0c1fa8fae94f Mon Sep 17 00:00:00 2001 From: Adrian Scillato <35405447+ascillato@users.noreply.github.com> Date: Sat, 19 May 2018 03:00:48 -0300 Subject: [PATCH 4/4] Fix 'vars' on Rules The 'vars' was not working from one rule to another because the declaration of the variable was not global and was being lost. --- sonoff/xdrv_10_rules.ino | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sonoff/xdrv_10_rules.ino b/sonoff/xdrv_10_rules.ino index 076e7333d..dfd26d534 100644 --- a/sonoff/xdrv_10_rules.ino +++ b/sonoff/xdrv_10_rules.ino @@ -88,6 +88,8 @@ uint32_t rules_triggers = 0; uint8_t rules_trigger_count = 0; uint8_t rules_teleperiod = 0; +char vars[RULES_MAX_VARS][10] = { 0 }; + /*******************************************************************************************/ long TimeDifference(unsigned long prev, unsigned long next) @@ -243,7 +245,6 @@ bool RulesRuleMatch(String &event, String &rule) bool RulesProcess() { bool serviced = false; - char vars[RULES_MAX_VARS][10] = { 0 }; char stemp[10]; delay(0); // Prohibit possible loop software watchdog @@ -488,4 +489,4 @@ boolean Xdrv10(byte function) return result; } -#endif // USE_RULES \ No newline at end of file +#endif // USE_RULES