Skip to content

Commit f0ffdd7

Browse files
committedNov 17, 2024·
simplify publish function
1 parent a6212f5 commit f0ffdd7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed
 

‎src/MqttClient.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,10 @@ int MqttClient::endMessage()
272272
*/
273273
int MqttClient::publish(const char* topic, const char* payload, bool retain, uint8_t qos, bool dup) {
274274
int ret = beginMessage(topic, strlen_P(payload), retain, qos, dup);
275-
if (!ret) {
276-
return ret;
275+
if (ret) {
276+
print(payload);
277+
ret = endMessage();
277278
}
278-
print(payload);
279-
ret = endMessage();
280279
return ret;
281280
}
282281

0 commit comments

Comments
 (0)