diff --git a/data/mqttConfig.json b/data/mqttConfig.json index f55046a..789897d 100644 --- a/data/mqttConfig.json +++ b/data/mqttConfig.json @@ -2,5 +2,5 @@ "mqttClientName" : "illucat", "mqttBrokerHost" : "192.168.1.2", "mqttBrokerPort" : 1883, - "mqttRootTopic" : "wirelos/illucat" + "mqttRootTopic" : "wirelos/led/illucat" } \ No newline at end of file diff --git a/data/www/index.html b/data/www/index.html index a42d1a2..69e9946 100644 --- a/data/www/index.html +++ b/data/www/index.html @@ -73,8 +73,8 @@

NeoPixel

- +

MQTT

+

IRC

diff --git a/platformio.ini b/platformio.ini index 8860265..7616473 100644 --- a/platformio.ini +++ b/platformio.ini @@ -100,4 +100,6 @@ lib_deps = ${common.lib_deps} https://gitlab.com/wirelos/sprocket-network-wifi.git https://gitlab.com/wirelos/sprocket-plugin-web.git https://gitlab.com/wirelos/sprocket-plugin-irc.git + https://gitlab.com/wirelos/sprocket-plugin-mqtt.git + PubSubClient ArduinoIRC diff --git a/src/var/illuchat/illuchat_config.h b/src/var/illuchat/illuchat_config.h index 2acadb1..41b90b7 100644 --- a/src/var/illuchat/illuchat_config.h +++ b/src/var/illuchat/illuchat_config.h @@ -52,5 +52,11 @@ #define WEB_DEFAULT_FILE "index.html" #define WEB_PORT 80 +// mqtt config +#define MQTT_CLIENT_NAME "illucat" +#define MQTT_HOST "192.168.1.2" +#define MQTT_PORT 1883 +#define MQTT_ROOT_TOPIC "wirelos/led/illucat" + #endif \ No newline at end of file diff --git a/src/var/illuchat/main.cpp b/src/var/illuchat/main.cpp index d6abeec..c6ecb61 100644 --- a/src/var/illuchat/main.cpp +++ b/src/var/illuchat/main.cpp @@ -9,6 +9,7 @@ #include #include #include +#include WiFiNet *network; Sprocket *sprocket; @@ -18,6 +19,7 @@ WebApiPlugin *webApiPlugin; PixelPlugin *pixelPlugin; IrcPlugin *ircPlugin; OtaTcpPlugin *otaTcp; +MqttPlugin *mqttPlugin; void setup() { @@ -25,6 +27,7 @@ void setup() sprocket = new Sprocket({STARTUP_DELAY, SERIAL_BAUD_RATE}); pixelPlugin = new PixelPlugin({LED_STRIP_PIN, LED_STRIP_LENGTH, LED_STRIP_BRIGHTNESS, LED_STRIP_UPDATE_INTERVAL}); ircPlugin = new IrcPlugin({IRC_SERVER, IRC_PORT, chipName, chipName}); + mqttPlugin = new MqttPlugin({MQTT_CLIENT_NAME, MQTT_HOST, MQTT_PORT, MQTT_ROOT_TOPIC}); webServerPlugin = new WebServerPlugin({WEB_CONTEXT_PATH, WEB_DOC_ROOT, WEB_DEFAULT_FILE, WEB_PORT}); webConfigPlugin = new WebConfigPlugin(webServerPlugin->server); webApiPlugin = new WebApiPlugin(webServerPlugin->server); @@ -36,6 +39,7 @@ void setup() sprocket->addPlugin(webApiPlugin); sprocket->addPlugin(otaTcp); sprocket->addPlugin(ircPlugin); + sprocket->addPlugin(mqttPlugin); network = new WiFiNet( WIFI_MODE, @@ -49,6 +53,7 @@ void setup() webServerPlugin->server->serveStatic(PIXEL_CONFIG_FILE, SPIFFS, "pixelConfig.json"); webServerPlugin->server->serveStatic(IRC_CONFIG_FILE, SPIFFS, "ircConfig.json"); + webServerPlugin->server->serveStatic(MQTT_CONFIG_FILE, SPIFFS, "mqttConfig.json"); sprocket->subscribe("irc/connected", [](String msg) { if (atoi(msg.c_str())) diff --git a/src/var/mqcatt/mqcatt_config.h b/src/var/mqcatt/mqcatt_config.h index fe82687..00b9bc5 100644 --- a/src/var/mqcatt/mqcatt_config.h +++ b/src/var/mqcatt/mqcatt_config.h @@ -36,16 +36,17 @@ #define COLOR_CONNECTED LED_STRIP_DEFAULT_COLOR #define COLOR_NOT_CONNECTED 255 + +// OTA config +#define OTA_PORT 8266 +#define OTA_PASSWORD "" + // mqtt config #define MQTT_CLIENT_NAME "illucat" #define MQTT_HOST "192.168.1.2" #define MQTT_PORT 1883 #define MQTT_ROOT_TOPIC "wirelos/illucat" -// OTA config -#define OTA_PORT 8266 -#define OTA_PASSWORD "" - // WebServer #define WEB_CONTEXT_PATH "/" #define WEB_DOC_ROOT "/www"