Skip to content

Commit

Permalink
Merge pull request #14 from Qrome/1.6
Browse files Browse the repository at this point in the history
1.6
  • Loading branch information
Qrome authored May 4, 2018
2 parents e2bf2b2 + 24a4cac commit ddbb050
Show file tree
Hide file tree
Showing 2 changed files with 1,073 additions and 1,056 deletions.
19 changes: 18 additions & 1 deletion marquee/OpenWeatherMapClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ OpenWeatherMapClient::OpenWeatherMapClient(String ApiKey, int CityIDs[], int cit

void OpenWeatherMapClient::updateWeather() {
WiFiClient weatherClient;
String apiGetData = "GET /data/2.5/group?id=" + myCityIDs + "&units=" + units + "&cnt=1&APPID=" + myApiKey;
String apiGetData = "GET /data/2.5/group?id=" + myCityIDs + "&units=" + units + "&cnt=1&APPID=" + myApiKey + " HTTP/1.1";

Serial.println("Getting Weather Data");
Serial.println(apiGetData);
Expand All @@ -53,6 +53,23 @@ void OpenWeatherMapClient::updateWeather() {

Serial.println("Waiting for data");

// Check HTTP status
char status[32] = {0};
weatherClient.readBytesUntil('\r', status, sizeof(status));
Serial.println("Response Header: " + String(status));
if (strcmp(status, "HTTP/1.1 200 OK") != 0) {
Serial.print(F("Unexpected response: "));
Serial.println(status);
return;
}

// Skip HTTP headers
char endOfHeaders[] = "\r\n\r\n";
if (!weatherClient.find(endOfHeaders)) {
Serial.println(F("Invalid response"));
return;
}

while (weatherClient.connected() || weatherClient.available()) { //connected or data available
char c = weatherClient.read(); //gets byte from ethernet buffer
result = result+c;
Expand Down
Loading

0 comments on commit ddbb050

Please sign in to comment.