code-sammler-flat-room-group-B3.0 — ESP32 simulation

Web-Log-Terminal: vollständige h-Ausgabe (Puffer 64), größere Anzeige und Stick-to-Bottom-Scroll-Logik.

An interactive ESP32 circuit simulation you can run free in your browser on Velxio, by bmw550i.

Components

Sketch code

// Version: B3.0

// ===================================================================
// SKETCH.INO - TEIL 1 (Definitionen, Variablen & Prototypen)
// ===================================================================
#include <WiFi.h>
#include <WebServer.h>
WebServer server(80);

#include <esp_now.h>
#include <ArduinoJson.h>
#include <esp_task_wdt.h> 
#include "esp_mac.h" 
#include "config.h"
#include "webpage.h"
#include <stdarg.h> 
#include <ArduinoOTA.h>  // ✅ Neu für drahtlose Updates

#define WDT_TIMEOUT_SECONDS 5 

uint32_t myLocalSequenceNumber = 0;
uint32_t simSequenceCounter = 0; 

bool logToSerialActive = true;    
bool logToEspNowActive = false;   
bool logToWebActive = true;
bool logEspNowTransmitInProgress = false; // Schutz gegen Log->TX->Log Rekursion    

#define WEB_LOG_MAX_LINES 512
String webLogBuffer[WEB_LOG_MAX_LINES];
uint16_t webLogBufferIdx = 0;
uint32_t webLogSequence = 0;   // Monotone Sequenznummer je Logzeile (fuer Browser-Inkrement-Abgleich)

struct MsgFingerprint { uint16_t srcId; uint32_t seqNum; };
#define MESH_HISTORY_SIZE 512
MsgFingerprint meshHistory[MESH_HISTORY_SIZE];
uint16_t meshHistoryIdx = 0;

unsigned long lastWifiCheckTime = 0;
const unsigned long wifiCheckInterval = 10000; 

// --- COMPILER-FORWARD-PROTOTYPEN ---
void sendBroadcast(LightControlPayload &payload);
void processDebugCommand(const char* cmdStr);
void checkLocalInputs();
void evaluatePrioritiesAndOutputs();
void printSystemConfig(const SystemConfig& cfg);
void printGlobalRegistry();
void handleWebDebugCommand(const char* webCmdStr);
String webProcessor(const String& var);
void handleApiStatus();
void registerWebEndpoints();
void loadConfiguration();
void checkWifiBackgroundEngine();
void processReceivedPacket(const uint8_t* sourceMac, const LightControlPayload& packet);
void initArduinoOTA();
void executeCentralCommand(String inputStr);

// ===================================================================
// STRUKTURIERTES LOGGING - B2.22
// ===================================================================
// Kategorien: BOOT / SYS / WEB / INPUT / LOGIC / PWM / ESPNOW / OTA / ERR
// Bestehende systemLogf()-Aufrufe bleiben kompatibel; neue/gezielte Diagnose
// verwendet systemLogCategoryf(), damit die Zuständigkeit im Log sofort sichtbar ist.
void systemLogCategoryf(const char* category, const char* format, ...);

// ===================================================================
// B3 ARCHITEKTUR: SOURCE -> LOGIC -> ACTION -> ACTUATOR
// ===================================================================
// Transport bleibt davon getrennt: RX -> Duplicate-Pruefung -> unveraendertes FWD.
// Die vorhandene Konfiguration bleibt in B3.0 kompatibel; diese Typen bilden
// zunaechst die Laufzeit-Schnittstellen der neuen Schichten.

enum SourceEventKind : uint8_t {
    SOURCE_EVENT_CLICK = EVENT_CLICK,
    SOURCE_EVENT_VALUE_CHANGE = EVENT_VALUE_CHANGE,
    SOURCE_EVENT_HOLD = EVENT_HOLD,
    SOURCE_EVENT_RELEASE = EVENT_RELEASE
};

str

More projects by bmw550i