mirror of
https://github.com/HendrikRauh/dmx-interface.git
synced 2025-07-09 23:25:45 +00:00
extracted default config values
This commit is contained in:
parent
1e52c401e4
commit
c3fab50ccc
3 changed files with 44 additions and 38 deletions
|
@ -4,6 +4,7 @@
|
|||
#include "WiFi.h"
|
||||
|
||||
Preferences config;
|
||||
String DEFAULT_SSID = "";
|
||||
|
||||
#pragma region Utility
|
||||
|
||||
|
@ -75,28 +76,23 @@ void onGetConfig(AsyncWebServerRequest *request)
|
|||
{
|
||||
config.begin("dmx", true);
|
||||
|
||||
IPAddress defaultIp(192, 168, 1, 201);
|
||||
IPAddress ip = config.getUInt("ip", defaultIp);
|
||||
|
||||
IPAddress defaultSubnet(255, 255, 255, 0);
|
||||
IPAddress subnet = config.getUInt("subnet", defaultSubnet);
|
||||
|
||||
IPAddress defaultGateway(192, 168, 1, 1);
|
||||
IPAddress gateway = config.getUInt("gateway", defaultGateway);
|
||||
IPAddress ip = config.getUInt("ip", DEFAULT_IP);
|
||||
IPAddress subnet = config.getUInt("subnet", DEFAULT_SUBNET);
|
||||
IPAddress gateway = config.getUInt("gateway", DEFAULT_GATEWAY);
|
||||
|
||||
JsonDocument doc;
|
||||
doc["connection"] = config.getUInt("connection", WiFiSta);
|
||||
doc["ssid"] = config.getString("ssid", "artnet");
|
||||
doc["password"] = config.getString("password", "mbgmbgmbg");
|
||||
doc["ip-method"] = config.getUInt("ip-method"), Static;
|
||||
doc["connection"] = config.getUInt("connection", DEFAULT_CONNECTION);
|
||||
doc["ssid"] = config.getString("ssid", DEFAULT_SSID);
|
||||
doc["password"] = config.getString("password", DEFAULT_PASSWORD);
|
||||
doc["ip-method"] = config.getUInt("ip-method", DEFAULT_IP_METHOD);
|
||||
doc["ip"] = ip.toString();
|
||||
doc["subnet"] = subnet.toString();
|
||||
doc["gateway"] = gateway.toString();
|
||||
doc["universe-1"] = config.getUInt("universe-1", 1);
|
||||
doc["direction-1"] = config.getUInt("direction-1", Output);
|
||||
doc["universe-2"] = config.getUInt("universe-2", 1);
|
||||
doc["direction-2"] = config.getUInt("direction-2", Input);
|
||||
doc["led-brightness"] = config.getUInt("led-brightness", 25);
|
||||
doc["universe-1"] = config.getUInt("universe-1", DEFAULT_UNIVERSE1);
|
||||
doc["direction-1"] = config.getUInt("direction-1", DEFAULT_DIRECTION1);
|
||||
doc["universe-2"] = config.getUInt("universe-2", DEFAULT_UNIVERSE2);
|
||||
doc["direction-2"] = config.getUInt("direction-2", DEFAULT_DIRECTION2);
|
||||
doc["led-brightness"] = config.getUInt("led-brightness", DEFAULT_LED_BRIGHTNESS);
|
||||
|
||||
config.end();
|
||||
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
#include <AsyncWebServer_ESP32_W5500.h>
|
||||
#include <ESPDMX.h>
|
||||
#include <Preferences.h>
|
||||
|
||||
// #ifndef CONFIG_h
|
||||
// #define CONFIG_h
|
||||
#ifndef CONFIG_h
|
||||
#define CONFIG_h
|
||||
|
||||
extern Preferences config;
|
||||
|
||||
|
@ -31,10 +29,25 @@ enum Direction
|
|||
};
|
||||
const uint8_t DIRECTION_SIZE = 2;
|
||||
|
||||
const Connection DEFAULT_CONNECTION = WiFiAP;
|
||||
const IpMethod DEFAULT_IP_METHOD = DHCP;
|
||||
extern String DEFAULT_SSID; // initialized in setup because it depends on the mac address
|
||||
const String DEFAULT_PASSWORD = "mbgmbgmbg";
|
||||
const IPAddress DEFAULT_IP(192, 168, 4, 1);
|
||||
const IPAddress DEFAULT_SUBNET(255, 0, 0, 0);
|
||||
const IPAddress DEFAULT_GATEWAY(2, 0, 0, 1);
|
||||
|
||||
const Direction DEFAULT_DIRECTION1 = Output;
|
||||
const Direction DEFAULT_DIRECTION2 = Input;
|
||||
const uint8_t DEFAULT_UNIVERSE1 = 1;
|
||||
const uint8_t DEFAULT_UNIVERSE2 = 2;
|
||||
|
||||
const uint8_t DEFAULT_LED_BRIGHTNESS = 25;
|
||||
|
||||
void onGetConfig(AsyncWebServerRequest *request);
|
||||
|
||||
void onPutConfig(AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total);
|
||||
|
||||
void onGetNetworks(AsyncWebServerRequest *request);
|
||||
|
||||
// #endif
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue