/* * Libraries and global scope code */ #include #include #include BearSSL::WiFiClientSecure net; time_t now; unsigned long lastMillis = 0; String devname; // Device identifier for MQTT struct Settings { String name = ""; String ip = ""; } settings; /* * Debugging might be nice sometimes */ #define USE_SERIAL //uncomment for Serial debugging statements bool serialinitialised = false; char printbuffer[100]; void PRINT_SERIAL(const String& line) { #ifdef USE_SERIAL if(!serialinitialised){ Serial.begin(115200); serialinitialised = true; } Serial.print(settings.ip + " " + settings.name + " "); Serial.print(line); #endif } void APPEND_SERIAL(const String& line) { #ifdef USE_SERIAL Serial.print(line); #endif } void PRINTLN_SERIAL(const String& line) { #ifdef USE_SERIAL PRINT_SERIAL(line); Serial.println(); #endif } void APPENDLN_SERIAL(const String& line) { #ifdef USE_SERIAL Serial.println(line); #endif } #define NOP __asm__ __volatile__ ("nop\n")