Merge branch 'rework'

This commit is contained in:
sqozz 2018-11-17 22:01:41 +01:00
commit 9bf0eefb2e

View file

@ -9,6 +9,9 @@
#include <CertStoreBearSSL.h>
#include <FS.h>
// TODO: figure out how these freakin summertime works
// best would be some kind of automatic change
#define DEVICE_NAME "OTA TEST DEVICE"
#define TZ 1 // (utc+) TZ in hours
#define DST_MN 0 // use 60mn for summer time in some countries
@ -21,6 +24,7 @@ BearSSL::CertStore certStore;
WiFiManager wifiManager;
String config_password;
// Copy&Pasted code from the esp core example based on BeadSSL
class SPIFFSCertStoreFile : public BearSSL::CertStoreFile {
public:
SPIFFSCertStoreFile(const char *name) {
@ -94,8 +98,7 @@ void setup() {
int numCerts = certStore.initCertStore(&certs_idx, &certs_ar);
Serial.print(F("Number of CA certs read: ")); Serial.println(numCerts);
if (numCerts == 0) {
Serial.println(F("No certs found. Did you run certs-from-mozill.py and upload the SPIFFS directory before running?"));
// TODO: bailout?
Serial.println(F("No certs found. HTTPS requests will most likely fail."));
}
if (SPIFFS.exists("/config_password.txt")) {
@ -108,13 +111,12 @@ void setup() {
}
wifiManager.autoConnect(DEVICE_NAME, config_password.c_str());
} else {
Serial.println(F("Failed to find file. Upload config_password.txt with the configuration password included"));
// TODO: bailout?
Serial.println(F("Failed to find AP password file in SPIFFS. Refusing to set up the wifi manager in an usecure way. Upload config_password.txt with the configuration password included"));
}
}
void loop() {
checkUpdate();
checkUpdate(); // Checks for updates and applies it if available
delay(10000);
}
@ -140,9 +142,6 @@ void checkUpdate() {
ESPhttpUpdate.setLedPin(LED_BUILTIN, LOW);
t_httpUpdate_return ret = ESPhttpUpdate.update(client, "https://iotupdates.companioncu.be/update");
// Or:
//t_httpUpdate_return ret = ESPhttpUpdate.update(client, "server", 443, "file.bin");
switch (ret) {
case HTTP_UPDATE_FAILED: