mirror of
https://github.com/OpenEPaperLink/OpenEPaperLink.git
synced 2026-03-21 15:06:38 +01:00
fix AP not responding + add more logs to investigate crashes
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
#include <ArduinoJson.h>
|
||||
#include <HTTPClient.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "web.h"
|
||||
|
||||
namespace util {
|
||||
@@ -72,6 +73,7 @@ static void printLargestFreeBlock() {
|
||||
static bool httpGetJson(String &url, JsonDocument &json, const uint16_t timeout, JsonDocument *filter = nullptr) //, const followRedirects_t redirects = followRedirects_t::HTTPC_DISABLE_FOLLOW_REDIRECTS)
|
||||
{
|
||||
HTTPClient http;
|
||||
logLine("http httpGetJson " + url);
|
||||
http.begin(url);
|
||||
http.setTimeout(timeout);
|
||||
// http.setFollowRedirects(redirects);
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#endif
|
||||
#include "language.h"
|
||||
#include "settings.h"
|
||||
#include "system.h"
|
||||
#include "tag_db.h"
|
||||
#include "truetype.h"
|
||||
#include "util.h"
|
||||
@@ -870,6 +871,7 @@ int getImgURL(String &filename, String URL, time_t fetched, imgParam &imageParam
|
||||
Storage.begin();
|
||||
|
||||
HTTPClient http;
|
||||
logLine("http getImgURL " + URL);
|
||||
http.begin(URL);
|
||||
http.addHeader("If-Modified-Since", formatHttpDate(fetched));
|
||||
http.addHeader("X-ESL-MAC", MAC);
|
||||
@@ -975,6 +977,7 @@ bool getCalFeed(String &filename, String URL, String title, tagRecord *&taginfo,
|
||||
strftime(dateString, sizeof(dateString), "%d.%m.%Y", &timeinfo);
|
||||
|
||||
HTTPClient http;
|
||||
logLine("http getCalFeed " + URL);
|
||||
http.begin(URL);
|
||||
http.setTimeout(10000);
|
||||
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||
@@ -1077,6 +1080,7 @@ uint8_t drawBuienradar(String &filename, JsonObject &cfgobj, tagRecord *&taginfo
|
||||
|
||||
String lat = cfgobj["#lat"];
|
||||
String lon = cfgobj["#lon"];
|
||||
logLine("http drawBuienradar");
|
||||
http.begin("https://gps.buienradar.nl/getrr.php?lat=" + lat + "&lon=" + lon);
|
||||
http.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS);
|
||||
http.setTimeout(5000);
|
||||
@@ -1338,6 +1342,7 @@ bool getJsonTemplateFileExtractVariables(String &filename, String jsonfile, Json
|
||||
int getJsonTemplateUrl(String &filename, String URL, time_t fetched, String MAC, tagRecord *&taginfo, imgParam &imageParams) {
|
||||
HTTPClient http;
|
||||
http.useHTTP10(true);
|
||||
logLine("http getJsonTemplateUrl " + URL);
|
||||
http.begin(URL);
|
||||
http.addHeader("If-Modified-Since", formatHttpDate(fetched));
|
||||
http.addHeader("X-ESL-MAC", MAC);
|
||||
|
||||
@@ -239,6 +239,7 @@ void prepareExternalDataAvail(struct pendingData* pending, IPAddress remoteIP) {
|
||||
String imageUrl = "http://" + remoteIP.toString() + filename;
|
||||
wsLog("GET " + imageUrl);
|
||||
HTTPClient http;
|
||||
logLine("http prepareExternalDataAvail " + imageUrl);
|
||||
http.begin(imageUrl);
|
||||
int httpCode = http.GET();
|
||||
if (httpCode == 200) {
|
||||
@@ -250,6 +251,7 @@ void prepareExternalDataAvail(struct pendingData* pending, IPAddress remoteIP) {
|
||||
} else if (httpCode == 404) {
|
||||
imageUrl = "http://" + remoteIP.toString() + "/current/" + String(hexmac) + ".raw";
|
||||
http.end();
|
||||
logLine("http prepareExternalDataAvail " + imageUrl);
|
||||
http.begin(imageUrl);
|
||||
httpCode = http.GET();
|
||||
if (httpCode == 200) {
|
||||
@@ -296,6 +298,7 @@ void prepareExternalDataAvail(struct pendingData* pending, IPAddress remoteIP) {
|
||||
String dataUrl = "http://" + remoteIP.toString() + "/getdata?mac=" + String(hexmac);
|
||||
wsLog("GET " + dataUrl);
|
||||
HTTPClient http;
|
||||
logLine("http DATATYPE_CUSTOM_LUT_OTA " + dataUrl);
|
||||
http.begin(dataUrl);
|
||||
int httpCode = http.GET();
|
||||
if (httpCode == 200) {
|
||||
|
||||
@@ -288,7 +288,7 @@ bool sendPing() {
|
||||
Serial.print("ping");
|
||||
int t = millis();
|
||||
if (!txStart()) return false;
|
||||
for (uint8_t attempt = 0; attempt < 5; attempt++) {
|
||||
for (uint8_t attempt = 0; attempt < 3; attempt++) {
|
||||
cmdReplyValue = CMD_REPLY_WAIT;
|
||||
AP_SERIAL_PORT.print("RDY?");
|
||||
if (waitCmdReply()) {
|
||||
@@ -681,11 +681,7 @@ bool bringAPOnline() {
|
||||
// try without rebooting
|
||||
AP_SERIAL_PORT.updateBaudRate(115200);
|
||||
uint32_t bootTimeout = millis();
|
||||
bool APrdy = false;
|
||||
while ((!APrdy) && (millis() - bootTimeout < 3 * 1000)) {
|
||||
APrdy = sendPing();
|
||||
vTaskDelay(300 / portTICK_PERIOD_MS);
|
||||
}
|
||||
bool APrdy = sendPing();
|
||||
if (!APrdy) {
|
||||
if (apInfo.state == AP_STATE_FLASHING) return false;
|
||||
APTagReset();
|
||||
@@ -761,10 +757,10 @@ void APTask(void* parameter) {
|
||||
ShowAPInfo();
|
||||
|
||||
if (apInfo.type == SOLUM_SEG_UK) {
|
||||
setAPstate(false, AP_STATE_COMING_ONLINE);
|
||||
setAPstate(true, AP_STATE_COMING_ONLINE);
|
||||
segmentedShowIp();
|
||||
showAPSegmentedInfo(apInfo.mac, true);
|
||||
setAPstate(false, AP_STATE_ONLINE);
|
||||
setAPstate(true, AP_STATE_ONLINE);
|
||||
updateContent(apInfo.mac);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ void initTime(void* parameter) {
|
||||
sntp_set_time_sync_notification_cb(timeSyncCallback);
|
||||
sntp_set_sync_interval(300 * 1000);
|
||||
configTzTime(config.timeZone, "nl.pool.ntp.org", "europe.pool.ntp.org", "time.nist.gov");
|
||||
logStartUp();
|
||||
struct tm timeinfo;
|
||||
while (millis() < 30000) {
|
||||
if (!getLocalTime(&timeinfo)) {
|
||||
@@ -25,7 +26,6 @@ void initTime(void* parameter) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
logStartUp();
|
||||
if (config.runStatus = RUNSTATUS_INIT) config.runStatus = RUNSTATUS_RUN;
|
||||
vTaskDelay(10 / portTICK_PERIOD_MS);
|
||||
vTaskDelete(NULL);
|
||||
@@ -43,6 +43,7 @@ void logLine(const String& text) {
|
||||
const char* format = (now < (time_t)1672531200) ? " %H:%M:%S " : "%Y-%m-%d %H:%M:%S ";
|
||||
strftime(timeStr, sizeof(timeStr), format, localtime(&now));
|
||||
|
||||
xSemaphoreTake(fsMutex, portMAX_DELAY);
|
||||
File logFile = contentFS->open("/log.txt", "a");
|
||||
if (logFile) {
|
||||
if (logFile.size() >= 10 * 1024) {
|
||||
@@ -57,6 +58,7 @@ void logLine(const String& text) {
|
||||
logFile.println(text);
|
||||
logFile.close();
|
||||
}
|
||||
xSemaphoreGive(fsMutex);
|
||||
}
|
||||
|
||||
void logStartUp() {
|
||||
|
||||
Reference in New Issue
Block a user