Guys,
i'm using the HttpClient to access some data on the web. In this case specifically i'm getting weather information from open weather.
String getWeatherData()
{
HttpClient client;
char charstep = 0;
typedef enum {STEP_TEMP, STEP_HUMI} TValueStep;
static const char openWeatherLink[] = "http://api.openweathermap.org/data/2.5/weather?q=Stevensville&mode=json&units=metric";
TValueStep valuestep = STEP_TEMP;
String tempValue = "";
String humidValue = "";
client.get(openWeatherLink);
while (client.available()) {
char c = client.read();
if ((charstep == 0) & (c == 't')) {
charstep++;
valuestep = STEP_TEMP;
}
else if ((charstep == 0) & (c == 'h')) {
charstep++;
valuestep = STEP_HUMI;
}
// read temp
else if (valuestep == STEP_TEMP) {
if ((charstep == 1) & (c == 'e')) charstep++;
else if ((charstep == 2) & (c == 'm')) charstep++;
else if ((charstep == 3) & (c == 'p')) charstep++;
else if ((charstep == 4) & (c == '"')) charstep++;
else if ((charstep == 5) & (c == ':')) charstep++;
else if (charstep == 6) {
if ((c != ',') && (c != '}')) tempValue += c;
else charstep++;
}
else charstep = 0;
}
// read humidity
else if (valuestep == STEP_HUMI) {
if ((charstep == 1) & (c == 'u')) charstep++;
else if ((charstep == 2) & (c == 'm')) charstep++;
else if ((charstep == 3) & (c == 'i')) charstep++;
else if ((charstep == 4) & (c == 'd')) charstep++;
else if ((charstep == 5) & (c == 'i')) charstep++;
else if ((charstep == 6) & (c == 't')) charstep++;
else if ((charstep == 7) & (c == 'y')) charstep++;
else if ((charstep == 8) & (c == '"')) charstep++;
else if ((charstep == 9) & (c == ':')) charstep++;
else if (charstep == 10) {
if ((c != ',') && (c != '}')) humidValue += c;
else charstep++;
}
else charstep = 0;
}
}
return (humidValue + "/" + tempValue);
}
The code above is working fine and feel free to use it :). Just change the word "Stevensville" to your city in the link.
The problem now is when i try to do something similar with google calendar that is a HTTPS connection.
Using HttpClient dont work at all. I noticed that Ethernet interface libraty have support for HTTPS but not Wifi.
Any idea how to do solve it?
Thanks!