23#if defined(ARDUINO_ARCH_ESP8266)
24# include <ESP8266WiFi.h>
25# include <ESPAsyncTCP.h>
26# include <ESPAsyncUDP.h>
27#elif defined(ARDUINO_ARCH_ESP32)
32# error "Unsupported CPU type"
36# error "PSRAM is not supported by ESPixelStick"
39#define ARDUINOJSON_USE_LONG_LONG 1
40#define ARDUINOJSON_DEFAULT_NESTING_LIMIT 15
43#include <ArduinoJson.h>
44#ifdef ARDUINO_ARCH_ESP8266
45# include <coredecls.h>
53#define LOG_PORT Serial
54#define CLIENT_TIMEOUT 15
57#define MilliSecondsInASecond 1000
58#define MicroSecondsInAmilliSecond 1000
59#define MicroSecondsInASecond (MicroSecondsInAmilliSecond * MilliSecondsInASecond)
60#define NanoSecondsInAMicroSecond 1000
61#define NanoSecondsInASecond (MicroSecondsInASecond * NanoSecondsInAMicroSecond)
62#define NanoSecondsInAMilliSecond (NanoSecondsInAMicroSecond * MicroSecondsInAmilliSecond)
64#define CPU_ClockTimeNS ((1.0 / float(F_CPU)) * float(NanoSecondsInASecond))
67#define STRINGIFY(X) #X
68#define STRING(X) STRINGIFY(X)
70extern void RequestReboot(String & Reason, uint32_t LoopDelay,
bool SkipDisable =
false);
91 const char Version[32];
92 const char BuildDate[32];
93 const char ConfigFileName[32];
94 const uint8_t CurrentConfigVersion;
108#ifdef ARDUINO_ARCH_ESP8266
109 if (!can_yield ()) {
return; }
115extern void PrettyPrint (JsonObject& jsonStuff, String Name);
116extern void PrettyPrint (JsonArray& jsonStuff, String Name);
117extern void PrettyPrint(JsonDocument &jsonStuff, String Name);
119void inline SafeStrncpy(
char* dest,
const char* src, uint destSize)
121 memset(dest, 0x00, destSize);
122 size_t cpyLen = min(destSize-1, strlen(src));
123 memcpy(dest, src, cpyLen);
126template <
typename T,
typename N>
129 bool HasBeenModified =
false;
131 if (Json[(
char*)Name].
template is<T>())
133 T temp = Json[(
char*)Name];
134 if (temp != OutValue)
137 HasBeenModified =
true;
142 DEBUG_V(String(
"Could not find field '") + Name +
"' in the json record");
146 return HasBeenModified;
149template <
typename N,
size_t S>
152 bool HasBeenModified =
false;
154 if (Json[(
char*)Name].
template is<String>())
156 String temp = Json[(
char*)Name];
157 if (!temp.equals(String(OutValue)))
160 HasBeenModified =
true;
165 DEBUG_V(String(
"Could not find field '") + Name +
"' in the json record");
169 return HasBeenModified;
172template <
typename T,
typename N>
175 bool HasBeenModified =
false;
177 if (Json[(
char*)Name].
template is<T>())
179 T temp = Json[(
char*)Name];
180 if (temp != OutValue)
183 HasBeenModified =
true;
188 DEBUG_V(String(
"Could not find field '") + Name +
"' in the json record");
192 return HasBeenModified;
195#if defined(ARDUINO_ARCH_ESP8266)
196# define JsonWrite(j, n, v) (j)[String(n)] = (v)
197void inline ResetGpio(
const gpio_num_t pinId)
199 if(gpio_num_t(33) > pinId)
201 pinMode(pinId, INPUT);
205# define JsonWrite(j, n, v) (j)[(char*)(n)] = (v)
208 if(GPIO_IS_VALID_OUTPUT_GPIO(pinId))
210 pinMatrixOutDetach(pinId,
false,
false);
211 gpio_reset_pin(pinId);
212 pinMode(pinId, INPUT);
225 GetDriverName (DN); \
226 extern void _logcon (String & DriverName, String Message); \
233#define LOAD_CONFIG_DELAY 4
bool deserializeCore(JsonObject &json)
Definition main.cpp:344
bool dsNetwork(JsonObject &json)
void deserializeCoreHandler(JsonDocument &jsonDoc)
Definition main.cpp:431
config_t config
Definition main.cpp:98
void DelayReboot(uint32_t MinDelay)
Definition main.cpp:562
void PrettyPrint(JsonObject &jsonStuff, String Name)
Definition WebMgr.cpp:74
String serializeCore(bool pretty=false)
Definition main.cpp:533
uint32_t DiscardedRxData
Definition main.cpp:108
bool ResetWiFi
Definition main.cpp:102
bool setFromJSON(T &OutValue, JsonObject &Json, N Name)
Definition ESPixelStick.h:127
void SafeDelay(uint32_t ms)
Definition ESPixelStick.h:106
void SafeStrncpy(char *dest, const char *src, uint destSize)
Definition ESPixelStick.h:119
void ResetGpio(const gpio_num_t pinId)
Definition ESPixelStick.h:206
void RequestReboot(String &Reason, uint32_t LoopDelay, bool SkipDisable=false)
Definition main.cpp:665
bool IsBooting
Definition main.cpp:103
ConstConfig_t ConstConfig
Definition main.cpp:83
void FeedWDT()
Definition main.cpp:705
bool dsDevice(JsonObject &json)
Deserialize device configuration JSON to config structure - returns true if config change detected.
Definition main.cpp:302
bool ConfigSaveNeeded
Definition main.cpp:105
bool RebootInProgress()
Definition main.cpp:660
bool ConsoleUartIsActive
Definition main.cpp:677
struct FSEQParsedRangeEntry __attribute__
#define DEBUG_V(v)
Definition memdebug.h:18
Core configuration structure.
Definition ESPixelStick.h:76
uint32_t BlankDelay
Definition ESPixelStick.h:79