I’m just tinkering with my new Photon and need to use the the httpclient library from the build.particle.cc library.
I copy the example code to my work space (in build) but the example code will not compile. I’ve made no changes to it.
the final error seems to be:
application.cpp:2:24: fatal error: HttpClient.h: No such file or directory
is it possible the library is not in my workspace? How could I check?
[Update] So i got the “Include in App” function to work this time and it included the library as “HttpClient/HttpClient.h” and the example app will verify, but when I try to flash it to my Proton I get a couple errors that say the functions mills() and delay are not defined in this scope. Well that seems odd…
Man, for one of (if not “THE”) most popular lib out there, the fact that the author has not yet fixed it is insane. It was literally a one line fix for me, but also means that I cant use the web ide. Hoepfully he will fix this soon.
If the library worked on the core, and it’s only using our public API then it’s an issue in the firmware. I seem to recall that millis() had the wrong linkage (C++ instead of C) which caused problems in libraries that were redeclaring this function.
Here is the error report when I try to compile the example HTTPClient example for my Photon:
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaHttpClient/HttpClient.cpp: In member function 'void HttpClient::request(http_request_t&, http_response_t&, http_header_t*, const char*)':
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaHttpClient/HttpClient.cpp:172:37: error: 'millis' was not declared in this scope
unsigned long lastRead = millis();
^
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaHttpClient/HttpClient.cpp:231:22: error: 'delay' was not declared in this scope
delay(200);
^
/spark/compile_service/shared/workspace/6_hal_12_0/firmware-privaHttpClient/HttpClient.cpp:266:47: error: 'atoi' was not declared in this scope
aResponse.status = atoi(statusCode.c_str());
^
make[1]: *** [../build/target/user/platform-6HttpClient/HttpClient.o] Error 1
make: *** [user] Error 2
Please use this format to paste code in discourse:
``` <-- insert this
//paste code here
``` <-- insert this
@bleddy I think I see your problem: you need to use Particle Dev because you apparently can’t modify library code from build. Or else I don’t know how…
@leon When you say you imported it, you used the HttpClient version from the particle.io web site? or did you clone it from github? Also, did you compile and flash it? If you just use the check compile, it doesn’t complain about the missing libraries.
I just tried compiling and flashing the example app from the HttpClient library on particle.io and I get the same compile error referred to in previous comments (missing library for millis etc). When I import the library from github, it compiles and flashes without error.
@Leon thanks.
I figure out in the end. It works well with the Core, but I have some problems with the Photon - it stuck as soon as it enters the loop. Do you have any problem with it?
I have tried using the code from GitHub, but I still get compile issues. Is it as simple a creating a new tab and copying the code into it from GitHub? I am using the Build IDE on Particle.io OR does cloning from GitHub mean something else?
I am writing a program to just go to a google form URL. I don’t need to have any data transfered back, as just requesting the URL from google inputs and submits the data to a spreadsheet.