If the code hasn't been touched in this long, its probably release-worthy.
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
#include "Platform.h"
|
||||
#include <ArduinoLog.h>
|
||||
#include "Static.h"
|
||||
#include <time.h>
|
||||
|
||||
#ifdef BOARD_ESP32
|
||||
#ifdef CONFIG_WIFI
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
#include <esp_task_wdt.h>
|
||||
#include <time.h>
|
||||
#elif defined(BOARD_ESP8266)
|
||||
#ifdef CONFIG_WIFI
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <WiFiUdp.h>
|
||||
#include <NTPClient.h>
|
||||
@@ -16,11 +19,14 @@ WiFiUDP wifiUdp;
|
||||
//NTPClient timeClient(wifiUdp, "pool.ntp.org", 3600 * -7);
|
||||
NTPClient timeClient(wifiUdp, "10.0.0.1", 3600 * -7);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PLATFORM_PHOTON
|
||||
STARTUP(BootOptions::initPins());
|
||||
#else
|
||||
#ifdef CONFIG_MQTT
|
||||
#include "platform/arduino/MQTTTelemetry.h"
|
||||
#endif
|
||||
void printNewline(Print* logOutput)
|
||||
{
|
||||
logOutput->print("\r\n");
|
||||
@@ -33,6 +39,8 @@ int printEspLog(const char* fmt, va_list args)
|
||||
#endif
|
||||
|
||||
int Platform::s_timezone = 0;
|
||||
Platform::TaskRegistration* Platform::firstTask = NULL;
|
||||
Platform::TaskRegistration* Platform::lastTask = NULL;
|
||||
|
||||
const char*
|
||||
Platform::name()
|
||||
@@ -78,7 +86,11 @@ Platform::preSetup()
|
||||
Log.notice("\xf0\x9f\x94\x8c Serial connected");
|
||||
}
|
||||
#else
|
||||
Log.begin(LOG_LEVEL_VERBOSE, Static<MQTTTelemetry>::instance()->logPrinter());
|
||||
#ifdef CONFIG_MQTT
|
||||
Log.begin(LOG_LEVEL_TRACE, Static<MQTTTelemetry>::instance()->logPrinter());
|
||||
#else
|
||||
Log.begin(LOG_LEVEL_TRACE, &Serial);
|
||||
#endif
|
||||
Log.setSuffix(printNewline);
|
||||
#endif
|
||||
|
||||
@@ -101,8 +113,10 @@ Platform::setup()
|
||||
constexpr int dst = 1;
|
||||
configTime(s_timezone* 3600, 3600 * dst, "pool.ntp.org");
|
||||
#elif defined(BOARD_ESP8266)
|
||||
#ifdef CONFIG_WIFI
|
||||
timeClient.begin();
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
@@ -114,15 +128,24 @@ Platform::bootSplash()
|
||||
Log.notice(u8" 3: Serial - %d", bootopts.isSerial);
|
||||
Log.notice(u8" 4: Flash - %d", bootopts.isFlash);
|
||||
#endif
|
||||
|
||||
Log.trace("Registered tasks:");
|
||||
auto it = beginTasks();
|
||||
while (it != endTasks()) {
|
||||
Log.trace((*it)->name);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Platform::loop()
|
||||
{
|
||||
#ifdef BOARD_ESP8266
|
||||
#ifdef CONFIG_WIFI
|
||||
if (WiFi.status() == WL_CONNECTED) {
|
||||
timeClient.update();
|
||||
}
|
||||
#endif
|
||||
ESP.wdtFeed();
|
||||
#elif defined(BOARD_ESP32)
|
||||
esp_task_wdt_reset();
|
||||
@@ -141,13 +164,18 @@ Platform::getLocalTime(struct tm* timedata)
|
||||
return false;
|
||||
#elif defined(BOARD_ESP32)
|
||||
time_t rawtime;
|
||||
memset(&rawtime, 0, sizeof(rawtime));
|
||||
time(&rawtime);
|
||||
(*timedata) = (*localtime(&rawtime));
|
||||
return (timedata->tm_year > (2016-1990));
|
||||
//return getLocalTime(timedata);
|
||||
#else
|
||||
#ifdef CONFIG_WIFI
|
||||
timedata->tm_hour = timeClient.getHours();
|
||||
timedata->tm_min = timeClient.getMinutes();
|
||||
#else
|
||||
memset(timedata, sizeof(struct tm), 0);
|
||||
return false;
|
||||
#endif
|
||||
return true;
|
||||
#endif
|
||||
}
|
||||
@@ -172,3 +200,4 @@ char
|
||||
Platform::s_deviceID[15];
|
||||
|
||||
STATIC_ALLOC(Platform);
|
||||
STATIC_TASK(Platform);
|
||||
|
Reference in New Issue
Block a user