I am just learning an Arduino so this is totally educational purpose call.
I want to instantiate PubSubClient client with WiFiClient parameter.
#include <WiFiClient.h>
#include <PubSubClient.h>
WiFiClient *wifi = NULL;
PubSubClient client(wifi);
void setup() {
// put your setup code here, to run once:
}
void loop() {
// put your main code here, to run repeatedly:
}
compilation gives me back:
Compilation error: no matching function for call to /home/tepo/Arduino/libraries/PubSubClient/src/PubSubClient.h:116:4: note: candidate expects 0 arguments, 1 provided
/home/tepo/Arduino/libraries/PubSubClient/src/PubSubClient.h:88:7: note: candidate: 'PubSubClient::PubSubClient(const PubSubClient&)'
class PubSubClient : public Print {
^~~~~~~~~~~~
/home/tepo/Arduino/libraries/PubSubClient/src/PubSubClient.h:88:7: note: no known conversion for argument 1 from 'WiFiClient*' to 'const PubSubClient&'
exit status 1
Compilation error: no matching function for call to 'PubSubClient::PubSubClient(WiFiClient*&)'
and listing all the other constructors.
type chain seems to hold:
class WiFiClient : public ESPLwIPClient -> class ESPLwIPClient : public Client -> class Client: public Stream
PubSubClient ctor:
PubSubClient(Client& client);
so why is it not accepting a WifiClient as a parameter?
PubSubClient client(*wifi);. it will compile, but it will just crash in runtime since there will be no WiFiClient object at address 0