diff --git a/lib/download/download.cpp b/lib/download/download.cpp index 5d52aa6..4a85fac 100644 --- a/lib/download/download.cpp +++ b/lib/download/download.cpp @@ -3,9 +3,7 @@ #include "download.h" #include "device.h" -HTTPClient http; - -bool downloadFile(String url, const char *path) +bool downloadFile(String url, const char *path, const char* CAcert) { // @note duration time: 200kb = 35sec write to flash Serial.println("Download file: " + url); @@ -25,14 +23,20 @@ bool downloadFile(String url, const char *path) return false; } + HTTPClient http; http.useHTTP10(true); // http1.1 chunked is not working correctly http.setTimeout(7000); - http.setUserAgent("paperdash esp"); + http.setUserAgent("paperdash-epd"); // use the last 8 bytes of the unique serial id http.addHeader("X-PaperDash-Id", DeviceId); - http.begin(url); + if (CAcert) { + http.begin(url, CAcert); + } else { + http.begin(url); + } + int httpCode = http.GET(); if (httpCode != HTTP_CODE_OK) { @@ -58,4 +62,10 @@ bool downloadFile(String url, const char *path) http.end(); return !hasError; +} + + +bool downloadFile(String url, const char *path) +{ + return downloadFile(url, path, NULL); } \ No newline at end of file diff --git a/lib/download/download.h b/lib/download/download.h index 093920a..fcef212 100644 --- a/lib/download/download.h +++ b/lib/download/download.h @@ -1,6 +1,7 @@ #ifndef DOWNLOAD_H #define DOWNLOAD_H +bool downloadFile(String url, const char *path, const char* CAcert); bool downloadFile(String url, const char *path); #endif \ No newline at end of file diff --git a/lib/face/faceCalendar.cpp b/lib/face/faceCalendar.cpp index 60b2977..69730ef 100644 --- a/lib/face/faceCalendar.cpp +++ b/lib/face/faceCalendar.cpp @@ -21,8 +21,8 @@ void display_time(); const char faceCalendarPicutreJson[] = "/calendarPhoto.json"; const char faceCalendarPicture[] = "/calendarPhoto.jpg"; -const char faceCalendarPictureUrl[] = "http://us-central1-paperdash-io.cloudfunctions.net/apiImageOnRequest/390x384.jpg"; // TODO load from settings -//const char faceCalendarPictureUrl[] = "https://paperdash.io/api/image/390x384.jpg"; // TODO load from settings +//const char faceCalendarPictureUrl[] = "http://us-central1-paperdash-io.cloudfunctions.net/apiImageOnRequest/390x384.jpg"; // TODO load from settings +const char faceCalendarPictureUrl[] = "https://paperdash.io/api/image/390x384.jpg"; // TODO load from settings unsigned long lastCalendarDataUpdate = 0;