Skip to content

Add a publish() function #113

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
hmueller01 opened this issue Nov 10, 2024 · 1 comment · May be fixed by #114
Open

Add a publish() function #113

hmueller01 opened this issue Nov 10, 2024 · 1 comment · May be fixed by #114
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement

Comments

@hmueller01
Copy link

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.

@per1234 per1234 added type: enhancement Proposed improvement topic: code Related to content of the project itself labels Nov 10, 2024
@per1234 per1234 changed the title Can we add a publish() function? Add a publish() function Nov 10, 2024
@hmueller01 hmueller01 linked a pull request Nov 11, 2024 that will close this issue
@hmueller01
Copy link
Author

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants