From 8be0236c1a6b19c7981e573ab42f248a1507a718 Mon Sep 17 00:00:00 2001 From: beegee-tokyo Date: Tue, 8 Mar 2022 15:31:04 +0800 Subject: [PATCH] Fix RAK11200 compile error --- src/RAK13800_W5100S.h | 62 +++++++++++++++++++++++++++++++------------ src/RewriteServer.h | 33 +++++++++++++++++++++++ 2 files changed, 78 insertions(+), 17 deletions(-) create mode 100644 src/RewriteServer.h diff --git a/src/RAK13800_W5100S.h b/src/RAK13800_W5100S.h index 39171ae..5f292e5 100644 --- a/src/RAK13800_W5100S.h +++ b/src/RAK13800_W5100S.h @@ -50,9 +50,14 @@ #include #include "Client.h" -#include "Server.h" #include "Udp.h" +#ifdef _VARIANT_RAK11200_ + #include "RewriteServer.h" +#else + #include "Server.h" +#endif + enum EthernetLinkStatus { Unknown, LinkON, @@ -254,24 +259,47 @@ class EthernetClient : public Client { uint16_t _timeout; }; +#if defined(_VARIANT_RAK11200_) + class EthernetServer : public RewriteServer + { + private: + uint16_t _port; + public: + EthernetServer(uint16_t port) : _port(port) { } + EthernetClient available(); + EthernetClient accept(); + virtual void begin(); + virtual size_t write(uint8_t); + virtual size_t write(const uint8_t *buf, size_t size); + virtual operator bool(); + using Print::write; + //void statusreport(); + + // TODO: make private when socket allocation moves to EthernetClass + static uint16_t server_port[MAX_SOCK_NUM]; + }; +#else + class EthernetServer : public Server + { + private: + uint16_t _port; + public: + EthernetServer(uint16_t port) : _port(port) { } + EthernetClient available(); + EthernetClient accept(); + virtual void begin(); + virtual size_t write(uint8_t); + virtual size_t write(const uint8_t *buf, size_t size); + virtual operator bool(); + using Print::write; + //void statusreport(); + + // TODO: make private when socket allocation moves to EthernetClass + static uint16_t server_port[MAX_SOCK_NUM]; + }; +#endif -class EthernetServer : public Server { -private: - uint16_t _port; -public: - EthernetServer(uint16_t port) : _port(port) { } - EthernetClient available(); - EthernetClient accept(); - virtual void begin(); - virtual size_t write(uint8_t); - virtual size_t write(const uint8_t *buf, size_t size); - virtual operator bool(); - using Print::write; - //void statusreport(); - // TODO: make private when socket allocation moves to EthernetClass - static uint16_t server_port[MAX_SOCK_NUM]; -}; class DhcpClass { diff --git a/src/RewriteServer.h b/src/RewriteServer.h new file mode 100644 index 0000000..8bd363e --- /dev/null +++ b/src/RewriteServer.h @@ -0,0 +1,33 @@ +/* + Server.h - Base class that provides Server + Copyright (c) 2011 Adrian McEwen. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef Rewriteserver_h +#define Rewriteserver_h + +#include "Print.h" + +class RewriteServer: public Print +{ +public: + // virtual void begin(uint16_t port=0) =0; + // error: cannot declare variable 'server' to be of abstract type 'EthernetServer' + void begin() {}; // Fix compiler error for EthernetWebServer, add by Michael. 2022-3-3 +}; + +#endif