I'm trying to create a class that acts as a wrapper for managing various types of internet connections (Ethernet, WiFi, Cellular).
I got Cellular working, which was the hardest by far. But getting Ethernet is proving difficult as well. (The default Ethernet library uses blocking code which is horrible for my application)
Whenever I try to call connect(ip,port) inside my class, I get a compile-time error that says "invalid use of non-static member function".
I'd imagine it has to do with trying pass in data that can be deleted or otherwise non-static into a function that requires it to stick around. As much coding as I do in C++, I don't actually run into this issue terribly often, so I'm prepared for face-palms.
For reference, here is the class:
class CESEthernet : public CESCommSlot
bool sendPayload(String payload);
StopWatch GP_Timer = StopWatch(false);
And here is the method:
if (GP_Timer.start(itsNetConfig.RemoteTimeout)) //Initializes to RemoteTimeout when the timer initially starts
DebugMessage(DM_INFO, F("Web Connect"));
if (itsClient.connect(itsNetConfig.IPAddr.toCharArray, itsNetConfig.rPort))
DebugMessage(DM_INFO, F("Connected To ") + itsNetConfig.IPAddr + ":" + String(itsNetConfig.rPort));
itsState = ETH_DHCP;
DebugMessage(DM_ERROR, F("Connection Failed"));
Well yeah. I generally don't post something onto a forum unless I'm having trouble finding relevant information on google.
Can you post an MCVE (https://stackoverflow.com/help/mcve)?
OK so in the process, I found the issue.
I replaced "itsClient.connect(itsNetConfig.IPAddr.toCharArray" with a string literal. In this case, "Google.com".
guess I'll just have to figure out how to pass the desired website as a char array using some other method.
what you googled "C++ call static member" or somthing like that! I don't think you did. By the way if you look at my initial reply I gave you the answer.
In other words I told you
A. how to find the answer and
B. What the answer was ::