Fixed ESP8266 build issue

This commit is contained in:
Gunnar Skjold
2024-04-21 10:35:30 +02:00
parent 3f1861deda
commit 05506cdc9f
2 changed files with 22 additions and 12 deletions

View File

@@ -20,7 +20,6 @@
#include "PriceService.h"
#include "RealtimePlot.h"
#include "ConnectionHandler.h"
#include "CloudConnector.h"
#if defined(ESP8266)
#include <ESP8266WiFi.h>
@@ -34,6 +33,7 @@
#include <HTTPClient.h>
#include <HTTPUpdate.h>
#include <ESP32SSDP.h>
#include "CloudConnector.h"
#else
#warning "Unsupported board type"
#endif
@@ -45,7 +45,9 @@ public:
AmsWebServer(uint8_t* buf, RemoteDebug* Debug, HwTools* hw, ResetDataContainer* rdc);
void setup(AmsConfiguration*, GpioConfig*, AmsData*, AmsDataStorage*, EnergyAccounting*, RealtimePlot*);
void loop();
#if defined(ESP32)
void setCloud(CloudConnector* cloud);
#endif
void setTimezone(Timezone* tz);
void setMqttEnabled(bool);
void setPriceService(PriceService* ps);
@@ -74,7 +76,9 @@ private:
RealtimePlot* rtp = NULL;
AmsMqttHandler* mqttHandler = NULL;
ConnectionHandler* ch = NULL;
#if defined(ESP32)
CloudConnector* cloud = NULL;
#endif
bool uploading = false;
File file;
bool performRestart = false;

View File

@@ -162,9 +162,11 @@ void AmsWebServer::setup(AmsConfiguration* config, GpioConfig* gpioConfig, AmsDa
mqttEnabled = strlen(mqttConfig.host) > 0;
}
#if defined(ESP32)
void AmsWebServer::setCloud(CloudConnector* cloud) {
this->cloud = cloud;
}
#endif
void AmsWebServer::setTimezone(Timezone* tz) {
this->tz = tz;
@@ -1093,18 +1095,22 @@ void AmsWebServer::translationsJson() {
void AmsWebServer::cloudkeyJson() {
if(!checkSecurity(1))
return;
if(cloud == NULL)
#if defined(ESP32)
if(cloud == NULL)
notFound();
String seed = cloud->generateSeed();
snprintf_P(buf, BufferSize, PSTR("{\"seed\":\"%s\"}"), seed.c_str());
server.setContentLength(strlen(buf));
server.sendHeader(HEADER_CACHE_CONTROL, CACHE_CONTROL_NO_CACHE);
server.sendHeader(HEADER_PRAGMA, PRAGMA_NO_CACHE);
server.sendHeader(HEADER_EXPIRES, EXPIRES_OFF);
server.send(200, MIME_JSON, buf);
#else
notFound();
String seed = cloud->generateSeed();
snprintf_P(buf, BufferSize, PSTR("{\"seed\":\"%s\"}"), seed.c_str());
server.setContentLength(strlen(buf));
server.sendHeader(HEADER_CACHE_CONTROL, CACHE_CONTROL_NO_CACHE);
server.sendHeader(HEADER_PRAGMA, PRAGMA_NO_CACHE);
server.sendHeader(HEADER_EXPIRES, EXPIRES_OFF);
server.send(200, MIME_JSON, buf);
#endif
}
void AmsWebServer::handleSave() {