I'm adapting an existing library ("Webduino", a web server for Arduino) to work with another existing library ("WiFly", a wifi module) and running into a problem. Each library works fine on its own. The Webduino library expects to use an Ethernet hardware module over SPI, whereas the WiFi module uses a serial port (UART). The error I get is:
WiFlyClient.h: In member function 'WiFlyClient& WiFlyClient::operator=(const WiFlyClient&)':
WiFlyClient.h:14:
error: non-static reference member 'WiFlyDevice& WiFlyClient::_WiFly', can't use default assignment operator
WiFlyWebServer.h: In member function 'void WebServer::processConnection(char*, int*)':
WiFlyWebServer.h:492: note: synthesized method 'WiFlyClient& WiFlyClient::operator=(const WiFlyClient&)' first required here
Here are the relevant code snippets. Note that so far I have only been modifying WiFlyWebServer.h (Webduino):
// WiFlyWebServer.h (Webduino)
...
WiFlyServer m_server; // formerly EthernetServer and
WiFlyClient m_client; // EthernetClient
...
void WebServer::processConnection(char *buff, int *bufflen){
...
// line 492
m_client = m_server.available();
...
}
// WiFlyClient.h
class WiFlyClient : public Client {
public:
WiFlyClient();
...
private:
WiFlyDevice& _WiFly;
...
}
// WiFlyClient.cpp
#include "WiFly.h"
#include "WiFlyClient.h"
WiFlyClient::WiFlyClient() :
_WiFly (WiFly) { // sets _wiFly to WiFly, which is an extern for WiFlyDevice (WiFly.h)
...
}
// WiFly.h
#include "WiFlyDevice.h"
...
extern WiFlyDevice WiFly;
...
// WiFlyDevice.h
class WiFlyDevice {
public:
WiFlyDevice(SpiUartDevice& theUart);
...
// WiFlyDevice.cpp
WiFlyDevice::WiFlyDevice(SpiUartDevice& theUart) : SPIuart (theUart) {
/*
Note: Supplied UART should/need not have been initialised first.
*/
...
}
The problem stems from m_client = m_server.available();
, if I comment that out the problem goes away (but the whole thing relies on that line). The actual problem seems to be that the _WiFly member can't be initialized (overwritten?) when the WiFiClient object is being assigned, but I can't understand why it doesn't work here when it does work without modification.
(Yes, I know there's implementation in the header file, I don't know why they wrote it that way, don't blame me!)
Any insights?