From f4e87685fb93e7eee9284b24a1bb4c8e229f97d3 Mon Sep 17 00:00:00 2001 From: Patrick Balsiger Date: Thu, 15 Nov 2018 23:28:32 +0100 Subject: [PATCH 1/3] add mqtt cat --- platformio.ini | 46 +++++++++++++++++---------- src/var/mqcatt/main.cpp | 52 +++++++++++++++++++++++++++++++ src/var/mqcatt/mqcatt_config.h | 55 +++++++++++++++++++++++++++++++++ src/{ => var}/wifi/main.cpp | 0 src/{ => var}/wifiMesh/main.cpp | 0 5 files changed, 137 insertions(+), 16 deletions(-) create mode 100644 src/var/mqcatt/main.cpp create mode 100644 src/var/mqcatt/mqcatt_config.h rename src/{ => var}/wifi/main.cpp (100%) rename src/{ => var}/wifiMesh/main.cpp (100%) diff --git a/platformio.ini b/platformio.ini index 4a9ff5c..30fb3d6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -30,10 +30,23 @@ lib_deps = painlessMesh https://gitlab.com/wirelos/sprocket-lib.git#develop https://gitlab.com/wirelos/sprocket-plugin-neopixel.git - https://gitlab.com/wirelos/sprocket-plugin-web.git [env:build] -src_filter = +<*> - + +src_filter = +<*> - + +platform = ${common.platform} +board = ${common.board} +upload_speed = ${common.upload_speed} +monitor_baud = ${common.monitor_baud} +framework = ${common.framework} +build_flags = -Wl,-Teagle.flash.4m1m.ld + -DSPROCKET_PRINT=1 +lib_deps = ${common.lib_deps} + https://gitlab.com/wirelos/sprocket-plugin-web.git + + + +[env:build] +src_filter = +<*> - + platform = ${common.platform} board = ${common.board} upload_speed = ${common.upload_speed} @@ -46,7 +59,7 @@ lib_deps = ${common.lib_deps} [env:build-mesh] -src_filter = +<*> + - +src_filter = +<*> - + platform = ${common.platform} board = ${common.board} upload_speed = ${common.upload_speed} @@ -58,7 +71,7 @@ lib_deps = ${common.lib_deps} painlessMesh [env:release] -src_filter = +<*> - + +src_filter = +<*> - + platform = ${common.platform} board = ${common.board} upload_speed = ${common.upload_speed} @@ -70,15 +83,16 @@ lib_deps = ${common.lib_deps} https://gitlab.com/wirelos/sprocket-plugin-web.git -;[env:mqttcat] -;src_filter = +<*> - + -;platform = ${common.platform} -;board = ${common.board} -;upload_speed = ${common.upload_speed} -;monitor_baud = ${common.monitor_baud} -;framework = ${common.framework} -;build_flags = -Wl,-Teagle.flash.4m1m.ld -; -DSPROCKET_PRINT=1 -;lib_deps = ${common.lib_deps} -; https://gitlab.com/wirelos/sprocket-lib.git#develop -; PubSubClient \ No newline at end of file +[env:mqcatt] +src_filter = +<*> - + +platform = ${common.platform} +board = ${common.board} +upload_speed = ${common.upload_speed} +monitor_baud = ${common.monitor_baud} +framework = ${common.framework} +build_flags = -Wl,-Teagle.flash.4m1m.ld + -DSPROCKET_PRINT=1 +lib_deps = ${common.lib_deps} + https://gitlab.com/wirelos/sprocket-plugin-web.git + https://gitlab.com/wirelos/sprocket-plugin-mqtt.git + PubSubClient \ No newline at end of file diff --git a/src/var/mqcatt/main.cpp b/src/var/mqcatt/main.cpp new file mode 100644 index 0000000..e7b1e76 --- /dev/null +++ b/src/var/mqcatt/main.cpp @@ -0,0 +1,52 @@ +#include "mqcatt_config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +WiFiNet *network; +Sprocket *sprocket; +AsyncWebServer *server; +WebServerPlugin *webServerPlugin; +WebConfigPlugin *webConfigPlugin; +WebApiPlugin *webApiPlugin; +PixelPlugin *pixelPlugin; +MqttPlugin *mqttPlugin; + +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}); + mqttPlugin = new MqttPlugin({MQTT_CLIENT_NAME, MQTT_HOST, MQTT_PORT, MQTT_TOPIC_IN, MQTT_TOPIC_OUT}); + webServerPlugin = new WebServerPlugin({WEB_DOC_ROOT, WEB_CONTEXT_PATH, WEB_DEFAULT_FILE, WEB_PORT}); + webConfigPlugin = new WebConfigPlugin(webServerPlugin->server); + webApiPlugin = new WebApiPlugin(webServerPlugin->server); + sprocket->addPlugin(pixelPlugin); + sprocket->addPlugin(webServerPlugin); + sprocket->addPlugin(webConfigPlugin); + sprocket->addPlugin(webApiPlugin); + sprocket->addPlugin(mqttPlugin); + + network = new WiFiNet( + WIFI_MODE, + STATION_SSID, + STATION_PASSWORD, + AP_SSID, + AP_PASSWORD, + HOSTNAME, + CONNECT_TIMEOUT); + network->connect(); + + sprocket->activate(); +} + +void loop() +{ + sprocket->loop(); + yield(); +} \ No newline at end of file diff --git a/src/var/mqcatt/mqcatt_config.h b/src/var/mqcatt/mqcatt_config.h new file mode 100644 index 0000000..f6e26c5 --- /dev/null +++ b/src/var/mqcatt/mqcatt_config.h @@ -0,0 +1,55 @@ +#ifndef __MQCATT_CONFIG__ +#define __MQCATT_CONFIG__ + +// Scheduler config +#define _TASK_SLEEP_ON_IDLE_RUN +#define _TASK_STD_FUNCTION +#define _TASK_PRIORITY + +// Chip config +#define SPROCKET_TYPE "ILLUCAT" +#define SERIAL_BAUD_RATE 115200 +#define STARTUP_DELAY 1000 + +// Network config +#define WIFI_MODE 0 +#define WIFI_CHANNEL 11 +#define AP_SSID "illucat" +#define AP_PASSWORD "illumination" +#define MESH_PREFIX "illucat-mesh" +#define MESH_PASSWORD "th3r31sn0sp00n" +#define STATION_SSID "MyAP" +#define STATION_PASSWORD "th3r31sn0sp00n" +#define HOSTNAME "illucat" +#define CONNECT_TIMEOUT 10000 + +// pixel config +#define PIXEL_CONFIG_FILE "/pixelConfig.json" + +// mqtt config +#define MQTT_CLIENT_NAME "mqcatt" +#define MQTT_HOST "192.168.1.2" +#define MQTT_PORT 1883 +#define MQTT_TOPIC_IN "wirelos/illucat-in/" +#define MQTT_TOPIC_OUT "wirelos/illucat-out/" + +// OTA config +#define OTA_PORT 8266 +#define OTA_PASSWORD "" + +// WebServer +#define WEB_CONTEXT_PATH "/" +#define WEB_DOC_ROOT "/www" +#define WEB_DEFAULT_FILE "index.html" +#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 \ No newline at end of file diff --git a/src/wifi/main.cpp b/src/var/wifi/main.cpp similarity index 100% rename from src/wifi/main.cpp rename to src/var/wifi/main.cpp diff --git a/src/wifiMesh/main.cpp b/src/var/wifiMesh/main.cpp similarity index 100% rename from src/wifiMesh/main.cpp rename to src/var/wifiMesh/main.cpp From abc902d5a69309c5d8549c02ce20cbee8e744004 Mon Sep 17 00:00:00 2001 From: Patrick Balsiger Date: Fri, 16 Nov 2018 00:16:51 +0100 Subject: [PATCH 2/3] stuff --- platformio.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index 30fb3d6..e614484 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,8 +8,8 @@ ; Please visit documentation for the other options and examples ; http://docs.platformio.org/page/projectconf.html -[platformio] -env_default = build +;[platformio] +;env_default = build [common] framework = arduino From ae1f4689695b3627538b5c8e287356a8b8a67aa6 Mon Sep 17 00:00:00 2001 From: Patrick Balsiger Date: Fri, 16 Nov 2018 00:44:05 +0100 Subject: [PATCH 3/3] update ui --- data/www/favicon.ico | Bin 1150 -> 0 bytes data/www/{favicon-32x32.png => favicon.png} | Bin data/www/index.html | 4 ++++ data/www/styles.css | 2 +- platformio.ini | 4 ++-- src/var/mqcatt/main.cpp | 2 +- 6 files changed, 8 insertions(+), 4 deletions(-) delete mode 100644 data/www/favicon.ico rename data/www/{favicon-32x32.png => favicon.png} (100%) diff --git a/data/www/favicon.ico b/data/www/favicon.ico deleted file mode 100644 index 4b46de8a7255c52916b7717978e5e56b615ade99..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1150 zcmZXT>uM8G5XUEM?FFGNO{rKLZAcU?w#780+l!iPx;L8yX*Bf`sX{9KXwfKW#oB&Q z(Kiu%hCYf9u}1{I_?zq!DiZ#gIWzO0GdnX!B*kxhT=<`ry#bLa5xEL5VTtVs5quM8 zWAx6+-;Y1v<&JS>)A++)R9OcdFLFKwrusE78y|gB{eo==6gdxa?$ftS1Fi?xnQlU zw~_Nmo45rqLoS8-mVx>zpa9-bQ-NH&=ue1M-!*I*a%8#l3_J_ns+-Wlp2eS`{yA)m z$Tt0Y1`e=q;-A4*L(k$LrKWz5RmVOC^29eZ7X2>u>x`6N!nOu4r+E6SEiJRv=Qo)V zb4ua60oTWLp36$)S9mMK0$1CAbINf5chq=G)vllKlVH zk4?y}Gsq<|)bH2PkAU`|jc;CigZ&b^_HRJ@M?F@e&tlJzYmRkc&O@iwu#KhwyiWM}kjqq9rFQsP_V zz83q}q<_Qgt{|tdb*bk$Ijh{!+h6Ua0v>N5&>lO)>{9bSoHWq6^xh9KX=>O3AArw! zl{)n;=r`#%@_yX6;30QRl8g5f@5u4*Lm{WY8{s|NB5#M;eB*o!c)!kPY`kBm1b+xy ce>Z*(iJVv>hpE1)r&uQSystem
 bytes

+
+ +
+
diff --git a/data/www/styles.css b/data/www/styles.css index 91868a7..fb13cdf 100644 --- a/data/www/styles.css +++ b/data/www/styles.css @@ -31,7 +31,7 @@ .sui label { color: #b3b2b2; } -.sui button { +.sui button, .sui input[type=file] { background: #097479; color: #eeeeee; font-size: 0.9em; diff --git a/platformio.ini b/platformio.ini index e614484..30fb3d6 100644 --- a/platformio.ini +++ b/platformio.ini @@ -8,8 +8,8 @@ ; Please visit documentation for the other options and examples ; http://docs.platformio.org/page/projectconf.html -;[platformio] -;env_default = build +[platformio] +env_default = build [common] framework = arduino diff --git a/src/var/mqcatt/main.cpp b/src/var/mqcatt/main.cpp index e7b1e76..55ca206 100644 --- a/src/var/mqcatt/main.cpp +++ b/src/var/mqcatt/main.cpp @@ -23,7 +23,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}); mqttPlugin = new MqttPlugin({MQTT_CLIENT_NAME, MQTT_HOST, MQTT_PORT, MQTT_TOPIC_IN, MQTT_TOPIC_OUT}); - webServerPlugin = new WebServerPlugin({WEB_DOC_ROOT, WEB_CONTEXT_PATH, WEB_DEFAULT_FILE, WEB_PORT}); + webServerPlugin = new WebServerPlugin({WEB_CONTEXT_PATH, WEB_DOC_ROOT, WEB_DEFAULT_FILE, WEB_PORT}); webConfigPlugin = new WebConfigPlugin(webServerPlugin->server); webApiPlugin = new WebApiPlugin(webServerPlugin->server); sprocket->addPlugin(pixelPlugin);