Browse Source

Fix MQTT will topic

fastled
Xose Pérez 7 years ago
parent
commit
7e51b031f6
5 changed files with 4 additions and 5 deletions
  1. +1
    -2
      code/espurna/config/general.h
  2. BIN
      code/espurna/data/index.html.gz
  3. BIN
      code/espurna/data/password.html.gz
  4. +2
    -2
      code/espurna/mqtt.ino
  5. +1
    -1
      code/html/index.html

+ 1
- 2
code/espurna/config/general.h View File

@ -73,8 +73,7 @@
#define MQTT_BUTTON_TOPIC "/button" #define MQTT_BUTTON_TOPIC "/button"
#define MQTT_IP_TOPIC "/ip" #define MQTT_IP_TOPIC "/ip"
#define MQTT_VERSION_TOPIC "/version" #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_CONNECT_EVENT 0
#define MQTT_DISCONNECT_EVENT 1 #define MQTT_DISCONNECT_EVENT 1


BIN
code/espurna/data/index.html.gz View File


BIN
code/espurna/data/password.html.gz View File


+ 2
- 2
code/espurna/mqtt.ino View File

@ -78,7 +78,6 @@ void _mqttOnConnect(bool sessionPresent) {
// Build MQTT topics // Build MQTT topics
buildTopics(); buildTopics();
mqtt.setWill((mqttTopic + MQTT_HEARTBEAT_TOPIC).c_str(), MQTT_QOS, MQTT_RETAIN, (char *) "0");
// Say hello and report our IP and VERSION // Say hello and report our IP and VERSION
mqttSend(MQTT_IP_TOPIC, getIP().c_str()); mqttSend(MQTT_IP_TOPIC, getIP().c_str());
@ -141,7 +140,7 @@ void mqttConnect() {
DEBUG_MSG("[MQTT] Connecting to broker at %s", host); DEBUG_MSG("[MQTT] Connecting to broker at %s", host);
mqtt.setServer(host, port); mqtt.setServer(host, port);
mqtt.setKeepAlive(MQTT_KEEPALIVE).setCleanSession(false); 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)) { if ((strlen(user) > 0) && (strlen(pass) > 0)) {
DEBUG_MSG(" as user '%s'.", user); DEBUG_MSG(" as user '%s'.", user);
mqtt.setCredentials(user, pass); mqtt.setCredentials(user, pass);
@ -157,6 +156,7 @@ void mqttSetup() {
mqtt.onConnect(_mqttOnConnect); mqtt.onConnect(_mqttOnConnect);
mqtt.onDisconnect(_mqttOnDisconnect); mqtt.onDisconnect(_mqttOnDisconnect);
mqtt.onMessage(_mqttOnMessage); mqtt.onMessage(_mqttOnMessage);
buildTopics();
} }
void mqttLoop() { void mqttLoop() {


+ 1
- 1
code/html/index.html View File

@ -331,8 +331,8 @@
- <strong>&lt;root&gt;/relay/#</strong> 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.<br /> - <strong>&lt;root&gt;/relay/#</strong> 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.<br />
- <strong>&lt;root&gt;/led/#</strong> 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.<br /> - <strong>&lt;root&gt;/led/#</strong> 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.<br />
- <strong>&lt;root&gt;/ip</strong> The device will report to this topic its IP.<br /> - <strong>&lt;root&gt;/ip</strong> The device will report to this topic its IP.<br />
- <strong>&lt;root&gt;/heartbeat</strong> The device will report to this topic every few minutes.<br />
- <strong>&lt;root&gt;/version</strong> The device will report to this topic its firmware version on boot.<br /> - <strong>&lt;root&gt;/version</strong> The device will report to this topic its firmware version on boot.<br />
- <strong>&lt;root&gt;/status</strong> The device will report a 1 to this topic every few minutes. Upon MQTT disconnecting this will be set to 0.
</div> </div>
</fieldset> </fieldset>


Loading…
Cancel
Save