Skip to content

Add a publish() function #113

@hmueller01

Description

@hmueller01

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselftype: enhancementProposed improvement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy