Closed gamerpaddy closed 3 years ago
I noticed that the example code for 2 subs only reads the last subscribed topic on startup.
Example:
Adafruit_MQTT_Subscribe onoff = Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/lamp/onoff"); Adafruit_MQTT_Subscribe dimming= Adafruit_MQTT_Subscribe(&mqtt, AIO_USERNAME "/lamp/dim");
...
mqtt.subscribe(&dimming); mqtt.subscribe(&onoff);
(i suspect the error over here, subscribe overwrites the previous subscribe?) ...
Adafruit_MQTT_Subscribe *subscription; while ((subscription = mqtt.readSubscription(5000))) { if (subscription == &onoff ) { Serial.print(F("Got onoff: ")); Serial.println((char *)onoff.lastread); } if (subscription == &dimming) { Serial.print(F("Got dimming: ")); Serial.println((char *)dimming.lastread); } }
my most recent Mosquitto feed looks like this:
... /lamp/dim 54 /lamp/dim 30 /lamp/dim 8 /lamp/onoff 1 /lamp/onoff 0 /lamp/onoff 1 /lamp/dim 23 /lamp/test 1
The ESP8266 with the "2 subs example code "only prints this on startup:
Connecting to MQTT... Dropped a packet MQTT Connected! Got onoff: 1
not the /lamp/dim subscription. It only prints that, when i update it after it booted up or when i reverse the order of "mqtt.subscribe(..."
The expected behaviour is that my ESP8266 prints
Got onoff: 1 Got dimming: 23
Since these are the two last known values for this topics.
@gamerpaddy This issue has been fixed in the latest release. Please try it!
I noticed that the example code for 2 subs only reads the last subscribed topic on startup.
Example:
...
(i suspect the error over here, subscribe overwrites the previous subscribe?) ...
my most recent Mosquitto feed looks like this:
The ESP8266 with the "2 subs example code "only prints this on startup:
not the /lamp/dim subscription. It only prints that, when i update it after it booted up or when i reverse the order of "mqtt.subscribe(..."
The expected behaviour is that my ESP8266 prints
Since these are the two last known values for this topics.