From 7e51b031f67e68b4cc7aaef3ed0ef46a9c917214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xose=20P=C3=A9rez?= Date: Sat, 21 Jan 2017 15:38:38 +0100 Subject: [PATCH] Fix MQTT will topic --- code/espurna/config/general.h | 3 +-- code/espurna/data/index.html.gz | Bin 3547 -> 3565 bytes code/espurna/data/password.html.gz | Bin 602 -> 791 bytes code/espurna/mqtt.ino | 4 ++-- code/html/index.html | 2 +- 5 files changed, 4 insertions(+), 5 deletions(-) diff --git a/code/espurna/config/general.h b/code/espurna/config/general.h index 3032f5d8..88fb2ad6 100644 --- a/code/espurna/config/general.h +++ b/code/espurna/config/general.h @@ -73,8 +73,7 @@ #define MQTT_BUTTON_TOPIC "/button" #define MQTT_IP_TOPIC "/ip" #define MQTT_VERSION_TOPIC "/version" -#define MQTT_FSVERSION_TOPIC "/fsversion" -#define MQTT_HEARTBEAT_TOPIC "/heartbeat" +#define MQTT_HEARTBEAT_TOPIC "/status" #define MQTT_CONNECT_EVENT 0 #define MQTT_DISCONNECT_EVENT 1 diff --git a/code/espurna/data/index.html.gz b/code/espurna/data/index.html.gz index 0f4ed80475d5713134ac395ef4e32060d9b5a39c..116a554a57d7d8496cd2eec21f59e713ecb1c773 100644 GIT binary patch literal 3565 zcmVj= znDkZRF*8lYsV8GT7M-V-?F%z8I`u~U5u0uJ<2kSik74km6q6Kycnn?}k-#z&8JO@i z5HLfusIe~-X(W$Y+UJotJ*?wkrjgL05T;m+dfL9$Fs@^X9I9a2I|<|?lfkJM@u|uU zyyb4jH?c@^kKW87Q5CR(l=$Itb*5Hp#K zy(aH1^gNoM5lL-`_W4)Rh`36Sw`ev}6>!6$mnQ<)X}HOOOZS7b!RLD-s1wO8E-)5} z$av)Se!RTCygU1}gC(@^^Gup4P;q(w`K~|sWe1B)x^H(RiiN3~rO zbD6Y;xiKoi-D{s};9ZyfY2_)bA-vva`aS8`?jC!2W+uSkB*F*Q-xZIm%?F!^bK$3) zchUh`>VGT5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8UIU>evkF@qwjU4&!K~tA0of^-6(+_yY_8)Ck(_+dLj9dmSbeh%Zr zL8CYsu#CI*P(42rEw~CS&TXzaRv4!8v1GL85==DGg?d34XUq(8 zIizCjat2T|Kg?5yCr)t@13U(=2rO-q&&(($4rVE6Br()N7?x-wvjC!M1dOxR63*tv z$DD*1Wby+R(|BFcCpYz_Llq0EVu2LIx)ARlRZ>g{b&?1|gHT2wt23{(_U4C1bCliT zy&_8&K5j~t0keRn?<*v=Ya|_i_;9jATE3`4M)c(=Zp zS@b@`fSnwnccDhwQP|_6B7DzlqG%b}z z_^eEIw2FENQMaI-+2W@Z7LU(YmwB)>=1-888QKnW4xE^mSt<~_A@v`zjX@1K(SZAy zEiU8(f?byjIOnxI;K_^u^%w~hOQyO;I*PA%w+bW#7O5UWaTVT+;+1&P)04_OoII zn7v+IJ=f#G^WsyzSL&daqnGc!YnVBAM_VrA4`%WJ1f#4^4^rEw&WUf91H7 z-_W=q_t$+=zJ;=m3X&4U(m`@{kp+>?hq7|MukX5}JqA8KK^~|ED}3-^T^Oc|XpA$3 z&TX-hMf?%6b zaPoES9g4QN0`V6UF5;!|nn#mdVO`r=mGZ_0mbguCOoMqJN{|?0i2Hp+eI9W=J;Vk| z@=p+8aSg`_(6x6cz~V;EUrd1KcvVs1wWBS!rwQWG+QLTF69(H9d-Ozt;Rd%NGbcfH zNO%(*fb~4BnMbJP5q3xCo&#u!6TnMm;6gCs9ofL!!kBPCa1&Kov!q^<=6&fShq9yD zacO;i#XZ-KucdLGcq7E7dcf7&8{@e_ib@gBeo*4!ixdNR6LF8sC8p^*mEi?fmTL7> zyhR(CwH)R;?|A*jH_Z4xCv~>#GwTd6EnJly8D#XVbgM^}A$(_OJa15|p3vL=%Dd4{x@qfO{VjWLH006^OvMm4r diff --git a/code/espurna/data/password.html.gz b/code/espurna/data/password.html.gz index 2bb3023e2894a81d65e1c822bf5341c1dbd8b231..8f9b50ba71850496862d580f0477cac86b434004 100644 GIT binary patch literal 791 zcmV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NUswzm6!Rr2D-FqwHX2D;P zC$MOdB-D-c0jU%{ZL_bUDvY)-;L(&KG|p4q6X@Dm0d(lF6uOl=%wMyFH6FL6*vfs} zE_e`=td%X3_Zo+eMFj9Mq2*@=t*9v#@(s+!%_nU&X=$=hOM~TdZUY?*h6a(2kB!Kp z4uN@ja&qI;p(>Q#gI1+5^5A+B38;+>p%l~e3~rroM_ODw$UTZ9r|Ugt5fvb7($1D5 z7r@>$j_I8XXPTX~XatP*ltSsy@yp*f#?>!#Vl)yxW6iR9xW9Y){qymeOgacR-B}kYWSu1T<_Pkc&yOJ6<)&r(4+@f{vvJ=N0hv@t_ar;Zmwr+sg$!Mx_&H z(8j=KtH^6aHz&8gK)egXp)i#uEpwh6a5yR`P7!a1GL` z*;ThkpD~b0?V<0KBn&5o1xI4VndEq#MR$iWT^fzz`kbG|OzmQw$PJnq+Gk6c7Ol#b z*%uN0EyWm@HS@T>)>S>&dJi&bZEs05K8e^}WL8+5N o?R7^Ge9i4Xt`~pCc2Aolp*q@IUfjH$<>T+~FTMY96chyj0952GkpKVy diff --git a/code/espurna/mqtt.ino b/code/espurna/mqtt.ino index b0302d55..f5658b68 100644 --- a/code/espurna/mqtt.ino +++ b/code/espurna/mqtt.ino @@ -78,7 +78,6 @@ void _mqttOnConnect(bool sessionPresent) { // Build MQTT topics buildTopics(); - mqtt.setWill((mqttTopic + MQTT_HEARTBEAT_TOPIC).c_str(), MQTT_QOS, MQTT_RETAIN, (char *) "0"); // Say hello and report our IP and VERSION mqttSend(MQTT_IP_TOPIC, getIP().c_str()); @@ -141,7 +140,7 @@ void mqttConnect() { DEBUG_MSG("[MQTT] Connecting to broker at %s", host); mqtt.setServer(host, port); mqtt.setKeepAlive(MQTT_KEEPALIVE).setCleanSession(false); - mqtt.setWill(MQTT_HEARTBEAT_TOPIC, MQTT_QOS, MQTT_RETAIN, "0"); + mqtt.setWill((mqttTopic + MQTT_HEARTBEAT_TOPIC).c_str(), MQTT_QOS, MQTT_RETAIN, "0"); if ((strlen(user) > 0) && (strlen(pass) > 0)) { DEBUG_MSG(" as user '%s'.", user); mqtt.setCredentials(user, pass); @@ -157,6 +156,7 @@ void mqttSetup() { mqtt.onConnect(_mqttOnConnect); mqtt.onDisconnect(_mqttOnDisconnect); mqtt.onMessage(_mqttOnMessage); + buildTopics(); } void mqttLoop() { diff --git a/code/html/index.html b/code/html/index.html index 7c0736d4..b28c70e5 100644 --- a/code/html/index.html +++ b/code/html/index.html @@ -331,8 +331,8 @@ - <root>/relay/# Send a 0 or a 1 as a payload to this topic to switch it on or off. You can also send a 2 to toggle its current state. Replace # with the relay ID (starting from 0). If the board has only one relay it will be 0.
- <root>/led/# Send a 0 or a 1 as a payload to this topic to set the onboard LED to the given state, send a 3 to turn it back to WIFI indicator. Replace # with the LED ID (starting from 0). If the board has only one LED it will be 0.
- <root>/ip The device will report to this topic its IP.
- - <root>/heartbeat The device will report to this topic every few minutes.
- <root>/version The device will report to this topic its firmware version on boot.
+ - <root>/status The device will report a 1 to this topic every few minutes. Upon MQTT disconnecting this will be set to 0.