Skip to content

Add a publish() function #113

Open
@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