add new command
This commit is contained in:
parent
483a39e30c
commit
012b0d4831
5
.gitignore
vendored
5
.gitignore
vendored
@ -1 +1,6 @@
|
|||||||
/Release/
|
/Release/
|
||||||
|
ConfigGenerator/configuration.cpp
|
||||||
|
ConfigGenerator/configuration.h
|
||||||
|
~*
|
||||||
|
*~
|
||||||
|
|
||||||
|
BIN
.vscode/ipch/4c5e97abbb9a812a/mmap_address.bin
vendored
Normal file
BIN
.vscode/ipch/4c5e97abbb9a812a/mmap_address.bin
vendored
Normal file
Binary file not shown.
BIN
.vscode/ipch/4c5e97abbb9a812a/productionMode.ipch
vendored
Normal file
BIN
.vscode/ipch/4c5e97abbb9a812a/productionMode.ipch
vendored
Normal file
Binary file not shown.
BIN
.vscode/ipch/724217c09c04d0aa/PRODUCTIONMODE.ipch
vendored
Normal file
BIN
.vscode/ipch/724217c09c04d0aa/PRODUCTIONMODE.ipch
vendored
Normal file
Binary file not shown.
BIN
.vscode/ipch/724217c09c04d0aa/mmap_address.bin
vendored
Normal file
BIN
.vscode/ipch/724217c09c04d0aa/mmap_address.bin
vendored
Normal file
Binary file not shown.
@ -16,6 +16,7 @@ configItems = [
|
|||||||
{"label":"MQTT Password", "key":"mqttPass", "type":"C", "length":32, "default":"geheim123"},
|
{"label":"MQTT Password", "key":"mqttPass", "type":"C", "length":32, "default":"geheim123"},
|
||||||
{"label":"MQTT ClientId", "key":"mqttClientId", "type":"C", "length":32, "default":"RgbLed1"},
|
{"label":"MQTT ClientId", "key":"mqttClientId", "type":"C", "length":32, "default":"RgbLed1"},
|
||||||
{"label":"MQTT Port", "key":"mqttPort", "type":"I", "default":8883},
|
{"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 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":"MQTT DebugTopic", "key":"mqttDebugTopic", "type":"C", "length":64, "default":"IoT/RgbLed1/Debug"},
|
||||||
{"label":"DebugMode", "key":"debugMode", "type":"I", "default":0}
|
{"label":"DebugMode", "key":"debugMode", "type":"I", "default":0}
|
||||||
|
@ -24,6 +24,8 @@
|
|||||||
#include "configuration.h"
|
#include "configuration.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define MAX_TOKENS 5
|
||||||
|
|
||||||
|
|
||||||
void callback(char* topic, byte* payload, unsigned int length);
|
void callback(char* topic, byte* payload, unsigned int length);
|
||||||
|
|
||||||
@ -70,7 +72,7 @@ void setup_wifi() {
|
|||||||
|
|
||||||
static CRGB evaluationColorWord(char* cmd) {
|
static CRGB evaluationColorWord(char* cmd) {
|
||||||
uint8_t red = 0, green = 0, blue = 0;
|
uint8_t red = 0, green = 0, blue = 0;
|
||||||
if (! strcmp(cmd, "on")) {
|
if ((! strcmp(cmd, "on")) || (! strcmp(cmd, "white")) {
|
||||||
red = 255;
|
red = 255;
|
||||||
green = 255;
|
green = 255;
|
||||||
blue = 255;
|
blue = 255;
|
||||||
@ -129,13 +131,14 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (! strcmp(topic, configBlock.mqttTopicCommand)) {
|
|
||||||
char *inbuf = buffer;
|
char *inbuf = buffer;
|
||||||
char *tk = NULL;
|
char *tk = NULL;
|
||||||
uint8_t tokenCnt = 0;
|
uint8_t tokenCnt = 0;
|
||||||
#define MAX_TOKENS 5
|
|
||||||
char *tokens[MAX_TOKENS];
|
char *tokens[MAX_TOKENS];
|
||||||
do {
|
do {
|
||||||
|
if (tokenCnt >= MAX_TOKENS) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
tk = strtok(inbuf, " ");
|
tk = strtok(inbuf, " ");
|
||||||
inbuf = NULL;
|
inbuf = NULL;
|
||||||
tokens[tokenCnt] = tk;
|
tokens[tokenCnt] = tk;
|
||||||
@ -154,6 +157,11 @@ void callback(char* topic, byte* payload, unsigned int length) {
|
|||||||
Serial.println(tokens[i]);
|
Serial.println(tokens[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (! strcmp(topic, configBlock.mqttTopicCommand)) {
|
||||||
|
int32_t n;
|
||||||
|
|
||||||
|
} else if (! strcmp(topic, configBlock.mqttTopicColorCommand)) {
|
||||||
int32_t n, red, green, blue;
|
int32_t n, red, green, blue;
|
||||||
CRGB colors;
|
CRGB colors;
|
||||||
switch (tokenCnt) {
|
switch (tokenCnt) {
|
||||||
@ -227,6 +235,7 @@ void reconnect() {
|
|||||||
client.publish(configBlock.mqttDebugTopic, "hello world");
|
client.publish(configBlock.mqttDebugTopic, "hello world");
|
||||||
client.publish(configBlock.mqttDebugTopic, WiFi.localIP().toString().c_str());
|
client.publish(configBlock.mqttDebugTopic, WiFi.localIP().toString().c_str());
|
||||||
|
|
||||||
|
client.subscribe(configBlock.mqttTopicColorCommand);
|
||||||
client.subscribe(configBlock.mqttTopicCommand);
|
client.subscribe(configBlock.mqttTopicCommand);
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
Loading…
x
Reference in New Issue
Block a user