ArduinoMqttClient icon indicating copy to clipboard operation
ArduinoMqttClient copied to clipboard

Add a `publish()` function

Open hmueller01 opened this issue 1 year ago • 1 comments

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.

hmueller01 avatar Nov 10 '24 09:11 hmueller01

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 ... ;-)

hmueller01 avatar Dec 03 '24 20:12 hmueller01