vshymanskyy / TinyGSM

A small Arduino library for GSM modules, that just works
GNU Lesser General Public License v3.0
1.91k stars 709 forks source link

It's not a bug, but can you help me to instance PubSubClient with TinyGsmClient OR WiFi ? #607

Open clabnet opened 2 years ago

clabnet commented 2 years ago

Hi, I have this class :

class MqttBackend : PubSubClient
{
public:
    MqttBackend(WiFiClient &wifiClient);
    MqttBackend(TinyGsmClient &gsmClient);
    ....

and the main class as is :

#include <MqttBackend.h>
class SASModem : public MqttBackend
{
private:
    TinyGsmClient &_gsmClient;

public:
    SASModem()
    {
        MqttBackend(&_gsmClient);
    }
    bool init();  \\ init the modem network connection
    bool close(); \\ close the modem connection
};

How to instanciate the PubSubClient passing it the gsmClient OR the WiFiClient ?

Thank's

SRGDamia1 commented 2 years ago

Have you figured this out? I think you might be looking for an initialization list in your class constructor.