I’m getting this error when compiling and was hoping I could get a little guidance:
In file included from …/inc/spark_wiring.h:30:0,
from application.h:31,
from Adafruit_CharacterOLED.h:4,
from Adafruit_CharacterOLED.cpp:7:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
Adafruit_CharacterOLED.cpp: In member function ‘virtual size_t Adafruit_CharacterOLED::write(uint8_t)’:
Adafruit_CharacterOLED.cpp:243:1: warning: no return statement in function returning non-void [-Wreturn-type]
In file included from …/inc/spark_wiring.h:30:0,
from …/inc/spark_wiring_tcpclient.h:29,
from HttpClient.h:5,
from HttpClient.cpp:1:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
In file included from …/inc/spark_wiring.h:30:0,
from application.h:31,
from Weather.h:19,
from Weather.cpp:2:
…/…/core-common-lib/SPARK_Firmware_Driver/inc/config.h:12:2: warning: #warning “Defaulting to Release Build” [-Wcpp]
Weather.cpp: In member function ‘weather_response_t Weather::update()’:
Weather.cpp:23:16: error: ‘class HttpClient’ has no member named 'init’
Weather.cpp:24:54: error: no matching function for call to 'HttpClient::get(http_request_t&)'
Weather.cpp:24:54: note: candidates are:
In file included from application.h:45:0,
from Weather.h:19,
from Weather.cpp:2:
HttpClient.h:71:22: note: http_response_t* HttpClient::get(http_request_t*)
HttpClient.h:71:22: note: no known conversion for argument 1 from ‘http_request_t’ to 'http_request_t*'
HttpClient.h:91:22: note: http_response_t* HttpClient::get(http_request_t*, http_header_t*)
HttpClient.h:91:22: note: candidate expects 2 arguments, 1 provided
make: *** [Weather.o] Error 1
ross, is this an arduino library you are porting? It is difficult to understand the output without seeing the actual code. A little more information might help.
Hah of course. No I’m not porting anything, I’m basically just trying to get this to run before I can modify it for my project:
I messaged the author about it and he wasn’t sure about the error I was getting and suggested I make a post about it.
I’ve added in all of the libraries that are included in the “Full Usage Example” at the bottom of that page. Those being: Adafruit_CharacterOLED, weather(included on that github page), HttpClient.and application.
I can get them to all compile individually, but get the above error when I pull it all together for the app.
I have not really worked with either of the HttpClient or Weather libraries, yet.
But by reading your error output
I had a look at the source of those libs and there actually is no "init" methode in the HttpClient, which Weather lib tries to call in its "update" function.
I also don't quite see why this would be necessary in there, since the HttpClient should have been initialized - in its constructor call - before it was passed over to Weather.update(). Maybe you just try to comment out this code line.
aRequest is expected to be a pointer to http_request_t but is passed in as a http_request_t.
On the other hand I might make a complete fool of me if someone who has actually worked with these libs has had no problem with what I see as error.
But then I can at least correct my own misconceptions
Looking at the yahoo-weather code and the HttpClient code (referenced in readme.md of Weather lib), I’d guess that the current version of HttpClient does not fit the one used when yahoo-weather was built.
As mentioned above, I can’t find a HttpClient.init methode and as just realized I can’t even find a HttpClient constructor that does not take any parameters, which would be required to have the sample code working, that is given in the readme.md
Annotated code snipped:
void setup() {
httpClient = new HttpClient(); // <-- I can't find a constructor taking no parameters in HttpClient.cpp
lcd = new Adafruit_CharacterOLED(...);
// weather
weather.init("781788", httpClient); // <-- if HttpClient was constructed with host, call to non existent HttpClient.init() would not be required within Weather.init().
weatherCache.init(&weather);
}
@kennethlimcp, Weather lib is linked in the third post and HttpClient in the readme.md of Weather lib.
Guys, thanks so much for the help. This community is amazing.
I changed this, as @ScruffR mentioned earlier and used Coffee's updated example code
I've been beating my head against this for a little while now. I've got it down to these two errors:
Weather.cpp: In member function 'weather_response_t Weather::update()':
Weather.cpp:23:16: error: 'class HttpClient' has no member named 'init'
Weather.cpp:24:55: error: conversion from 'http_response_t*' to non-scalar type 'http_response_t' requested
make: *** [Weather.o] Error 1
@ross,
you might have missed this in @Coffee 's (aka synox) answer.
He has already updated his sample code in the readme.md to this
void setup() {
httpClient = new HttpClient("781788", httpClient); // <-- this is important now
// <-- although I think it should rathter be
// <-- new HttpClient("query.yahooapis.com", 80);
// (comment by Scruff.R)
lcd = new Adafruit_CharacterOLED(...);
// weather
weather.init("781788", &httpClient, true); // <--
// <-- I guess this is also missing in the readme.md, to make it work
// (comment by Scruff.R)
weatherCache.init(&weather);
}
Once you have constructed the HttpClient this way just change the line
this->client->init("query.yahooapis.com", 80);
in yahoo_weather.cpp Weather::update() to this
// this->client->init("query.yahooapis.com", 80);
since it's still there in the current version of yahoo_weather.
And for the second error, I'm sorry I gave you a bad clue.
I had put in the correct declaration of get - which returns a pointer to a http_response_t - but I have just copied the call from Weather::update without looking propperly, since this assumes that get returns a http_response_t rather than a pointer.
So the correct version should look like this (Edit: corrected in previous post for future readers)
And since response is now a pointer and not a http_response_t you will have to change any reference to it accordingly (e.g. response.status into response->status and response.body to response->body).
I am sorry, I missed to build it against the correct version of http-client. let me fix and test that before you go on. @ScruffR Thanks for pointing out my error.
I just released a new version of the HttpClient that is hopefully more easy to use, and more stable to run (no promises that it’s perfect, but it’s better than it was).
You can find it here:
It doesn’t require any initialisation anymore and has an empty constructor so for this example it should work pretty well.
I am updating the library to use http://openweathermap.org/API instead, i will publish it as soon it is fully tested and httpclient has all the features required.
I added @Coffee’s chunked read implementation to HttpClient and will be making some minor changes today for style, but the functionality should be in place now!