mirror of
https://gitlab.com/zwirbel/illucat.git
synced 2025-12-16 18:05:05 +01:00
separate fw variation for chat
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
#include <WebApiPlugin.h>
|
||||
#include <PixelPlugin.h>
|
||||
#include <MqttPlugin.h>
|
||||
#include <OtaTcpPlugin.cpp>
|
||||
|
||||
WiFiNet *network;
|
||||
Sprocket *sprocket;
|
||||
@@ -16,6 +17,7 @@ WebConfigPlugin *webConfigPlugin;
|
||||
WebApiPlugin *webApiPlugin;
|
||||
PixelPlugin *pixelPlugin;
|
||||
MqttPlugin *mqttPlugin;
|
||||
OtaTcpPlugin *otaTcpPlugin;
|
||||
|
||||
void setup()
|
||||
{
|
||||
@@ -25,11 +27,14 @@ void setup()
|
||||
webServerPlugin = new WebServerPlugin({WEB_CONTEXT_PATH, WEB_DOC_ROOT, WEB_DEFAULT_FILE, WEB_PORT});
|
||||
webConfigPlugin = new WebConfigPlugin(webServerPlugin->server);
|
||||
webApiPlugin = new WebApiPlugin(webServerPlugin->server);
|
||||
otaTcpPlugin = new OtaTcpPlugin({OTA_PORT, OTA_PASSWORD});
|
||||
|
||||
sprocket->addPlugin(pixelPlugin);
|
||||
sprocket->addPlugin(webServerPlugin);
|
||||
sprocket->addPlugin(webConfigPlugin);
|
||||
sprocket->addPlugin(webApiPlugin);
|
||||
sprocket->addPlugin(mqttPlugin);
|
||||
sprocket->addPlugin(otaTcpPlugin);
|
||||
|
||||
network = new WiFiNet(
|
||||
WIFI_MODE,
|
||||
@@ -44,11 +49,10 @@ void setup()
|
||||
webServerPlugin->server->serveStatic(PIXEL_CONFIG_FILE, SPIFFS, "pixelConfig.json");
|
||||
webServerPlugin->server->serveStatic(MQTT_CONFIG_FILE, SPIFFS, "mqttConfig.json");
|
||||
|
||||
const char* mqChatTopic = "wirelos/chat/log";
|
||||
const char* outChatTopic = "out/chat/log";
|
||||
const char* chatUser = "user";
|
||||
const char *mqChatTopic = "wirelos/chat/log";
|
||||
const char *outChatTopic = "out/chat/log";
|
||||
|
||||
sprocket->subscribe("mqtt/connect", [mqChatTopic, outChatTopic, chatUser](String msg) {
|
||||
sprocket->subscribe("mqtt/connect", [mqChatTopic, outChatTopic](String msg) {
|
||||
if (msg.length() > 0)
|
||||
{
|
||||
mqttPlugin->client->subscribe(mqChatTopic);
|
||||
@@ -58,9 +62,9 @@ void setup()
|
||||
});
|
||||
|
||||
// send message from WS to this topic
|
||||
sprocket->subscribe(outChatTopic, [mqChatTopic, chatUser](String msg) {
|
||||
PRINT_MSG(Serial, "CHAT", msg.c_str());
|
||||
mqttPlugin->client->publish(mqChatTopic, (String(chatUser) + ": " + msg).c_str());
|
||||
sprocket->subscribe(outChatTopic, [mqChatTopic](String msg) {
|
||||
PRINT_MSG(Serial, "CHAT", String("outgoing: " + msg).c_str());
|
||||
mqttPlugin->client->publish(mqChatTopic, msg.c_str());
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user