1

I've visited this forum many many many times, but this is my actual first post here. Usually I can find my answer here and I guess I've probably found it this time, but this time my knowledge is lacking to understand the solutions given (been learning C++ for the last 2 weeks).

The error I get:

no matching function for call to 'WidgetBridge::WidgetBridge()'

an extraction of my (rather lengthy) code:

class Room {
private:

  //initializer list of internal objects
  WidgetBridge bridge_thermostat;
  WidgetBridge bridge_relay;

public:
  //Constructor of the class:
  Room() : bridge_thermostat(V100), bridge_relay(V107){}

  void initBridges(String authThermostat, String authRelay){
      bridge_thermostat.setAuthToken(authThermostat);
      bridge_relay.setAuthToken(authRelay);
  }

  void receiveCurrentT(float param){
    currentT = param;
    Blynk.virtualWrite(V10, currentT);
    timer.restartTimer(thermostatTimer );          //reset isDead timer for thermostat
    Blynk.setProperty(V17, "color", BLYNK_GREEN);    //change LED color
    Blynk.virtualWrite(V17, 200);
  }
} livingRoom;

BLYNK_CONNECTED() {
  Blynk.syncAll();
  livingRoom.initBridges("xxx", "xxxx");  //auth of: thermostat, relay
}
BLYNK_WRITE(V10){ livingRoom.receiveCurrentT(param.asFloat());        } //receive currentT from thermostat

Based on the answers I've found on this forum it appears that WidgetBridge doens't have its own constructor when called. Based on the answers given I've also tried:

public:
    //Constructor of the class:
  Room() : {
    bridge_thermostat = V100;
    bridge_relay = V107;
  }

but that rendered the same error. I've continued reading about static fields, constructors, namespaces, etc. but bottomline: I'm stuck and I don't know how to fix this.

Additional info: code is for an esp8266 arduino wifi module which communicates with other esp8266's (relay and thermostat). The communication takes place through 'bridges' which are created using code from the Blynk app.

Thank you for your time!

UPDATE: I've finally found the actual calss widgetbridge itself. And from the mentioned solution I gathered that it has no constructor of itself, but it does..so now I'm really lost. Here's part of the widget class:

class WidgetBridge
    : private BlynkWidgetBase
{
public:
    WidgetBridge(uint8_t vPin)
        : BlynkWidgetBase(vPin)
    {}

    void setAuthToken(const char* token) {
        char mem[BLYNK_MAX_SENDBYTES];
        BlynkParam cmd(mem, 0, sizeof(mem));
        cmd.add(mPin);
        cmd.add("i");
        cmd.add(token);
        Blynk.sendCmd(BLYNK_CMD_BRIDGE, 0, cmd.getBuffer(), cmd.getLength()-1);
    }
(....)
};
Wolph42
  • 11
  • 3
  • 1
    Your first constructor should not cause that error, but the second one should. The error message should also indicate a location in the source that it refers to. Please share what it is. – molbdnilo Apr 09 '18 at 10:28
  • not sure what you're exactly looking for, but here's the full error report: https://www.dropbox.com/s/fol1cplf16iq369/errorResult.txt?dl=0 – Wolph42 Apr 09 '18 at 13:22
  • `Room() : targetT(20), currentT(20), heatOn(false), maintenanceOn(false) errorOn(false)` this is not the code you're showing. – O'Neil Apr 23 '18 at 12:16

1 Answers1

0

From the code extract you posted (partial) and the error message(partial too...) , the only reasonable answer is that the WidgetBridge class as no default constructor (i.e. constructor with 0 argument).

Probably because the base class BlynkWidgetBase has no default constructor as well.

So you get compiler errors on those lines

  //initializer list of internal objects
  WidgetBridge bridge_thermostat;
  WidgetBridge bridge_relay;

You can either implement a WidgetBride default constructor or instanciate those two variables with the constructor taking a uint8_t parameter :

  //initializer list of internal objects
  WidgetBridge bridge_thermostat(3); 
  WidgetBridge bridge_relay(4);

3 and 4 to be replaced by whatever value that makes sense, but only you can know that from the code extract

sandwood
  • 2,038
  • 20
  • 38