diff --git a/firmware/README.md b/firmware/README.md index 82ad0c3..7195a15 100644 --- a/firmware/README.md +++ b/firmware/README.md @@ -1,6 +1,6 @@ ####固件开发环境 * Arduino 1.6 -* github.com/Wiznet/WIZ_Ethernet_Library +* github.com/593141477/WIZ_Ethernet_Library * github.com/593141477/PN532 Library安装方法(Arduino对库的支持实在太hack了): diff --git a/firmware/WIZ_Ethernet_Library-master/.gitattributes b/firmware/WIZ_Ethernet_Library-master/.gitattributes old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/.gitignore b/firmware/WIZ_Ethernet_Library-master/.gitignore old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Dhcp.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Dhcp.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Dhcp.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Dhcp.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Dns.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Dns.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Dns.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Dns.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Ethernet.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Ethernet.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Ethernet.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Ethernet.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/EthernetClient.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/EthernetClient.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/EthernetClient.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/EthernetClient.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/EthernetServer.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/EthernetServer.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/EthernetServer.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/EthernetServer.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/EthernetUdp.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/EthernetUdp.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/EthernetUdp.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/EthernetUdp.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Twitter.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Twitter.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Twitter.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/Twitter.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/ChatServer/ChatServer.ino b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/ChatServer/ChatServer.ino old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/DhcpAddressPrinter/DhcpAddressPrinter.ino old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/TelnetClient/TelnetClient.ino b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/TelnetClient/TelnetClient.ino old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/Twitter_Serial_GW/Twitter_Serial_GW.ino b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/Twitter_Serial_GW/Twitter_Serial_GW.ino old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/Twitter_SimplePost/Twitter_SimplePost.ino b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/Twitter_SimplePost/Twitter_SimplePost.ino old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/UDPSendReceiveString/UDPSendReceiveString.ino b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/UDPSendReceiveString/UDPSendReceiveString.ino old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/UdpNtpClient/UdpNtpClient.ino old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/WebClient/WebClient.ino b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/WebClient/WebClient.ino old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/WebClientRepeating/WebClientRepeating.ino b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/WebClientRepeating/WebClientRepeating.ino old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/WebServer/WebServer.ino b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/WebServer/WebServer.ino old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/XivelyClient/XivelyClient.ino b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/XivelyClient/XivelyClient.ino old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/XivelyClientString/XivelyClientString.ino b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/examples/XivelyClientString/XivelyClientString.ino old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/util.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/util.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/socket.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/socket.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/socket.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/socket.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/w5100.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/w5100.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/w5100.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/w5100.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/w5200.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/w5200.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/w5200.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/w5200.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/w5500.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/w5500.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/w5500.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.0.x/Ethernet/utility/w5500.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Dhcp.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Dhcp.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Dhcp.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Dhcp.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Dns.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Dns.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Dns.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Dns.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Ethernet.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Ethernet.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Ethernet.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Ethernet.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetClient.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetClient.cpp old mode 100755 new mode 100644 index 44a21dc..5e32808 --- a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetClient.cpp +++ b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetClient.cpp @@ -20,6 +20,12 @@ EthernetClient::EthernetClient(uint8_t sock) : _sock(sock) { } +void EthernetClient::initClientSrcPort(uint16_t srcport) { + if(srcport < 1024) + return; + _srcport = srcport; +} + int EthernetClient::connect(const char* host, uint16_t port) { // Look up the host first int ret = 0; @@ -59,15 +65,21 @@ return 0; } - while (status() != SnSR::ESTABLISHED) { + return 1; +} + +int EthernetClient::connecting() +{ + if (status() != SnSR::ESTABLISHED) { delay(1); if (status() == SnSR::CLOSED) { _sock = MAX_SOCK_NUM; return 0; } + return 1; + }else { + return 0; } - - return 1; } size_t EthernetClient::write(uint8_t b) { diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetClient.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetClient.h old mode 100755 new mode 100644 index 1992db0..7fb3239 --- a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetClient.h +++ b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetClient.h @@ -12,8 +12,10 @@ EthernetClient(uint8_t sock); uint8_t status(); + void initClientSrcPort(uint16_t srcport); virtual int connect(IPAddress ip, uint16_t port); virtual int connect(const char *host, uint16_t port); + virtual int connecting(); virtual size_t write(uint8_t); virtual size_t write(const uint8_t *buf, size_t size); virtual int available(); diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetServer.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetServer.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetServer.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetServer.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetUdp.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetUdp.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetUdp.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/EthernetUdp.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Twitter.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Twitter.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Twitter.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/Twitter.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/util.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/util.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/socket.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/socket.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/socket.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/socket.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/util.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/util.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/w5100.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/w5100.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/w5100.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/w5100.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/w5200.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/w5200.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/w5200.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/w5200.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/w5500.cpp b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/w5500.cpp old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/w5500.h b/firmware/WIZ_Ethernet_Library-master/Arduino IDE 1.5.x/Ethernet/src/utility/w5500.h old mode 100755 new mode 100644 diff --git a/firmware/WIZ_Ethernet_Library-master/README.md b/firmware/WIZ_Ethernet_Library-master/README.md old mode 100755 new mode 100644 diff --git a/firmware/core/core.ino b/firmware/core/core.ino index fb03d1b..4e85132 100644 --- a/firmware/core/core.ino +++ b/firmware/core/core.ino @@ -175,8 +175,44 @@ } } +void networkTask() +{ + static uint8_t connectRetries = 0; + static bool bConnecting = false; + if(bConnecting) { + if(!client.connecting()) { + bConnecting = false; + if(client.connected()) { + Serial.println("connected"); + connectRetries = 0; + digitalWrite(led, HIGH); + }else { + Serial.println("connecting failed"); + if(connectRetries > MAX_CONNECT_RETRIES) + ErrorConnect(); + } + } + }else if (!client.connected()) { //connection lost + digitalWrite(led, LOW); + client.stop(); + Serial.println("Trying to connect server."); + connectRetries++; + if(client.connect(SERVER_HOST, SERVER_PORT) > 0) { + Serial.println("bConnecting = true"); + bConnecting = true; + }else { + Serial.println("Error occurred in client.connect()"); + } + }else { + while (client.available() > 0) { + receivePacket(client.read()); + } + } + + renewDhcp(); +} + void loop() { - static uint8_t connect_retries = 0; button.Check(); @@ -204,27 +240,6 @@ rfid.Next(); } - if (!client.connected()) { - digitalWrite(led, LOW); - client.stop(); - - Serial.println(); - Serial.println("Trying to connect server."); - connect_retries++; - if(client.connect(SERVER_HOST, SERVER_PORT)>0){ - Serial.println("connected"); - connect_retries = 0; - digitalWrite(led, HIGH); - }else{ - if(connect_retries <= MAX_CONNECT_RETRIES) - return; - ErrorConnect(); - // software_Reset(); - } - } - while (client.available() > 0){ - receivePacket(client.read()); - } - renewDhcp(); + networkTask(); }