#33 https download works now

pull/1/head
Thomas Ballmann 4 years ago
parent fc523fb51c
commit 6d60ddf9d7

@ -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);
}

@ -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

@ -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;

Loading…
Cancel
Save