diff --git a/README.md b/README.md index 7d95d93705a6..1a1f05a9e119 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ## Sonoff-Tasmota -Alternative firmware for _ESP8266 based devices_ like [iTead](https://www.itead.cc/) _**Sonoff**_ with **web**, **timers**, 'Over The Air' (**OTA**) firmware updates and **sensors support**, allowing control under **Serial**, **HTTP** and **MQTT**, so as to be used on **Smart Home Systems**. Written for Arduino IDE and PlatformIO. +Alternative firmware for _ESP8266 based devices_ like [iTead](https://www.itead.cc/) _**Sonoff**_ with **web**, **timers**, 'Over The Air' (**OTA**) firmware updates and **sensors support**, allowing control under **Serial**, **HTTP**, **KNX** and **MQTT**, so as to be used on **Smart Home Systems**. Written for Arduino IDE and PlatformIO. [![GitHub version](https://img.shields.io/github/release/arendst/Sonoff-Tasmota.svg)](https://github.com/arendst/Sonoff-Tasmota/releases/latest) [![GitHub download](https://img.shields.io/github/downloads/arendst/Sonoff-Tasmota/total.svg)](https://github.com/arendst/Sonoff-Tasmota/releases/latest) @@ -81,4 +81,4 @@ You can contribute to Sonoff-Tasmota by ### License -This program is licensed under GPL-3.0 \ No newline at end of file +This program is licensed under GPL-3.0 diff --git a/lib/ESPAsyncUDP-0.21/README.md b/lib/ESPAsyncUDP-0.21/README.md deleted file mode 100644 index 6568fa37214c..000000000000 --- a/lib/ESPAsyncUDP-0.21/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# ESPAsyncUDP -_Library patched with the [PR #21](https://github.com/me-no-dev/ESPAsyncUDP/pull/21)_ - -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-0.21/examples/AsyncUDPClient/AsyncUDPClient.ino b/lib/ESPAsyncUDP-0.21/examples/AsyncUDPClient/AsyncUDPClient.ino deleted file mode 100644 index cf528fe12ab1..000000000000 --- a/lib/ESPAsyncUDP-0.21/examples/AsyncUDPClient/AsyncUDPClient.ino +++ /dev/null @@ -1,51 +0,0 @@ -#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-0.21/examples/AsyncUDPMulticastServer/AsyncUDPMulticastServer.ino b/lib/ESPAsyncUDP-0.21/examples/AsyncUDPMulticastServer/AsyncUDPMulticastServer.ino deleted file mode 100644 index bb3e69c9b6c3..000000000000 --- a/lib/ESPAsyncUDP-0.21/examples/AsyncUDPMulticastServer/AsyncUDPMulticastServer.ino +++ /dev/null @@ -1,52 +0,0 @@ -#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-0.21/examples/AsyncUDPServer/AsyncUDPServer.ino b/lib/ESPAsyncUDP-0.21/examples/AsyncUDPServer/AsyncUDPServer.ino deleted file mode 100644 index fc12a7fc3ab1..000000000000 --- a/lib/ESPAsyncUDP-0.21/examples/AsyncUDPServer/AsyncUDPServer.ino +++ /dev/null @@ -1,50 +0,0 @@ -#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-0.21/keywords.txt b/lib/ESPAsyncUDP-0.21/keywords.txt deleted file mode 100644 index 67c0b97a7152..000000000000 --- a/lib/ESPAsyncUDP-0.21/keywords.txt +++ /dev/null @@ -1,33 +0,0 @@ -####################################### -# 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-0.21/library.json b/lib/ESPAsyncUDP-0.21/library.json deleted file mode 100644 index fe300b6e62e5..000000000000 --- a/lib/ESPAsyncUDP-0.21/library.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "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-0.21/library.properties b/lib/ESPAsyncUDP-0.21/library.properties deleted file mode 100644 index 1aa6ef1ad78e..000000000000 --- a/lib/ESPAsyncUDP-0.21/library.properties +++ /dev/null @@ -1,9 +0,0 @@ -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-0.21/src/AsyncUDP.cpp b/lib/ESPAsyncUDP-0.21/src/AsyncUDP.cpp deleted file mode 100644 index 6d2423819f65..000000000000 --- a/lib/ESPAsyncUDP-0.21/src/AsyncUDP.cpp +++ /dev/null @@ -1,425 +0,0 @@ -#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) -{ - if(_pcb) - { - return writeTo(data, len, &(_pcb->remote_ip), _pcb->remote_port); - } -} - -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) { - return 0; - } - return writeTo(message.data(), message.length(), addr, port); -} - -size_t AsyncUDP::send(AsyncUDPMessage &message) -{ - if((!message) || (!_pcb)) { - 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-0.21/src/ESPAsyncUDP.h b/lib/ESPAsyncUDP-0.21/src/ESPAsyncUDP.h deleted file mode 100644 index 8e5a70b21cdc..000000000000 --- a/lib/ESPAsyncUDP-0.21/src/ESPAsyncUDP.h +++ /dev/null @@ -1,130 +0,0 @@ -#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-0.21/travis/common.sh b/lib/ESPAsyncUDP-0.21/travis/common.sh deleted file mode 100644 index 57bede34321a..000000000000 --- a/lib/ESPAsyncUDP-0.21/travis/common.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/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-async-udp-0.4.0.15/DPT.h b/lib/esp-knx-ip-0.5.0/DPT.h similarity index 100% rename from lib/esp-knx-ip-async-udp-0.4.0.15/DPT.h rename to lib/esp-knx-ip-0.5.0/DPT.h diff --git a/lib/esp-knx-ip-async-udp-0.4.0.15/LICENSE b/lib/esp-knx-ip-0.5.0/LICENSE similarity index 100% rename from lib/esp-knx-ip-async-udp-0.4.0.15/LICENSE rename to lib/esp-knx-ip-0.5.0/LICENSE diff --git a/lib/esp-knx-ip-async-udp-0.4.0.15/README.md b/lib/esp-knx-ip-0.5.0/README.md similarity index 77% rename from lib/esp-knx-ip-async-udp-0.4.0.15/README.md rename to lib/esp-knx-ip-0.5.0/README.md index b18b50d6b392..a93c09192553 100644 --- a/lib/esp-knx-ip-async-udp-0.4.0.15/README.md +++ b/lib/esp-knx-ip-0.5.0/README.md @@ -3,19 +3,6 @@ This is a library for the ESP8266 to enable KNXnet/IP communication. It uses UDP multicast on 224.0.23.12:3671. It is intended to be used with the Arduino platform for the ESP8266. -## Prerequisities / Dependencies ## - -* You need version 2.4.0 of the esp8266 board libraries. - * I only tested with lwip v1.4. v2 might work, you need to test yourself. -* You need the [ESPAsyncUDP](https://github.com/me-no-dev/ESPAsyncUDP) library. -* You need a KNXnet/IP **router**. A gateway will **not** work. Alternatively use [knxd](https://github.com/knxd/knxd). - -## Caveats ## - -Receiving packets should work immediately. - -Sending sometimes only works after a substantial amount of time (max 5 minutes in my experiments). In my case, this was fixed by disabling IGMP snooping on the switch(es). - ## How to use ## The library is under development. API may change multiple times in the future. @@ -104,4 +91,4 @@ Simply visit the IP of your ESP with a webbrowser. You can configure the followi * Which group address should trigger which callback * Which group address are to be used by the program (e.g. for status replies) -The configuration is dynamically generated from the code. \ No newline at end of file +The configuration is dynamically generated from the code. diff --git a/lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip-config.cpp b/lib/esp-knx-ip-0.5.0/esp-knx-ip-config.cpp similarity index 100% rename from lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip-config.cpp rename to lib/esp-knx-ip-0.5.0/esp-knx-ip-config.cpp diff --git a/lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip-conversion.cpp b/lib/esp-knx-ip-0.5.0/esp-knx-ip-conversion.cpp similarity index 100% rename from lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip-conversion.cpp rename to lib/esp-knx-ip-0.5.0/esp-knx-ip-conversion.cpp diff --git a/lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip-send.cpp b/lib/esp-knx-ip-0.5.0/esp-knx-ip-send.cpp similarity index 98% rename from lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip-send.cpp rename to lib/esp-knx-ip-0.5.0/esp-knx-ip-send.cpp index 1244fc50a3e1..72459f922757 100644 --- a/lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip-send.cpp +++ b/lib/esp-knx-ip-0.5.0/esp-knx-ip-send.cpp @@ -73,7 +73,9 @@ void ESPKNXIP::send(address_t const &receiver, knx_command_type_t ct, uint8_t da DEBUG_PRINTLN(F("")); #endif - udp.writeTo(buf, len, MULTICAST_IP, MULTICAST_PORT); + udp.beginPacketMulticast(MULTICAST_IP, MULTICAST_PORT, WiFi.localIP()); + udp.write(buf, len); + udp.endPacket(); } void ESPKNXIP::send_1bit(address_t const &receiver, knx_command_type_t ct, uint8_t bit) diff --git a/lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip-webserver.cpp b/lib/esp-knx-ip-0.5.0/esp-knx-ip-webserver.cpp similarity index 100% rename from lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip-webserver.cpp rename to lib/esp-knx-ip-0.5.0/esp-knx-ip-webserver.cpp diff --git a/lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip.cpp b/lib/esp-knx-ip-0.5.0/esp-knx-ip.cpp similarity index 98% rename from lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip.cpp rename to lib/esp-knx-ip-0.5.0/esp-knx-ip.cpp index 35b9c50140c0..b572333b9824 100644 --- a/lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip.cpp +++ b/lib/esp-knx-ip-0.5.0/esp-knx-ip.cpp @@ -96,10 +96,7 @@ void ESPKNXIP::__start() server->begin(); } - udp.listenMulticast(MULTICAST_IP, MULTICAST_PORT); - udp.onPacket([this](AsyncUDPPacket &packet) { - DEBUG_PRINTLN("got packet"); - __loop_knx(packet); }); + udp.beginMulticast(WiFi.localIP(), MULTICAST_IP, MULTICAST_PORT); } void ESPKNXIP::save_to_eeprom() @@ -514,6 +511,7 @@ feedback_id_t ESPKNXIP::feedback_register_action(String name, feedback_action_fp void ESPKNXIP::loop() { + __loop_knx(); if (server != nullptr) { __loop_webserver(); @@ -525,9 +523,9 @@ void ESPKNXIP::__loop_webserver() server->handleClient(); } -void ESPKNXIP::__loop_knx(AsyncUDPPacket &packet) +void ESPKNXIP::__loop_knx() { - size_t read = packet.length(); + int read = udp.parsePacket(); if (!read) { return; @@ -536,11 +534,14 @@ void ESPKNXIP::__loop_knx(AsyncUDPPacket &packet) DEBUG_PRINT(F("LEN: ")); DEBUG_PRINTLN(read); - uint8_t *buf = packet.data(); + uint8_t buf[read]; + + udp.read(buf, read); + udp.flush(); DEBUG_PRINT(F("Got packet:")); #ifdef ESP_KNX_DEBUG - for (size_t i = 0; i < read; ++i) + for (int i = 0; i < read; ++i) { DEBUG_PRINT(F(" 0x")); DEBUG_PRINT(buf[i], 16); diff --git a/lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip.h b/lib/esp-knx-ip-0.5.0/esp-knx-ip.h similarity index 99% rename from lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip.h rename to lib/esp-knx-ip-0.5.0/esp-knx-ip.h index 86e02c5e86df..538264b3eb4b 100644 --- a/lib/esp-knx-ip-async-udp-0.4.0.15/esp-knx-ip.h +++ b/lib/esp-knx-ip-0.5.0/esp-knx-ip.h @@ -45,7 +45,7 @@ #include "Arduino.h" #include #include -#include +#include #include #include "DPT.h" @@ -509,7 +509,7 @@ class ESPKNXIP { private: void __start(); - void __loop_knx(AsyncUDPPacket &packet); + void __loop_knx(); // Webserver functions void __loop_webserver(); @@ -544,7 +544,7 @@ class ESPKNXIP { ESP8266WebServer *server; address_t physaddr; - AsyncUDP udp; + WiFiUDP udp; callback_assignment_id_t registered_callback_assignments; callback_assignment_id_t free_callback_assignment_slots; diff --git a/lib/esp-knx-ip-async-udp-0.4.0.15/examples/environment-sensor/environment-sensor.ino b/lib/esp-knx-ip-0.5.0/examples/environment-sensor/environment-sensor.ino similarity index 100% rename from lib/esp-knx-ip-async-udp-0.4.0.15/examples/environment-sensor/environment-sensor.ino rename to lib/esp-knx-ip-0.5.0/examples/environment-sensor/environment-sensor.ino diff --git a/lib/esp-knx-ip-async-udp-0.4.0.15/examples/sonoff/sonoff.ino b/lib/esp-knx-ip-0.5.0/examples/sonoff/sonoff.ino similarity index 100% rename from lib/esp-knx-ip-async-udp-0.4.0.15/examples/sonoff/sonoff.ino rename to lib/esp-knx-ip-0.5.0/examples/sonoff/sonoff.ino diff --git a/lib/esp-knx-ip-async-udp-0.4.0.15/examples/static-config/static-config.ino b/lib/esp-knx-ip-0.5.0/examples/static-config/static-config.ino similarity index 100% rename from lib/esp-knx-ip-async-udp-0.4.0.15/examples/static-config/static-config.ino rename to lib/esp-knx-ip-0.5.0/examples/static-config/static-config.ino diff --git a/lib/esp-knx-ip-async-udp-0.4.0.15/keywords.txt b/lib/esp-knx-ip-0.5.0/keywords.txt similarity index 100% rename from lib/esp-knx-ip-async-udp-0.4.0.15/keywords.txt rename to lib/esp-knx-ip-0.5.0/keywords.txt diff --git a/lib/esp-knx-ip-async-udp-0.4.0.15/library.properties b/lib/esp-knx-ip-0.5.0/library.properties similarity index 60% rename from lib/esp-knx-ip-async-udp-0.4.0.15/library.properties rename to lib/esp-knx-ip-0.5.0/library.properties index ff2607bdc989..57cad993c4f8 100644 --- a/lib/esp-knx-ip-async-udp-0.4.0.15/library.properties +++ b/lib/esp-knx-ip-0.5.0/library.properties @@ -1,10 +1,10 @@ name=ESP KNX IP Library -version=0.4 +version=0.5 author=Nico Weichbrodt maintainer=Nico Weichbrodt sentence=ESP8266 library for KNX/IP communication. -paragraph=Build your own IoT devices with KNX/IP connectivity! This library depends on the ESPAsyncUDP library. +paragraph=Build your own IoT devices with KNX/IP connectivity! category=Communication url=https://github.com/envy/esp-knx-ip architectures=esp8266 -includes=esp-knx-ip.h \ No newline at end of file +includes=esp-knx-ip.h diff --git a/sonoff/language/es-AR.h b/sonoff/language/es-AR.h index 4a4e6c9ec944..6cedfcc3fccd 100644 --- a/sonoff/language/es-AR.h +++ b/sonoff/language/es-AR.h @@ -375,24 +375,24 @@ #define D_TIMER_ACTION "Estado" // xdrv_10_knx.ino -#define D_CONFIGURE_KNX "Configure KNX" -#define D_KNX_PARAMETERS "KNX Parameters" +#define D_CONFIGURE_KNX "Configuración de KNX" +#define D_KNX_PARAMETERS "Parámetros de KNX" #define D_KNX_GENERAL_CONFIG "General" -#define D_KNX_PHYSICAL_ADDRESS "Physical Address" -#define D_KNX_PHYSICAL_ADDRESS_NOTE "( Must be unique on the KNX network )" -#define D_KNX_ENABLE "Enable KNX" -#define D_KNX_GROUP_ADDRESS_TO_WRITE "Data to Send to Group Addresses" -#define D_ADD "Add" -#define D_DELETE "Delete" -#define D_REPLY "Reply" -#define D_KNX_GROUP_ADDRESS_TO_READ "Group Addresses to Receive Data from" +#define D_KNX_PHYSICAL_ADDRESS "Dirección Física" +#define D_KNX_PHYSICAL_ADDRESS_NOTE "( Debe ser única en la red KNX )" +#define D_KNX_ENABLE "Habilitar KNX" +#define D_KNX_GROUP_ADDRESS_TO_WRITE "Datos a Enviar a las Direcciones de Grupo" +#define D_ADD "Agregar" +#define D_DELETE "Eliminar" +#define D_REPLY "Responder" +#define D_KNX_GROUP_ADDRESS_TO_READ "Direcciones de Grupo para Recibir Datos" #define D_LOG_KNX "KNX: " -#define D_RECEIVED_FROM "Received from" -#define D_KNX_COMMAND_WRITE "Write" -#define D_KNX_COMMAND_READ "Read" -#define D_KNX_COMMAND_OTHER "Other" -#define D_SENT_TO "sent to" -#define D_KNX_WARNING "The group address ( 0 / 0 / 0 ) is reserved and can not be used." +#define D_RECEIVED_FROM "Recibido desde" +#define D_KNX_COMMAND_WRITE "Escribir" +#define D_KNX_COMMAND_READ "Leer" +#define D_KNX_COMMAND_OTHER "Otro" +#define D_SENT_TO "enviada a" +#define D_KNX_WARNING "La dirección de grupo ( 0 / 0 / 0 ) está reservada y no puede ser utilizada." // xdrv_03_energy.ino #define D_ENERGY_TODAY "Energía Hoy" diff --git a/sonoff/settings.h b/sonoff/settings.h index dec5ef2fefd5..806bcdc0275e 100644 --- a/sonoff/settings.h +++ b/sonoff/settings.h @@ -319,4 +319,4 @@ struct XDRVMAILBOX { ADC_MODE(ADC_VCC); // Set ADC input for Power Supply Voltage usage #endif -#endif // _SETTINGS_H_ \ No newline at end of file +#endif // _SETTINGS_H_ diff --git a/sonoff/sonoff.h b/sonoff/sonoff.h index 2a2bb58cea0f..04e3ab550b37 100644 --- a/sonoff/sonoff.h +++ b/sonoff/sonoff.h @@ -176,4 +176,4 @@ const uint8_t kDefaultRfCode[9] PROGMEM = { 0x21, 0x16, 0x01, 0x0E, 0x03, 0x48, extern uint8_t light_device; // Light device number -#endif // _SONOFF_H_ \ No newline at end of file +#endif // _SONOFF_H_ diff --git a/sonoff/xdrv_09_timers.ino b/sonoff/xdrv_09_timers.ino index 65dfd01365d9..4b216b676543 100644 --- a/sonoff/xdrv_09_timers.ino +++ b/sonoff/xdrv_09_timers.ino @@ -711,4 +711,4 @@ boolean Xdrv09(byte function) return result; } -#endif // USE_TIMERS \ No newline at end of file +#endif // USE_TIMERS diff --git a/sonoff/xsns_14_sht3x.ino b/sonoff/xsns_14_sht3x.ino index bef289aa38ef..f474d65357c6 100644 --- a/sonoff/xsns_14_sht3x.ino +++ b/sonoff/xsns_14_sht3x.ino @@ -159,4 +159,4 @@ boolean Xsns14(byte function) } #endif // USE_SHT3X -#endif // USE_I2C \ No newline at end of file +#endif // USE_I2C