From ed191f28e7a1134608b9ef86cbad923881356b97 Mon Sep 17 00:00:00 2001 From: Andreas Doebeli Date: Mon, 14 Sep 2020 03:01:16 +0200 Subject: [PATCH] got connection to mqtt broker working again --- .gitignore | 1 + .vscode/extensions.json | 12 ++--- data/config/mqtt.json | 9 ++++ data/config/wifi.json | 4 +- data/mqttConfig.json | 11 +++-- data/www/index.html | 82 +++++++++++++--------------------- platformio.ini | 4 +- src/config.h | 31 ++++++------- src/var/mqcatt/main.cpp | 5 ++- src/var/mqcatt/mqcatt_config.h | 41 ++++++++--------- 10 files changed, 98 insertions(+), 102 deletions(-) create mode 100644 data/config/mqtt.json diff --git a/.gitignore b/.gitignore index d657492..315bb1e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .pioenvs .piolibdeps +.pio .vscode data/config.json \ No newline at end of file diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 8281e64..0f0d740 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,7 +1,7 @@ { - // See http://go.microsoft.com/fwlink/?LinkId=827846 - // for the documentation about the extensions.json format - "recommendations": [ - "platformio.platformio-ide" - ] -} \ No newline at end of file + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ] +} diff --git a/data/config/mqtt.json b/data/config/mqtt.json new file mode 100644 index 0000000..66b7f3b --- /dev/null +++ b/data/config/mqtt.json @@ -0,0 +1,9 @@ +{ + "mqttClientName": "illucat1", + "mqttBrokerHost": "192.168.88.110", + "mqttBrokerPort": 1883, + "mqttRootTopic": "wirelos/illucat", + "mqttUser": "", + "mqttPass": "" + +} \ No newline at end of file diff --git a/data/config/wifi.json b/data/config/wifi.json index b80fdf3..5d77bfb 100644 --- a/data/config/wifi.json +++ b/data/config/wifi.json @@ -4,6 +4,6 @@ "apSSID": "illucat", "apPassword": "illumination", "connectTimeout": 5000, - "stationSSID": "wirelos", - "stationPassword": "th3r31sn0sp00n" + "stationSSID": "thobens-416257", + "stationPassword": "467304645DB5" } \ No newline at end of file diff --git a/data/mqttConfig.json b/data/mqttConfig.json index 36329d9..ec250fd 100644 --- a/data/mqttConfig.json +++ b/data/mqttConfig.json @@ -1,6 +1,9 @@ { - "mqttClientName" : "illucat1", - "mqttBrokerHost" : "192.168.1.2", - "mqttBrokerPort" : 1883, - "mqttRootTopic" : "wirelos/illucat" + "mqttClientName": "illucat1", + "mqttBrokerHost": "192.168.4.1", + "mqttBrokerPort": 1883, + "mqttRootTopic": "wirelos/illucat", + "mqttUser": "foo", + "mqttPass": "" + } \ No newline at end of file diff --git a/data/www/index.html b/data/www/index.html index 79aaa4b..6c609a4 100644 --- a/data/www/index.html +++ b/data/www/index.html @@ -16,47 +16,24 @@ Pixels
@@ -69,27 +46,30 @@
Settings
-

Network

-
-

NeoPixel

-
-
- System -
-
 bytes

-
- -
-
- -
+ System +
+
 bytes

+
+ +
+
+
+
diff --git a/platformio.ini b/platformio.ini index 89d285f..842bb17 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,8 +15,8 @@ framework = arduino platform = espressif8266@2.0.4 board = esp12e -upload_speed = 921600 -monitor_baud = 115200 +upload_speed = 115200 +monitor_baud = 74880 lib_deps = Hash TaskScheduler diff --git a/src/config.h b/src/config.h index 0225b6d..d8cb11e 100644 --- a/src/config.h +++ b/src/config.h @@ -7,23 +7,23 @@ #define _TASK_PRIORITY // Chip config -#define SPROCKET_TYPE "ILLUCAT" -#define SERIAL_BAUD_RATE 115200 -#define STARTUP_DELAY 1000 +#define SPROCKET_TYPE "ILLUCAT" +#define SERIAL_BAUD_RATE 74880 +#define STARTUP_DELAY 5000 // Mesh config -#define SPROCKET_MODE 0 -#define WIFI_CHANNEL 11 -#define MESH_PORT 5555 -#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 -#define MESH_DEBUG_TYPES ERROR | STARTUP | CONNECTION +#define SPROCKET_MODE 0 +#define WIFI_CHANNEL 11 +#define MESH_PORT 5555 +#define AP_SSID "illucat" +#define AP_PASSWORD "illumination" +#define MESH_PREFIX "illucat-mesh" +#define MESH_PASSWORD "th3r31sn0sp00n" +#define STATION_SSID "thobens-416257" +#define STATION_PASSWORD "467304645DB5" +#define HOSTNAME "illucat" +#define CONNECT_TIMEOUT 10000 +#define MESH_DEBUG_TYPES ERROR | STARTUP | CONNECTION //#define MESH_DEBUG_TYPES ERROR | MESH_STATUS | CONNECTION | SYNC | COMMUNICATION | GENERAL | MSG_TYPES | REMOTE #define PIXEL_CONFIG_FILE "/pixelConfig.json" @@ -46,5 +46,6 @@ #define LED_STRIP_DEFAULT_COLOR 100 #define COLOR_CONNECTED LED_STRIP_DEFAULT_COLOR #define COLOR_NOT_CONNECTED 255 +#define LED_STRIP_DEFAULT_PATTERN 1 #endif \ No newline at end of file diff --git a/src/var/mqcatt/main.cpp b/src/var/mqcatt/main.cpp index f01beb5..cb989cc 100644 --- a/src/var/mqcatt/main.cpp +++ b/src/var/mqcatt/main.cpp @@ -1,6 +1,7 @@ #include "mqcatt_config.h" #include #include +#include "../../IlluCat.h" #include #include #include @@ -21,7 +22,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_ROOT_TOPIC}); + mqttPlugin = new MqttPlugin({MQTT_CLIENT_NAME, MQTT_HOST, MQTT_PORT, MQTT_ROOT_TOPIC, MQTT_USER, MQTT_PASS}); webServerPlugin = new WebServerPlugin({WEB_CONTEXT_PATH, WEB_DOC_ROOT, WEB_DEFAULT_FILE, WEB_PORT}); webConfigPlugin = new WebConfigPlugin(webServerPlugin->server); webApiPlugin = new WebApiPlugin(webServerPlugin->server); @@ -42,7 +43,7 @@ void setup() network->connect(); webServerPlugin->server->serveStatic(PIXEL_CONFIG_FILE, SPIFFS, "pixelConfig.json"); - webServerPlugin->server->serveStatic(MQTT_CONFIG_FILE, SPIFFS, "mqttConfig.json"); + webServerPlugin->server->serveStatic(MQTT_CONFIG_FILE, SPIFFS, "config/mqtt.json"); sprocket->activate(); sprocket->publish("pixels/pattern", "1"); diff --git a/src/var/mqcatt/mqcatt_config.h b/src/var/mqcatt/mqcatt_config.h index 00b9bc5..8818072 100644 --- a/src/var/mqcatt/mqcatt_config.h +++ b/src/var/mqcatt/mqcatt_config.h @@ -7,25 +7,25 @@ #define _TASK_PRIORITY // Chip config -#define SPROCKET_TYPE "ILLUCAT" -#define SERIAL_BAUD_RATE 115200 -#define STARTUP_DELAY 1000 +#define SPROCKET_TYPE "ILLUCAT" +#define SERIAL_BAUD_RATE 74880 +#define STARTUP_DELAY 5000 // 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 +#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 "thobens-416257" +#define STATION_PASSWORD "467304645DB5" +#define HOSTNAME "illucat" +#define CONNECT_TIMEOUT 10000 // config files #define PIXEL_CONFIG_FILE "/pixelConfig.json" -#define MQTT_CONFIG_FILE "/mqttConfig.json" +#define MQTT_CONFIG_FILE "/config/mqtt.json" // NeoPixel #define LED_STRIP_PIN D2 @@ -35,17 +35,19 @@ #define LED_STRIP_DEFAULT_COLOR 100 #define COLOR_CONNECTED LED_STRIP_DEFAULT_COLOR #define COLOR_NOT_CONNECTED 255 - +#define LED_STRIP_DEFAULT_PATTERN 1 // 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" +#define MQTT_CLIENT_NAME "illucat" +#define MQTT_HOST "192.168.88.110" +#define MQTT_PORT 1883 +#define MQTT_ROOT_TOPIC "wirelos/illucat" +#define MQTT_USER "" +#define MQTT_PASS "" // WebServer #define WEB_CONTEXT_PATH "/" @@ -53,5 +55,4 @@ #define WEB_DEFAULT_FILE "index.html" #define WEB_PORT 80 - #endif \ No newline at end of file