load config from file

This commit is contained in:
2018-11-19 13:01:40 +01:00
parent 91566eca43
commit b05d2d4fde
4 changed files with 27 additions and 14 deletions

7
data/mqttConfig.json Normal file
View File

@@ -0,0 +1,7 @@
{
"mqttClientName" : "illucat00",
"mqttBrokerHost" : "192.168.1.2",
"mqttBrokerPort" : 1883,
"mqttInTopicRoot" : "wirelos/led-in/",
"mqttOutTopicRoot" : "wirelos/led-out/"
}

View File

@@ -67,6 +67,8 @@
<div class="Form" data-fileName="/config.json" data-name="configForm" data-from="/config.json" data-endpoint="/config"></div> <div class="Form" data-fileName="/config.json" data-name="configForm" data-from="/config.json" data-endpoint="/config"></div>
<h2>NeoPixel</h2> <h2>NeoPixel</h2>
<div class="Form" data-fileName="/pixelConfig.json" data-name="configForm" data-from="/pixelConfig.json" data-endpoint="/config"></div> <div class="Form" data-fileName="/pixelConfig.json" data-name="configForm" data-from="/pixelConfig.json" data-endpoint="/config"></div>
<h2>MQTT</h2>
<div class="Form" data-fileName="/mqttConfig.json" data-name="configForm" data-from="/mqttConfig.json" data-endpoint="/config"></div>
</div> </div>
</div> </div>
<div class="settings container collapsible"> <div class="settings container collapsible">

View File

@@ -11,7 +11,6 @@
WiFiNet *network; WiFiNet *network;
Sprocket *sprocket; Sprocket *sprocket;
AsyncWebServer *server;
WebServerPlugin *webServerPlugin; WebServerPlugin *webServerPlugin;
WebConfigPlugin *webConfigPlugin; WebConfigPlugin *webConfigPlugin;
WebApiPlugin *webApiPlugin; WebApiPlugin *webApiPlugin;
@@ -42,6 +41,9 @@ void setup()
CONNECT_TIMEOUT); CONNECT_TIMEOUT);
network->connect(); network->connect();
webServerPlugin->server->serveStatic(PIXEL_CONFIG_FILE, SPIFFS, "pixelConfig.json");
webServerPlugin->server->serveStatic(MQTT_CONFIG_FILE, SPIFFS, "mqttConfig.json");
sprocket->activate(); sprocket->activate();
} }

View File

@@ -23,15 +23,25 @@
#define HOSTNAME "illucat" #define HOSTNAME "illucat"
#define CONNECT_TIMEOUT 10000 #define CONNECT_TIMEOUT 10000
// pixel config // config files
#define PIXEL_CONFIG_FILE "/pixelConfig.json" #define PIXEL_CONFIG_FILE "/pixelConfig.json"
#define MQTT_CONFIG_FILE "/mqttConfig.json"
// NeoPixel
#define LED_STRIP_PIN D2
#define LED_STRIP_LENGTH 8
#define LED_STRIP_BRIGHTNESS 48
#define LED_STRIP_UPDATE_INTERVAL 200
#define LED_STRIP_DEFAULT_COLOR 100
#define COLOR_CONNECTED LED_STRIP_DEFAULT_COLOR
#define COLOR_NOT_CONNECTED 255
// mqtt config // mqtt config
#define MQTT_CLIENT_NAME "mqcatt" #define MQTT_CLIENT_NAME "illucat"
#define MQTT_HOST "192.168.1.2" #define MQTT_HOST "192.168.1.2"
#define MQTT_PORT 1883 #define MQTT_PORT 1883
#define MQTT_TOPIC_IN "wirelos/illucat-in/" #define MQTT_TOPIC_IN "wirelos/led-in/"
#define MQTT_TOPIC_OUT "wirelos/illucat-out/" #define MQTT_TOPIC_OUT "wirelos/led-out/"
// OTA config // OTA config
#define OTA_PORT 8266 #define OTA_PORT 8266
@@ -43,13 +53,5 @@
#define WEB_DEFAULT_FILE "index.html" #define WEB_DEFAULT_FILE "index.html"
#define WEB_PORT 80 #define WEB_PORT 80
// NeoPixel
#define LED_STRIP_PIN D2
#define LED_STRIP_LENGTH 8
#define LED_STRIP_BRIGHTNESS 48
#define LED_STRIP_UPDATE_INTERVAL 200
#define LED_STRIP_DEFAULT_COLOR 100
#define COLOR_CONNECTED LED_STRIP_DEFAULT_COLOR
#define COLOR_NOT_CONNECTED 255
#endif #endif