I’m just starting with the HTTPClient (great lib btw, props) and I don’t see the serial messages on the Particle IDE (desktop, OSX).
I tried a basic program to make sure I’m actually getting ANY serial communication and I am just fine. I flashed the Photon with the HTTPClient www.timeapi.org example and nothing spits out on the serial monitor. My photon connects to the Particle Cloud just fine as well.
@bko, it doesn’t matter where I see the print statements but I was using the serial monitor that is included with the Particle IDE. It may not even be getting to the Serial.print statements and I will need to see where it’s getting hung up.
I was able to test this tonight using the CLI to compile for my Photon and it worked fine for me. I then turned on logging in the HTTPClient library and it continued to work fine, but like your code above, I didn’t call any http functions other than the constructor.
There is one thing I wanted to caution against: because of the order things happen in Particle firmware, you cannot have a Serial.print() call in the constructor of an object since the order of object construction is not predictable.
Have you added any Serial.print() statements to the libraries you are using?
Which version of the HttpClient library are you using?
Here is what I tried this morning and it worked for me:
I cut and pasted those exact libraries from the raw text (there’s a button on github) into files in a directory.
I used the same program I used before, copied here:
// This #include statement was automatically added by the Spark IDE.
#include "HttpClient.h"
int count = 0;
unsigned int nextTime = 0; // Next time to contact the server
HttpClient http;
// Headers currently need to be set at init, useful for API keys etc.
http_header_t headers[] = {
{ "Content-Type", "application/json" },
{ "Accept" , "application/json" },
{ "Accept" , "*/*"},
{ "User-agent", "Particle HttpClient"},
{ NULL, NULL } // Always terminate headers will NULL
};
http_request_t request;
http_response_t response;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.print(count++);
Serial.println("Hello there!");
delay(1000);
}