diff --git a/.gitignore b/.gitignore index 9f963cf..82f7f17 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,6 @@ /Release/ +ConfigGenerator/configuration.cpp +ConfigGenerator/configuration.h +~* +*~ + diff --git a/.vscode/ipch/4c5e97abbb9a812a/mmap_address.bin b/.vscode/ipch/4c5e97abbb9a812a/mmap_address.bin new file mode 100644 index 0000000..862b842 Binary files /dev/null and b/.vscode/ipch/4c5e97abbb9a812a/mmap_address.bin differ diff --git a/.vscode/ipch/4c5e97abbb9a812a/productionMode.ipch b/.vscode/ipch/4c5e97abbb9a812a/productionMode.ipch new file mode 100644 index 0000000..0d3f91b Binary files /dev/null and b/.vscode/ipch/4c5e97abbb9a812a/productionMode.ipch differ diff --git a/.vscode/ipch/724217c09c04d0aa/PRODUCTIONMODE.ipch b/.vscode/ipch/724217c09c04d0aa/PRODUCTIONMODE.ipch new file mode 100644 index 0000000..1ae29fe Binary files /dev/null and b/.vscode/ipch/724217c09c04d0aa/PRODUCTIONMODE.ipch differ diff --git a/.vscode/ipch/724217c09c04d0aa/mmap_address.bin b/.vscode/ipch/724217c09c04d0aa/mmap_address.bin new file mode 100644 index 0000000..862b842 Binary files /dev/null and b/.vscode/ipch/724217c09c04d0aa/mmap_address.bin differ diff --git a/ConfigGenerator/configGen.py b/ConfigGenerator/configGen.py index d4f79ad..9266a21 100644 --- a/ConfigGenerator/configGen.py +++ b/ConfigGenerator/configGen.py @@ -16,6 +16,7 @@ configItems = [ {"label":"MQTT Password", "key":"mqttPass", "type":"C", "length":32, "default":"geheim123"}, {"label":"MQTT ClientId", "key":"mqttClientId", "type":"C", "length":32, "default":"RgbLed1"}, {"label":"MQTT Port", "key":"mqttPort", "type":"I", "default":8883}, + {"label":"MQTT Topic Color Command", "key":"mqttTopicColorCommand", "type":"C", "length":64, "default":"IoT/RgbLed1/ColorCommand"}, {"label":"MQTT Topic Command", "key":"mqttTopicCommand", "type":"C", "length":64, "default":"IoT/RgbLed1/Command"}, {"label":"MQTT DebugTopic", "key":"mqttDebugTopic", "type":"C", "length":64, "default":"IoT/RgbLed1/Debug"}, {"label":"DebugMode", "key":"debugMode", "type":"I", "default":0} diff --git a/productionMode.cpp b/productionMode.cpp index 83b1a25..c04dbc9 100644 --- a/productionMode.cpp +++ b/productionMode.cpp @@ -24,6 +24,8 @@ #include "configuration.h" +#define MAX_TOKENS 5 + void callback(char* topic, byte* payload, unsigned int length); @@ -70,7 +72,7 @@ void setup_wifi() { static CRGB evaluationColorWord(char* cmd) { uint8_t red = 0, green = 0, blue = 0; - if (! strcmp(cmd, "on")) { + if ((! strcmp(cmd, "on")) || (! strcmp(cmd, "white")) { red = 255; green = 255; blue = 255; @@ -129,31 +131,37 @@ void callback(char* topic, byte* payload, unsigned int length) { #endif - if (! strcmp(topic, configBlock.mqttTopicCommand)) { - char *inbuf = buffer; - char *tk = NULL; - uint8_t tokenCnt = 0; - #define MAX_TOKENS 5 - char *tokens[MAX_TOKENS]; - do { - tk = strtok(inbuf, " "); - inbuf = NULL; - tokens[tokenCnt] = tk; - if (tk) { - tokenCnt++; - Serial.print("TokenCnt: "); - Serial.print(tokenCnt); - Serial.println(); - } - } while (tk); + char *inbuf = buffer; + char *tk = NULL; + uint8_t tokenCnt = 0; + char *tokens[MAX_TOKENS]; + do { + if (tokenCnt >= MAX_TOKENS) { + break; + } + tk = strtok(inbuf, " "); + inbuf = NULL; + tokens[tokenCnt] = tk; + if (tk) { + tokenCnt++; + Serial.print("TokenCnt: "); + Serial.print(tokenCnt); + Serial.println(); + } + } while (tk); - for (uint8_t i = 0; i < tokenCnt; i++) { - Serial.print("Token "); - Serial.print(i); - Serial.print(": "); - Serial.println(tokens[i]); - } + for (uint8_t i = 0; i < tokenCnt; i++) { + Serial.print("Token "); + Serial.print(i); + Serial.print(": "); + Serial.println(tokens[i]); + } + + if (! strcmp(topic, configBlock.mqttTopicCommand)) { + int32_t n; + + } else if (! strcmp(topic, configBlock.mqttTopicColorCommand)) { int32_t n, red, green, blue; CRGB colors; switch (tokenCnt) { @@ -193,10 +201,10 @@ void callback(char* topic, byte* payload, unsigned int length) { red = strtol(tokens[1], NULL, 10); green = strtol(tokens[2], NULL, 10); blue = strtol(tokens[3], NULL, 10); - leds[n].r = red; - leds[n].g = green; - leds[n].b = blue; - FastLED.show(); + leds[n].r = red; + leds[n].g = green; + leds[n].b = blue; + FastLED.show(); } break; } @@ -227,6 +235,7 @@ void reconnect() { client.publish(configBlock.mqttDebugTopic, "hello world"); client.publish(configBlock.mqttDebugTopic, WiFi.localIP().toString().c_str()); + client.subscribe(configBlock.mqttTopicColorCommand); client.subscribe(configBlock.mqttTopicCommand); } else { #ifdef DEBUG