MQTT Client Retain Feature (#793)

Optionally allow MQTT client to publish specific messages with
the retain flag set.

default/current behavior should not be impacted.
This commit is contained in:
Dustin
2017-03-21 14:47:07 +01:00
committed by Henrik Ekblad
parent 61a415c422
commit ef42b3b534
3 changed files with 15 additions and 1 deletions
+7 -1
View File
@@ -56,7 +56,13 @@ bool gatewayTransportSend(MyMessage &message)
setIndication(INDICATION_GW_TX);
char *topic = protocolFormatMQTTTopic(MY_MQTT_PUBLISH_TOPIC_PREFIX, message);
debug(PSTR("Sending message on topic: %s\n"), topic);
return _MQTT_client.publish(topic, message.getString(_convBuffer));
#ifdef MY_MQTT_CLIENT_PUBLISH_RETAIN
bool retain = mGetCommand(message) == C_SET ||
(mGetCommand(message) == C_INTERNAL && message.type == I_BATTERY_LEVEL);
#else
bool retain = false;
#endif
return _MQTT_client.publish(topic, message.getString(_convBuffer), retain);
}
void incomingMQTT(char* topic, uint8_t* payload, unsigned int length)