ArduinoMqttClient
ArduinoMqttClient copied to clipboard
Add a `publish()` function
Can we add a function to publish messages in one call like this
int MqttClient::publish(const char* topic, const char *payload, bool retain = false, uint8_t qos = 0, bool dup = false);
int MqttClient::publish(const char *topic, const char *payload, bool retain, uint8_t qos, bool dup) {
int ret = beginMessage(topic, strlen_P(payload), retain, qos, dup);
if (!ret) {
return ret;
}
print(payload);
ret = endMessage();
return ret;
}
(and corresponding functions using Strings) This would make porting from other MQTT libs easier and save lines of code. If approved I can do a PR.
I was looking for an thin and actively maintained mqtt client. Currently I use pubsubclient, which unfortunately is not maintained by @knolleary any more. This PR makes porting from pubsubclient so much easier. I think a lot of people could make use of it. And I made it to test, how good maintained this repo is ... ;-)