Open sheda opened 8 years ago
include // [...] AsyncMqttClient& mqttClient = Homie.getMqttClient(); void onMqttConnect(bool sessionPresent) { mqttClient.onMessage(onMqttMessage); uint16_t packetIdSub = mqttClient.subscribe("toto/titi/tata", 0); mqttClient.publish("toto/titi/tata/tutu", 0, false, "true", sizeof("true")); Serial << "Subscribing at QoS 1" << packetIdSub << endl; } // [...] void onMqttMessage(char topic, char payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) { Serial.println(" Publish received "); // ... Serial.println(payload); } // [...] void setup() { Serial.begin(115200); Serial << endl << endl; // [...] mqttClient.onConnect(onMqttConnect); Homie.setup(); } // [...] void loop() { Homie.loop(); }
// [...] AsyncMqttClient& mqttClient = Homie.getMqttClient(); void onMqttConnect(bool sessionPresent) { mqttClient.onMessage(onMqttMessage); uint16_t packetIdSub = mqttClient.subscribe("toto/titi/tata", 0); mqttClient.publish("toto/titi/tata/tutu", 0, false, "true", sizeof("true")); Serial << "Subscribing at QoS 1" << packetIdSub << endl; } // [...] void onMqttMessage(char topic, char payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) { Serial.println(" Publish received "); // ... Serial.println(payload); } // [...] void setup() { Serial.begin(115200); Serial << endl << endl; // [...] mqttClient.onConnect(onMqttConnect); Homie.setup(); } // [...] void loop() { Homie.loop(); }
The issue seems to be the "by reference" & :)
AsyncMqttClient& mqttClient = Homie.getMqttClient();
Hey n8twj, This pull request may interest you as well: https://github.com/marvinroger/homie-esp8266/pull/244