| 83 | } |
| 84 | |
| 85 | bool UpdateManager_::checkUpdate(bool withScreen) |
| 86 | { |
| 87 | if (withScreen) |
| 88 | { |
| 89 | DisplayManager.clear(); |
| 90 | DisplayManager.resetTextColor(); |
| 91 | DisplayManager.printText(0, 6, "CHECK", true, true); |
| 92 | DisplayManager.show(); |
| 93 | } |
| 94 | |
| 95 | String payload; |
| 96 | int httpCode = -1; // Setzen Sie den Standardwert auf einen ungültigen HTTP-Code |
| 97 | String fwurl = ""; |
| 98 | fwurl += URL_fw_Version; |
| 99 | fwurl += "?"; |
| 100 | fwurl += String(rand()); |
| 101 | if (DEBUG_MODE) DEBUG_PRINTLN(F("Check firmwareversion")); |
| 102 | |
| 103 | static WiFiClientSecure client; // Statische Variable |
| 104 | |
| 105 | client.setCACert(rootCACertificate); |
| 106 | HTTPClient https; |
| 107 | |
| 108 | if (https.begin(client, fwurl)) |
| 109 | { // HTTPS |
| 110 | delay(100); |
| 111 | httpCode = https.GET(); |
| 112 | delay(100); |
| 113 | if (httpCode == HTTP_CODE_OK) // if version received |
| 114 | { |
| 115 | payload = https.getString(); // save received version |
| 116 | } |
| 117 | else |
| 118 | { |
| 119 | if (DEBUG_MODE) DEBUG_PRINTLN(F("Error in downloading version file")); |
| 120 | if (withScreen) |
| 121 | { |
| 122 | DisplayManager.clear(); |
| 123 | DisplayManager.resetTextColor(); |
| 124 | DisplayManager.printText(0, 6, "ERR CNCT", true, true); |
| 125 | DisplayManager.show(); |
| 126 | delay(1000); |
| 127 | } |
| 128 | } |
| 129 | https.end(); |
| 130 | } |
| 131 | |
| 132 | if (httpCode == HTTP_CODE_OK) // if version received |
| 133 | { |
| 134 | payload.trim(); |
| 135 | if (payload.equals(VERSION)) |
| 136 | { |
| 137 | UPDATE_AVAILABLE = false; |
| 138 | if (DEBUG_MODE) DEBUG_PRINTF("\nDevice already on latest firmware version: %s\n", VERSION); |
| 139 | if (withScreen) |
| 140 | { |
| 141 | DisplayManager.clear(); |
| 142 | DisplayManager.resetTextColor(); |
no test coverage detected