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>
50#define REBOOT_DELAY 100
51#define LOG_PORT Serial
52#define CLIENT_TIMEOUT 15
55#define MilliSecondsInASecond 1000
56#define MicroSecondsInAmilliSecond 1000
57#define MicroSecondsInASecond (MicroSecondsInAmilliSecond * MilliSecondsInASecond)
58#define NanoSecondsInAMicroSecond 1000
59#define NanoSecondsInASecond (MicroSecondsInASecond * NanoSecondsInAMicroSecond)
60#define NanoSecondsInAMilliSecond (NanoSecondsInAMicroSecond * MicroSecondsInAmilliSecond)
62#define CPU_ClockTimeNS ((1.0 / float(F_CPU)) * float(NanoSecondsInASecond))
65#define STRINGIFY(X) #X
66#define STRING(X) STRINGIFY(X)
68extern void RequestReboot(String & Reason, uint32_t LoopDelay,
bool SkipDisable =
false);
89 const char Version[32];
90 const char BuildDate[32];
91 const char ConfigFileName[32];
92 const uint8_t CurrentConfigVersion;
102extern void PrettyPrint (JsonObject& jsonStuff, String Name);
103extern void PrettyPrint (JsonArray& jsonStuff, String Name);
104extern void PrettyPrint(JsonDocument &jsonStuff, String Name);
106void inline SafeStrncpy(
char* dest,
const char* src, uint destSize)
108 memset(dest, 0x00, destSize);
109 size_t cpyLen = min(destSize-1, strlen(src));
110 memcpy(dest, src, cpyLen);
113template <
typename T,
typename N>
116 bool HasBeenModified =
false;
118 if (Json[(
char*)Name].
template is<T>())
120 T temp = Json[(
char*)Name];
121 if (temp != OutValue)
124 HasBeenModified =
true;
129 DEBUG_V(String(
"Could not find field '") + Name +
"' in the json record");
133 return HasBeenModified;
136template <
typename N,
size_t S>
139 bool HasBeenModified =
false;
141 if (Json[(
char*)Name].
template is<String>())
143 String temp = Json[(
char*)Name];
144 if (!temp.equals(String(OutValue)))
147 HasBeenModified =
true;
152 DEBUG_V(String(
"Could not find field '") + Name +
"' in the json record");
156 return HasBeenModified;
159template <
typename T,
typename N>
162 bool HasBeenModified =
false;
164 if (Json[(
char*)Name].
template is<T>())
166 T temp = Json[(
char*)Name];
167 if (temp != OutValue)
170 HasBeenModified =
true;
175 DEBUG_V(String(
"Could not find field '") + Name +
"' in the json record");
179 return HasBeenModified;
182#if defined(ARDUINO_ARCH_ESP8266)
183# define JsonWrite(j, n, v) (j)[String(n)] = (v)
184void inline ResetGpio(
const gpio_num_t pinId)
186 if(gpio_num_t(33) > pinId)
188 pinMode(pinId, INPUT);
192# define JsonWrite(j, n, v) (j)[(char*)(n)] = (v)
195 if(GPIO_IS_VALID_OUTPUT_GPIO(pinId))
197 pinMatrixOutDetach(pinId,
false,
false);
198 gpio_reset_pin(pinId);
199 pinMode(pinId, INPUT);
208 GetDriverName (DN); \
209 extern void _logcon (String & DriverName, String Message); \
216#define LOAD_CONFIG_DELAY 4
bool deserializeCore(JsonObject &json)
Definition main.cpp:336
bool dsNetwork(JsonObject &json)
void deserializeCoreHandler(JsonDocument &jsonDoc)
Definition main.cpp:418
config_t config
Definition main.cpp:98
void DelayReboot(uint32_t MinDelay)
Definition main.cpp:549
void PrettyPrint(JsonObject &jsonStuff, String Name)
Definition WebMgr.cpp:74
String serializeCore(bool pretty=false)
Definition main.cpp:520
uint32_t DiscardedRxData
Definition main.cpp:108
bool ResetWiFi
Definition main.cpp:102
bool setFromJSON(T &OutValue, JsonObject &Json, N Name)
Definition ESPixelStick.h:114
void SafeStrncpy(char *dest, const char *src, uint destSize)
Definition ESPixelStick.h:106
void ResetGpio(const gpio_num_t pinId)
Definition ESPixelStick.h:193
void RequestReboot(String &Reason, uint32_t LoopDelay, bool SkipDisable=false)
Definition main.cpp:650
bool IsBooting
Definition main.cpp:103
ConstConfig_t ConstConfig
Definition main.cpp:83
void FeedWDT()
Definition main.cpp:684
bool dsDevice(JsonObject &json)
Deserialize device configuration JSON to config structure - returns true if config change detected.
Definition main.cpp:294
bool ConfigSaveNeeded
Definition main.cpp:105
bool RebootInProgress()
Definition main.cpp:645
bool ConsoleUartIsActive
Definition main.cpp:662
struct FSEQParsedRangeEntry __attribute__
#define DEBUG_V(v)
Definition memdebug.h:18
Core configuration structure.
Definition ESPixelStick.h:74
uint32_t BlankDelay
Definition ESPixelStick.h:77