diff --git a/libraries/MySensors/MySensor.h b/libraries/MySensors/MySensor.h index f368f9f..4b54a51 100644 --- a/libraries/MySensors/MySensor.h +++ b/libraries/MySensors/MySensor.h @@ -26,7 +26,7 @@ #include "MyConfig.h" -#if defined(MY_GATEWAY_SERIAL) || defined(MY_GATEWAY_W5100) +#if defined(MY_GATEWAY_SERIAL) || defined(MY_GATEWAY_W5100) || defined(MY_GATEWAY_ENC28J60) #define MY_GATEWAY_FEATURE #define MY_NODE_TYPE "gateway" #elif defined(MY_REPEATER_FEATURE) @@ -102,6 +102,13 @@ // We assume that a gateway having a radio also should act as repeater #define MY_REPEATER_FEATURE #endif + #if defined(MY_CONTROLLER_IP_ADDRESS) + #define MY_GATEWAY_CLIENT_MODE + #endif + #if !defined(MY_PORT) + #error You must define MY_PORT (cotroller or gatway port to open) + #endif + #if defined(MY_GATEWAY_W5100) #include "drivers/AVR/Ethernet_W5100/utility/socket.cpp" #include "drivers/AVR/Ethernet_W5100/utility/w5100.cpp" @@ -110,13 +117,6 @@ #include "drivers/AVR/Ethernet_W5100/EthernetUdp.cpp" #include "drivers/AVR/Ethernet_W5100/IPAddress.cpp" - #if defined(MY_CONTROLLER_IP_ADDRESS) - #define MY_GATEWAY_CLIENT_MODE - #endif - - #if !defined(MY_PORT) - #error You must define MY_PORT (cotroller or gatway port to open) - #endif #if !defined(USE_UDP) #include "drivers/AVR/Ethernet_W5100/EthernetServer.cpp" #endif @@ -127,6 +127,23 @@ #else // What do we do here? #endif + #elif defined(MY_GATEWAY_ENC28J60) + #undef MY_USE_UDP // Will not fit (or compile) on ENC28J60 + #include "drivers/AVR/Ethernet_UIP/src/utility/uipethernet-conf.h" + #include "drivers/AVR/Ethernet_UIP/src/utility/uip-conf.h" + #include "drivers/AVR/Ethernet_UIP/src/UIPEthernet.h" + #include "drivers/AVR/Ethernet_UIP/src/utility/Enc28J60Network.cpp" + #include "drivers/AVR/Ethernet_UIP/src/utility/mempool_conf.h" + #include "drivers/AVR/Ethernet_UIP/src/utility/mempool.cpp" + #include "drivers/AVR/Ethernet_UIP/src/UIPEthernet.cpp" + #include "drivers/AVR/Ethernet_UIP/src/UIPServer.cpp" + #include "drivers/AVR/Ethernet_UIP/src/UIPClient.cpp" + #include "drivers/AVR/Ethernet_UIP/src/utility/clock-arch.c" + #include "drivers/AVR/Ethernet_UIP/src/utility/uip_timer.c" + #include "drivers/AVR/Ethernet_UIP/src/utility/uip.c" + #include "drivers/AVR/Ethernet_UIP/src/utility/uip_arp.c" + + #include "core/MyGatewayTransportEthernet.cpp" #elif defined(MY_GATEWAY_SERIAL) #include "core/MyGatewayTransportSerial.cpp" #endif diff --git a/libraries/MySensors/core/MyProtocol.cpp b/libraries/MySensors/core/MyProtocol.cpp deleted file mode 100644 index f0a473a..0000000 --- a/libraries/MySensors/core/MyProtocol.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/** - * The MySensors Arduino library handles the wireless radio link and protocol - * between your home built sensors/actuators and HA controller of choice. - * The sensors forms a self healing radio network with optional repeaters. Each - * repeater and gateway builds a routing tables in EEPROM which keeps track of the - * network topology allowing messages to be routed to nodes. - * - * Created by Henrik Ekblad - * Copyright (C) 2013-2015 Sensnology AB - * Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors - * - * Documentation: http://www.mysensors.org - * Support Forum: http://forum.mysensors.org - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * version 2 as published by the Free Software Foundation. - */ - -#include "MyProtocol.h" - -MyProtocol::MyProtocol() { -} diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/README b/libraries/MySensors/drivers/AVR/Ethernet_UIP/README index 321b334..c7368c6 100644 --- a/libraries/MySensors/drivers/AVR/Ethernet_UIP/README +++ b/libraries/MySensors/drivers/AVR/Ethernet_UIP/README @@ -1,4 +1,4 @@ -This is UIPEthernet version 1.09 +This is UIPEthernet version 1.59 An plugin-replacement of the stock Arduino Ethernet library for ENC28J60 shields and breakout boards. Full support for persistent (streaming) TCP-connections and UDP (Client and Server each), ARP, ICMP, DHCP and DNS. Just include 'UIPEthernet.h' instead of 'Ethernet.h' and use all your code written for the stock Arduino Ethernet lib! diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/AdvancedChatServer/AdvancedChatServer.ino b/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/AdvancedChatServer/AdvancedChatServer.ino index bc2f094..7b3b132 100644 --- a/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/AdvancedChatServer/AdvancedChatServer.ino +++ b/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/AdvancedChatServer/AdvancedChatServer.ino @@ -20,6 +20,7 @@ */ +#include #include // Enter a MAC address and IP address for your controller below. diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/EchoServer/EchoServer.ino b/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/EchoServer/EchoServer.ino index 62d66e4..8603001 100644 --- a/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/EchoServer/EchoServer.ino +++ b/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/EchoServer/EchoServer.ino @@ -18,6 +18,7 @@ * Adaption to Enc28J60 by Norbert Truchsess */ +#include #include // The connection_data struct needs to be defined in an external file. #include diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/TcpClient/TcpClient.ino b/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/TcpClient/TcpClient.ino index dca685c..444b36a 100644 --- a/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/TcpClient/TcpClient.ino +++ b/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/TcpClient/TcpClient.ino @@ -16,6 +16,7 @@ * Copyright (C) 2013 by Norbert Truchsess */ +#include #include EthernetClient client; diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/TcpServer/TcpServer.ino b/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/TcpServer/TcpServer.ino index 10512ec..b8a1e6d 100644 --- a/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/TcpServer/TcpServer.ino +++ b/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/TcpServer/TcpServer.ino @@ -18,6 +18,7 @@ * Adaption to Enc28J60 by Norbert Truchsess */ +#include #include EthernetServer server = EthernetServer(1000); diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/UdpClient/UdpClient.ino b/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/UdpClient/UdpClient.ino index aad56b4..f549c48 100644 --- a/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/UdpClient/UdpClient.ino +++ b/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/UdpClient/UdpClient.ino @@ -16,6 +16,7 @@ * Copyright (C) 2013 by Norbert Truchsess (norbert.truchsess@t-online.de) */ +#include #include EthernetUDP udp; diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/UdpServer/UdpServer.ino b/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/UdpServer/UdpServer.ino index 3b12d75..06b94be 100644 --- a/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/UdpServer/UdpServer.ino +++ b/libraries/MySensors/drivers/AVR/Ethernet_UIP/examples/UdpServer/UdpServer.ino @@ -14,6 +14,7 @@ * Copyright (C) 2013 by Norbert Truchsess (norbert.truchsess@t-online.de) */ +#include #include EthernetUDP udp; diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/library.properties b/libraries/MySensors/drivers/AVR/Ethernet_UIP/library.properties index 158ae31..cd8c551 100644 --- a/libraries/MySensors/drivers/AVR/Ethernet_UIP/library.properties +++ b/libraries/MySensors/drivers/AVR/Ethernet_UIP/library.properties @@ -4,7 +4,7 @@ email=Norbert Truchsess sentence=Ethernet library for ENC28J60 paragraph=implements the same API as stock Ethernet-lib. Just replace the include of Ethernet.h with UIPEthernet.h url=https://github.com/ntruchsess/arduino_uip -architectures=avr -version=1.04 +architectures=* +version=1.50 dependencies= core-dependencies=arduino (>=1.5.0) diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/Dhcp.cpp b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/Dhcp.cpp similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/Dhcp.cpp rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/Dhcp.cpp diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/Dhcp.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/Dhcp.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/Dhcp.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/Dhcp.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/Dns.cpp b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/Dns.cpp similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/Dns.cpp rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/Dns.cpp diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/Dns.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/Dns.h similarity index 98% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/Dns.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/Dns.h index 4913ca8..1b6bb3d 100644 --- a/libraries/MySensors/drivers/AVR/Ethernet_UIP/Dns.h +++ b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/Dns.h @@ -5,7 +5,7 @@ #ifndef DNSClient_h #define DNSClient_h -#include +#include "UIPUdp.h" class DNSClient { diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPClient.cpp b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPClient.cpp similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPClient.cpp rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPClient.cpp diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPClient.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPClient.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPClient.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPClient.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPEthernet.cpp b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPEthernet.cpp similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPEthernet.cpp rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPEthernet.cpp diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPEthernet.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPEthernet.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPEthernet.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPEthernet.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPServer.cpp b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPServer.cpp similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPServer.cpp rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPServer.cpp diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPServer.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPServer.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPServer.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPServer.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPUdp.cpp b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPUdp.cpp similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPUdp.cpp rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPUdp.cpp diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPUdp.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPUdp.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/UIPUdp.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/UIPUdp.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/ethernet_comp.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/ethernet_comp.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/ethernet_comp.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/ethernet_comp.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/Enc28J60Network.cpp b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/Enc28J60Network.cpp similarity index 87% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/Enc28J60Network.cpp rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/Enc28J60Network.cpp index c7c66fb..9c154cd 100644 --- a/libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/Enc28J60Network.cpp +++ b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/Enc28J60Network.cpp @@ -25,8 +25,19 @@ #include "Enc28J60Network.h" #include "Arduino.h" +#if ENC28J60_USE_SPILIB +#include +#endif + extern "C" { -#include + #if defined(ARDUINO_ARCH_AVR) + // AVR-specific code + #include + #elif defined(ARDUINO_ARCH_SAM) + // SAM-specific code + #else + // generic, non-platform specific code + #endif #include "enc28j60.h" #include "uip.h" } @@ -40,7 +51,15 @@ extern "C" { // set CS to 1 = passive #define CSPASSIVE digitalWrite(ENC28J60_CONTROL_CS, HIGH) // +#if defined(ARDUINO_ARCH_AVR) #define waitspi() while(!(SPSR&(1<tcpstateflags != UIP_CLOSED && conn->lport == htons(lastport)) { goto again; @@ -427,8 +427,8 @@ uip_connect(uip_ipaddr_t *ripaddr, u16_t rport) } conn = 0; - for(c = 0; c < UIP_CONNS; ++c) { - cconn = &uip_conns[c]; + for(cc = 0; cc < UIP_CONNS; ++cc) { + cconn = &uip_conns[cc]; if(cconn->tcpstateflags == UIP_CLOSED) { conn = cconn; break; @@ -482,17 +482,17 @@ uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport) lastport = 4096; } - for(c = 0; c < UIP_UDP_CONNS; ++c) { - if(uip_udp_conns[c].lport == htons(lastport)) { + for(cc = 0; cc < UIP_UDP_CONNS; ++cc) { + if(uip_udp_conns[cc].lport == htons(lastport)) { goto again; } } conn = 0; - for(c = 0; c < UIP_UDP_CONNS; ++c) { - if(uip_udp_conns[c].lport == 0) { - conn = &uip_udp_conns[c]; + for(cc = 0; cc < UIP_UDP_CONNS; ++cc) { + if(uip_udp_conns[cc].lport == 0) { + conn = &uip_udp_conns[cc]; break; } } @@ -517,9 +517,9 @@ uip_udp_new(uip_ipaddr_t *ripaddr, u16_t rport) void uip_unlisten(u16_t port) { - for(c = 0; c < UIP_LISTENPORTS; ++c) { - if(uip_listenports[c] == port) { - uip_listenports[c] = 0; + for(cc = 0; cc < UIP_LISTENPORTS; ++cc) { + if(uip_listenports[cc] == port) { + uip_listenports[cc] = 0; return; } } @@ -528,9 +528,9 @@ uip_unlisten(u16_t port) void uip_listen(u16_t port) { - for(c = 0; c < UIP_LISTENPORTS; ++c) { - if(uip_listenports[c] == 0) { - uip_listenports[c] = port; + for(cc = 0; cc < UIP_LISTENPORTS; ++cc) { + if(uip_listenports[cc] == 0) { + uip_listenports[cc] = port; return; } } @@ -1206,8 +1206,8 @@ uip_process(u8_t flag) tmp16 = BUF->destport; /* Next, check listening connections. */ - for(c = 0; c < UIP_LISTENPORTS; ++c) { - if(tmp16 == uip_listenports[c]) + for(cc = 0; cc < UIP_LISTENPORTS; ++cc) { + if(tmp16 == uip_listenports[cc]) goto found_listen; } @@ -1227,21 +1227,21 @@ uip_process(u8_t flag) BUF->tcpoffset = 5 << 4; /* Flip the seqno and ackno fields in the TCP header. */ - c = BUF->seqno[3]; + cc = BUF->seqno[3]; BUF->seqno[3] = BUF->ackno[3]; - BUF->ackno[3] = c; + BUF->ackno[3] = cc; - c = BUF->seqno[2]; + cc = BUF->seqno[2]; BUF->seqno[2] = BUF->ackno[2]; - BUF->ackno[2] = c; + BUF->ackno[2] = cc; - c = BUF->seqno[1]; + cc = BUF->seqno[1]; BUF->seqno[1] = BUF->ackno[1]; - BUF->ackno[1] = c; + BUF->ackno[1] = cc; - c = BUF->seqno[0]; + cc = BUF->seqno[0]; BUF->seqno[0] = BUF->ackno[0]; - BUF->ackno[0] = c; + BUF->ackno[0] = cc; /* We also have to increase the sequence number we are acknowledging. If the least significant byte overflowed, we need @@ -1277,15 +1277,15 @@ uip_process(u8_t flag) CLOSED connections are found. Thanks to Eddie C. Dost for a very nice algorithm for the TIME_WAIT search. */ uip_connr = 0; - for(c = 0; c < UIP_CONNS; ++c) { - if(uip_conns[c].tcpstateflags == UIP_CLOSED) { - uip_connr = &uip_conns[c]; + for(cc = 0; cc < UIP_CONNS; ++cc) { + if(uip_conns[cc].tcpstateflags == UIP_CLOSED) { + uip_connr = &uip_conns[cc]; break; } - if(uip_conns[c].tcpstateflags == UIP_TIME_WAIT) { + if(uip_conns[cc].tcpstateflags == UIP_TIME_WAIT) { if(uip_connr == 0 || - uip_conns[c].timer > uip_connr->timer) { - uip_connr = &uip_conns[c]; + uip_conns[cc].timer > uip_connr->timer) { + uip_connr = &uip_conns[cc]; } } } @@ -1325,19 +1325,19 @@ uip_process(u8_t flag) /* Parse the TCP MSS option, if present. */ if((BUF->tcpoffset & 0xf0) > 0x50) { - for(c = 0; c < ((BUF->tcpoffset >> 4) - 5) << 2 ;) { - opt = uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + c]; + for(cc = 0; cc < ((BUF->tcpoffset >> 4) - 5) << 2 ;) { + opt = uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + cc]; if(opt == TCP_OPT_END) { /* End of options. */ break; } else if(opt == TCP_OPT_NOOP) { - ++c; + ++cc; /* NOP option. */ } else if(opt == TCP_OPT_MSS && - uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == TCP_OPT_MSS_LEN) { + uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + cc] == TCP_OPT_MSS_LEN) { /* An MSS option with the right option length. */ - tmp16 = ((u16_t)uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + c] << 8) | - (u16_t)uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + 3 + c]; + tmp16 = ((u16_t)uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + cc] << 8) | + (u16_t)uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + 3 + cc]; uip_connr->initialmss = uip_connr->mss = tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16; @@ -1346,12 +1346,12 @@ uip_process(u8_t flag) } else { /* All other options have a length field, so that we easily can skip past them. */ - if(uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == 0) { + if(uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + cc] == 0) { /* If the length field is zero, the options are malformed and we don't process them further. */ break; } - c += uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c]; + cc += uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + cc]; } } } @@ -1395,11 +1395,11 @@ uip_process(u8_t flag) } /* Calculated the length of the data, if the application has sent any data to us. */ - c = (BUF->tcpoffset >> 4) << 2; + cc = (BUF->tcpoffset >> 4) << 2; /* uip_len will contain the length of the actual TCP data. This is calculated by subtracing the length of the TCP header (in c) and the length of the IP header (20 bytes). */ - uip_len = uip_len - c - UIP_IPH_LEN; + uip_len = uip_len - cc - UIP_IPH_LEN; /* First, check if the sequence number of the incoming packet is what we're expecting next. If not, we send out an ACK with the @@ -1494,19 +1494,19 @@ uip_process(u8_t flag) /* Parse the TCP MSS option, if present. */ if((BUF->tcpoffset & 0xf0) > 0x50) { - for(c = 0; c < ((BUF->tcpoffset >> 4) - 5) << 2 ;) { - opt = uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + c]; + for(cc = 0; cc < ((BUF->tcpoffset >> 4) - 5) << 2 ;) { + opt = uip_buf[UIP_IPTCPH_LEN + UIP_LLH_LEN + cc]; if(opt == TCP_OPT_END) { /* End of options. */ break; } else if(opt == TCP_OPT_NOOP) { - ++c; + ++cc; /* NOP option. */ } else if(opt == TCP_OPT_MSS && - uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == TCP_OPT_MSS_LEN) { + uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + cc] == TCP_OPT_MSS_LEN) { /* An MSS option with the right option length. */ - tmp16 = (uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + c] << 8) | - uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 3 + c]; + tmp16 = (uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 2 + cc] << 8) | + uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 3 + cc]; uip_connr->initialmss = uip_connr->mss = tmp16 > UIP_TCP_MSS? UIP_TCP_MSS: tmp16; @@ -1515,12 +1515,12 @@ uip_process(u8_t flag) } else { /* All other options have a length field, so that we easily can skip past them. */ - if(uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c] == 0) { + if(uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + cc] == 0) { /* If the length field is zero, the options are malformed and we don't process them further. */ break; } - c += uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + c]; + cc += uip_buf[UIP_TCPIP_HLEN + UIP_LLH_LEN + 1 + cc]; } } } diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_arch.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_arch.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_arch.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_arch.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_arp.c b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_arp.c similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_arp.c rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_arp.c diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_arp.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_arp.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_arp.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_arp.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_clock.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_clock.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_clock.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_clock.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_debug.cpp b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_debug.cpp similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_debug.cpp rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_debug.cpp diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_debug.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_debug.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_debug.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_debug.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_timer.c b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_timer.c similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_timer.c rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_timer.c diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_timer.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_timer.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uip_timer.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uip_timer.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uipethernet-conf.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uipethernet-conf.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uipethernet-conf.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uipethernet-conf.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uipopt.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uipopt.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/uipopt.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/uipopt.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/util.h b/libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/util.h similarity index 100% rename from libraries/MySensors/drivers/AVR/Ethernet_UIP/utility/util.h rename to libraries/MySensors/drivers/AVR/Ethernet_UIP/src/utility/util.h diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/tests/perl/tcpclient.pl b/libraries/MySensors/drivers/AVR/Ethernet_UIP/tests/perl/tcpclient.pl deleted file mode 100644 index e6884dc..0000000 --- a/libraries/MySensors/drivers/AVR/Ethernet_UIP/tests/perl/tcpclient.pl +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/perl -#tcpclient.pl - -use IO::Socket::INET; - -# flush after every write -$| = 1; - -my ($socket,$client_socket); - -# creating object interface of IO::Socket::INET modules which internally creates -# socket, binds and connects to the TCP server running on the specific port. -$socket = new IO::Socket::INET ( -PeerHost => '192.168.0.6', -PeerPort => '1000', -Proto => 'tcp', -) or die "ERROR in Socket Creation : $!\n"; - -print "TCP Connection Success.\n"; - -# write on the socket to server. -$data = "DATA from Client"; -print $socket "$data\n"; -# we can also send the data through IO::Socket::INET module, -# $socket->send($data); - -# read the socket data sent by server. -$data = <$socket>; -# we can also read from socket through recv() in IO::Socket::INET -# $socket->recv($data,1024); -print "Received from Server : $data\n"; - -sleep (10); -$socket->close(); \ No newline at end of file diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/tests/perl/tcpserver.pl b/libraries/MySensors/drivers/AVR/Ethernet_UIP/tests/perl/tcpserver.pl deleted file mode 100644 index 17405a3..0000000 --- a/libraries/MySensors/drivers/AVR/Ethernet_UIP/tests/perl/tcpserver.pl +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/perl -#tcpserver.pl - -use IO::Socket::INET; - -# flush after every write -$| = 1; - -my ($socket,$client_socket); -my ($peeraddress,$peerport); - -# creating object interface of IO::Socket::INET modules which internally does -# socket creation, binding and listening at the specified port address. -$socket = new IO::Socket::INET ( -LocalHost => '192.168.0.1', -LocalPort => '5000', -Proto => 'tcp', -Listen => 5, -Reuse => 1 -) or die "ERROR in Socket Creation : $!\n"; - -print "SERVER Waiting for client connection on port 5000\n"; - -while(1) -{ - # waiting for new client connection. - $client_socket = $socket->accept(); - - # get the host and port number of newly connected client. - $peer_address = $client_socket->peerhost(); - $peer_port = $client_socket->peerport(); - - print "Accepted New Client Connection From : $peer_address, $peer_port\n "; - - # read operation on the newly accepted client - $data = <$client_socket>; - # we can also read from socket through recv() in IO::Socket::INET - # $client_socket->recv($data,1024); - print "Received from Client : $data\n"; - - # write operation on the newly accepted client. - $data = "DATA from Server"; - print $client_socket "$data\n"; - # we can also send the data through IO::Socket::INET module, - # $client_socket->send($data); - - sleep(1); - - $client_socket->close(); -} - -$socket->close(); - diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/tests/perl/udpclient.pl b/libraries/MySensors/drivers/AVR/Ethernet_UIP/tests/perl/udpclient.pl deleted file mode 100644 index bc9e6a2..0000000 --- a/libraries/MySensors/drivers/AVR/Ethernet_UIP/tests/perl/udpclient.pl +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/perl -#udpclient.pl - -use IO::Socket::INET; - -# flush after every write -$| = 1; - -my ($socket,$data); - -# We call IO::Socket::INET->new() to create the UDP Socket -# and bind with the PeerAddr. -$socket = new IO::Socket::INET ( -PeerAddr => '192.168.0.6:5000', -Proto => 'udp' -) or die "ERROR in Socket Creation : $!\n"; -#send operation -$data = "data from client"; -$socket->send($data); - -#read operation -$data = <$socket>; -print "Data received from socket : $data\n "; - -sleep(10); -$socket->close(); diff --git a/libraries/MySensors/drivers/AVR/Ethernet_UIP/tests/perl/udpserver.pl b/libraries/MySensors/drivers/AVR/Ethernet_UIP/tests/perl/udpserver.pl deleted file mode 100644 index e728a46..0000000 --- a/libraries/MySensors/drivers/AVR/Ethernet_UIP/tests/perl/udpserver.pl +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/perl -#udpserver.pl - -use IO::Socket::INET; - -# flush after every write -$| = 1; - -my ($socket,$received_data); -my ($peeraddress,$peerport); - -# we call IO::Socket::INET->new() to create the UDP Socket and bound -# to specific port number mentioned in LocalPort and there is no need to provide -# LocalAddr explicitly as in TCPServer. -$socket = new IO::Socket::INET ( -LocalPort => '5000', -Proto => 'udp', -) or die "ERROR in Socket Creation : $!\n"; - -while(1) -{ -# read operation on the socket -$socket->recv($recieved_data,1024); - -#get the peerhost and peerport at which the recent data received. -$peer_address = $socket->peerhost(); -$peer_port = $socket->peerport(); -print "($peer_address , $peer_port) said : $recieved_data\n"; - -#send the data to the client at which the read/write operations done recently. -$data = "data from server\n"; - -$socket->send($data); - -print $socket "$data"; - -} - -$socket->close(); - diff --git a/libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino b/libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino index 3dd66d8..79c1e08 100644 --- a/libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino +++ b/libraries/MySensors/examples/EthernetGateway/EthernetGateway.ino @@ -63,8 +63,9 @@ #define MY_RADIO_NRF24 -// W5100 Ethernet gateway -#define MY_GATEWAY_W5100 +// Enable gateway type +//#define MY_GATEWAY_W5100 +#define MY_GATEWAY_ENC28J60 // Set default gateway protocol (http://www.mysensors.org/download/serial_api_15) #define MY_GATEWAY_PROTOCOL_DEFAULT