From bdac63fa8a29c6303908ce5e8600456e61896db9 Mon Sep 17 00:00:00 2001 From: Andrey Klimov Date: Mon, 4 Mar 2019 15:47:12 +0300 Subject: [PATCH 1/3] homie topic strucrure correction --- lighthub/item.cpp | 16 +++++++------- lighthub/item.h | 4 ++-- lighthub/main.cpp | 54 +++++++++++++++++++++------------------------- lighthub/options.h | 5 ++++- 4 files changed, 39 insertions(+), 40 deletions(-) diff --git a/lighthub/item.cpp b/lighthub/item.cpp index ac14fb2..b5e763b 100644 --- a/lighthub/item.cpp +++ b/lighthub/item.cpp @@ -198,7 +198,7 @@ boolean Item::getEnableCMD(int delta) { #define MAXCTRLPAR 3 -int Item::Ctrl(char * payload, boolean send){ +int Item::Ctrl(char * payload, boolean send, char * subItem){ if (!payload) return 0; // debugSerial< "); } debugSerial<name,sizeof(topic)); strncat(topic,"/",sizeof(topic)); @@ -450,7 +446,7 @@ void onMQTTConnect(){ if (format[0]) { //strncpy_P(topic, outprefix, sizeof(topic)); - setTopic(topic,sizeof(topic),T_OUT); + setTopic(topic,sizeof(topic),T_DEV); strncat(topic,item->name,sizeof(topic)); strncat(topic,"/",sizeof(topic)); @@ -460,7 +456,7 @@ void onMQTTConnect(){ item = item->next; } //if //strncpy_P(topic, outprefix, sizeof(topic)); - setTopic(topic,sizeof(topic),T_OUT); + setTopic(topic,sizeof(topic),T_DEV); strncat_P(topic, nodes_P, sizeof(topic)); mqttClient.publish(topic,buf,true); } @@ -519,7 +515,7 @@ void ip_ready_config_loaded_connecting_to_broker() { strncpy_P(willMessage,disconnected_P,sizeof(willMessage)); // strncpy_P(willTopic, outprefix, sizeof(willTopic)); - setTopic(willTopic,sizeof(willTopic),T_OUT); + setTopic(willTopic,sizeof(willTopic),T_DEV); strncat_P(willTopic, state_P, sizeof(willTopic)); diff --git a/lighthub/options.h b/lighthub/options.h index 2ac7360..ff6839a 100644 --- a/lighthub/options.h +++ b/lighthub/options.h @@ -82,14 +82,17 @@ #endif */ +//Default output topic #ifndef OUTTOPIC #define OUTTOPIC "s_out" #endif +//Topic to receive CLI commands #ifndef CMDTOPIC -#define CMDTOPIC "command" +#define CMDTOPIC "$command" #endif +//Default broadcast topic #ifndef INTOPIC #define INTOPIC "in" #endif From ac71e4436b8731af6ae0137b4b92c3f8cfd60e2c Mon Sep 17 00:00:00 2001 From: Andrey Klimov Date: Mon, 4 Mar 2019 16:02:17 +0300 Subject: [PATCH 2/3] fix --- lighthub/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lighthub/main.cpp b/lighthub/main.cpp index 388417a..b3a6f38 100644 --- a/lighthub/main.cpp +++ b/lighthub/main.cpp @@ -227,11 +227,13 @@ else { *subItem = 0; subItem++; + if (*subItem=='$') return; //Skipping homie stuff + // debugSerial< Date: Mon, 4 Mar 2019 16:07:45 +0300 Subject: [PATCH 3/3] due compilation fix --- lighthub/utils.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lighthub/utils.cpp b/lighthub/utils.cpp index 7844dd0..84bb0d2 100644 --- a/lighthub/utils.cpp +++ b/lighthub/utils.cpp @@ -369,7 +369,7 @@ void printIPAddress(IPAddress ipAddress) { } -char* setTopic(char* buf, int8_t buflen, topicType tt, char* suffix=NULL) +char* setTopic(char* buf, int8_t buflen, topicType tt, char* suffix) { aJsonObject *_root = NULL; aJsonObject *_l2 = NULL;