move all mqtt from statusservice to mqtt.start()

This commit is contained in:
proddy
2020-07-07 18:22:09 +02:00
parent deaea93b30
commit cef80dff12
4 changed files with 56 additions and 18 deletions

View File

@@ -255,9 +255,11 @@ void Mqtt::start(AsyncMqttClient * mqttClient) {
});
#ifndef EMSESP_STANDALONE
mqttClient_->onConnect([this](bool sessionPresent) { on_connect(); });
mqttClient_->setWill(make_topic(will_topic_, "status"), 1, true, "offline"); // with qos 1, retain true
mqttClient_->onMessage([this](char * topic, char * payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) {
on_message(topic, payload, len);
mqttClient_->onPublish([this](uint16_t packetId) { on_publish(packetId); });
});
#endif
}