Initialisation depot

This commit is contained in:
Serge NOEL
2026-08-05 09:14:31 +02:00
commit fd3fc380d8
10 changed files with 350 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
#pragma once
#include <functional>
#include <PubSubClient.h>
#include <WiFiClient.h>
class MqttManager {
public:
using MessageCallback = std::function<void(char*, uint8_t*, unsigned int)>;
MqttManager();
void begin(const char* server, uint16_t port, MessageCallback cb);
void loop();
bool publish(const char* topic, const char* payload);
bool subscribe(const char* topic);
bool connected();
private:
WiFiClient espClient;
PubSubClient client{espClient};
MessageCallback messageCb;
const char* serverAddr = nullptr;
uint16_t serverPort = 0;
static MqttManager* instance;
static void staticCallback(char* topic, byte* payload, unsigned int length);
void connect();
};
+24
View File
@@ -0,0 +1,24 @@
#pragma once
#include <Arduino.h>
#include <WiFi.h>
#include <WebServer.h>
class WifiManager {
public:
WifiManager();
void begin();
bool isConnected();
void loop();
String getSSID();
String getPassword();
private:
WebServer server{80};
String ssid;
String pass;
bool apMode;
void startAP();
void handleRoot();
void handleSave();
void loadCredentials();
void saveCredentials(const String &s, const String &p);
};
+17
View File
@@ -0,0 +1,17 @@
#ifndef CONFIG_H
#define CONFIG_H
// MQTT broker settings (leave MQTT server values as needed)
#define MQTT_SERVER "192.168.1.10"
#define MQTT_PORT 1883
#define MQTT_TOPIC_CMD "dcc/command"
#define MQTT_TOPIC_STATUS "dcc/status"
#define MQTT_TOPIC_RESPONSE "dcc/response"
// Pin used for simulated DCC output (adjust as needed)
#define DCC_OUTPUT_PIN 27
// Access point SSID shown when no WiFi credentials are configured
#define DEFAULT_AP_SSID "DCC_Config"
#endif // CONFIG_H