How to fix “no matching function call to 'HTTPSRedirect::printRedir(String&, con

I am not sure if you can help me but following How to post data to Google sheets using ESP8266 | Embedded Lab . Complete code attached.

I have updated the HttpsRedirect library as requested in the tutorial but now I get the following when verifying the code:

/home/test/Dropbox/Transfer/WorkingOn/WeatherStation - Dad/WeatherStationBMP280-GSheets/WeatherStationBMP280-GSheets.ino: In function 'void postData(String, float)': WeatherStationBMP280-GSheets:90:52: error: no matching function for call to 'HTTPSRedirect::printRedir(String&, const char*&, const char*&)' client.printRedir(urlFinal, host, googleRedirHost); ^

/home/test/Dropbox/Transfer/WorkingOn/WeatherStation - Dad/WeatherStationBMP280-GSheets/WeatherStationBMP280-GSheets.ino:90:52: note: candidate is: In file included from /home/test/Dropbox/Transfer/WorkingOn/WeatherStation - Dad/WeatherStationBMP280-GSheets/WeatherStationBMP280-GSheets.ino:9:0: /home/test/Arduino/libraries/HTTPSRedirect/HTTPSRedirect.h:48:10: note: bool HTTPSRedirect::printRedir() bool printRedir(void);
^

/home/test/Arduino/libraries/HTTPSRedirect/HTTPSRedirect.h:48:10: note: candidate expects 0 arguments, 3 provided exit status 1 no matching function for call to 'HTTPSRedirect::printRedir(String&, const char*&, const char*&)'

The HTTPSRedirect Library is taken from: ESP8266/HTTPSRedirect at master · electronicsguy/ESP8266 · GitHub. I am not sure how to change the code below to accommodate the updated library.

This is the call where this issue is happening

void postData(String tag, float value) {
  if (!client.connected()) {
    Serial.println("Connecting to client again…");
    client.connect(host, httpsPort);
  }
  String urlFinal = url + "tag = " + tag + "&value = " + String(value);
  client.printRedir(urlFinal, host, googleRedirHost); //This is the line where the error is highlighted
}

My declarations are as follows:

const char* googleRedirHost = "script.googleusercontent.com";

const int httpsPort =     443;
HTTPSRedirect client(httpsPort);

// Prepare the url (without the varying data)
String url = String(" / macros / s / ") + GScriptId + " / exec ? ";```

WeatherStationBMP280-GSheets.ino (2.66 KB)

I have updated the HttpsRedirect library as requested in the tutorial

Please be more specific. Exactly where does that tutorial tell you to "update" the library? Exactly what changes did you make?

Hi, the tutorials says the following

Update: The above library is outdated.

Please go to GitHub Sujay Phadke and download the updated library. Thanks Sujay.

In order to install it on your machine, simply download the above zipped file, unzip it, and move the folder named HTTPSRedirect into your Arduino’s libraries location. On Windows PC, it typically goes to C:\Users\Documents\Arduino\libraries\ .
Arduino IDE Library Path

Make sure both HTTPSRedirect.cpp and HTTPSRedirect.h files exist inside the copied library folder as shown above.

I did this. There is no further talk of making changes to the code so I simply used the code that the tutorial provides.

Good old Sujay Phadke decided to change the API of the library since that tutorial was written, making it no longer compatible with the code in the tutorial. You have three options:

  • Use the old version of the library provided by that tutorial.
  • Search back through the commit history of Sujay's repository until you find the newest working version of the library that is still compatible with the tutorial code (a process that will be unnecessarily difficult due to Sujay's poor commit discipline).
  • Modify the code so that it works with the latest version of the library.
1 Like

Hello,

@zululander - Please use only the latest version of HTTPSRedirect library and the latest version of esp8266 library (which of today is 2.5.0)

@pert - I work on my library code independently. Unfortunately, due to my regular work constraints, 3rd party tutorials are not something I can keep my code in sync with. Yes API changes happen, sometimes with no backward compatibility. Part of DIY is to learn how to transition to software changes. I'm happy to help out in any way I can, when I get the time.

Now lets come to the HTTPSRedirect library usage:
The tutorial is not written by me and I've no connection with them. So I cannot go and change it.

"printRedir" from the old version of HTTPSRedirect will not work directly. You need to use "GET" and "POST" methods. Please read the project Readme (Sec. II(b)) and go through the example Arduino code to understand the basics of the usage.

Please pay attention to Sec. III(d) of the Readme.

I used to latest version of HTTPSRedirect alongwith v2.5.0 of esp8266 library in Arduino and flashed successfully. It's able to connect to Google sheets and read/write. Here's the output log:

Free heap: 46424
Free stack: 3916

Connecting to wifi: ***
........
WiFi connected
IP address:
192.168.0.115
Connecting to script.google.com

GET: Write into cell 'A1'

Successfully wrote: Hello
into spreadsheet.

GET: Fetch Google Calendar Data:

Event Title, Description, Recurring?, All-day?, First Reminder (in minutes before event)
Buy dress, Need to buy daughter's dress, true, true, 600
Get car serviced, Need to get my car checked and oil filter replaced, true, true, 720
Send emails, Need to send important emails, true, true, 900

Series of GET and POST requests

Free heap: 14768
Free stack: 1616
GET Data from cell 'A1':
Hello

POST append memory data to spreadsheet:
Success

GET Data from cell 'A1':
Hello

=============================================================

@zululander - Please work with the code and example I've posted on the Github project page. Are you able to successfully use it as-is? If not, please open an issue on the Github page with the relevant details.

I've seen connection errors happen randomly with some wifi AP. Please use another wifi AP and try if the error persists.

If you are able to use that successfully, then you can work on integrating it with the other project on the page you've linked.

Thanks.

Sujay Phadke

1 Like

electronicsguy:
3rd party tutorials are not something I can keep my code in sync with.

Of course, it would be unreasonable for anyone to expect that of you.

electronicsguy:
Yes API changes happen, sometimes with no backward compatibility.

Breaking changes to the API are unfortunate, but sometimes necessary. The important thing is to clearly communicate this to the user when it does happen. One effective way to communicate API changes is by following the semver specification in versioning. I see some efforts at versioning in your library, but it could be improved. It's currently very difficult to see the versioning history of the library. This can be made very easy by the use of either Git tags or GitHub releases. Unfortunately, your repository does not lend itself well to that because you have multiple projects sharing the same repository and tags/releases apply to the entire repository. GitHub provides unlimited repositories for free so there is really no good reason to put multiple separate projects in one repository. Having the library in a subfolder of the repository also makes it more difficult to install, since the user can't use the popular "Add .ZIP Library" installation method with the .zip file downloaded from GitHub. It also makes the repository incompatible with the Arduino Library Manager, which provides an even easier method for library installation and updates.

@electronicsguy, thanks for your patience. I dumped the 3rd party tutorial and worked through you documentation and all works as it should.

@Zululander - great :slight_smile: If you face any more issues, please open an issue on Github directly.

@pert - This library is not a self-contained system like a full firmware or an OS and hence versioning is meaningless here. People must use only the latest version.

The change in API is communicated right at the top in the Readme so it is pretty clear.

Github's limitation of not supporting folders for repos is sad indeed. But I will make separate repos in the future.

@Zululander Any chance posting your fixed code?

I would like to compare your old vs new, to see if It could help me fix my existing script.