void IRAM_ATTR interruptHandler() { detachInterrupt(UPDATE_PIN); Serial.println("Let's do cloud magic!"); // Start cloud update airUpdater.start(); }
void onRequestSent(HttpClient& client, bool successful) { if (successful) { debugf("Update check successful."); StaticJsonBuffer<200> jsonBuffer; String response = client.getResponseString(); char json[response.length() + 1];// Add 1 char space for null strcpy(json, response.c_str()); JsonObject& root = jsonBuffer.parseObject(json); if (root != root.invalid()) { const char* version = root["version"]; if (strcmp(version, AppSettings.version.c_str()) == 0) { debugf("No new version available."); } else { debugf("New version available. Staging files..."); JsonArray& files = root["files"]; for (int i = 0; i < 10; i++) { JsonObject& file = files[i]; if (file == file.invalid()) break; // We're at the end of the file list int address = file["address"]; const char* url = file["url"]; // Configure cloud update airUpdater.addItem(address, url); debugf("Staging file %i from %s.", address, url); } debugf("Update files staged. Starting update..."); airUpdater.start(); } } } else { debugf("Update check failed."); } }