我正在调整现有库(“Webduino”,Arduino 的网络服务器)以与另一个现有库(“WiFly”,wifi 模块)一起使用并遇到问题。每个库都可以独立运行。Webduino 库希望通过 SPI 使用以太网硬件模块,而 WiFi 模块使用串行端口 (UART)。我得到的错误是:
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
以下是相关的代码片段。请注意,到目前为止,我只修改了 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.
*/
...
}
问题源于m_client = m_server.available();
,如果我评论说问题消失了(但整个事情都依赖于那条线)。实际的问题似乎是 _WiFly 成员在分配 WiFiClient 对象时无法初始化(覆盖?),但我不明白为什么它在没有修改的情况下在这里不起作用。
(是的,我知道头文件中有实现,我不知道他们为什么这样写,不要怪我!)
有什么见解吗?