Skip to content

Commit

Permalink
Fix RAK11200 compile error
Browse files Browse the repository at this point in the history
  • Loading branch information
beegee-tokyo committed Mar 8, 2022
1 parent 3b25196 commit 8be0236
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 17 deletions.
62 changes: 45 additions & 17 deletions src/RAK13800_W5100S.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@

#include <Arduino.h>
#include "Client.h"
#include "Server.h"
#include "Udp.h"

#ifdef _VARIANT_RAK11200_
#include "RewriteServer.h"
#else
#include "Server.h"
#endif

enum EthernetLinkStatus {
Unknown,
LinkON,
Expand Down Expand Up @@ -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 {
Expand Down
33 changes: 33 additions & 0 deletions src/RewriteServer.h
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 8be0236

Please sign in to comment.