diff --git a/mqtt/mqtt.tbh b/mqtt/mqtt.tbh index 1d5b4dc..a85deb5 100644 --- a/mqtt/mqtt.tbh +++ b/mqtt/mqtt.tbh @@ -117,7 +117,7 @@ declare sub callback_mqtt_notif(byref topic as string,byref data as string,remai #if MQTT_LARGE_PACKETS - declare sub mqtt_start_publish(byref topic as string, qos as en_qos_choices, length as dword) + declare sub mqtt_start_publish(byref topic as string, qos as en_qos_choices, length as dword, retain as boolean) 'API procedure, starts the procedure of publishing to the MQTT server (broker). Must be called before calling mqtt_continue_publish(). 'topic - Name of the topic to be published 'qos - QoS level diff --git a/mqtt/mqtt.tbs b/mqtt/mqtt.tbs index 408dbeb..e46123b 100644 --- a/mqtt/mqtt.tbs +++ b/mqtt/mqtt.tbs @@ -718,7 +718,7 @@ end sub #if MQTT_LARGE_PACKETS -sub mqtt_start_publish(byref topic as string, qos as en_qos_choices, length as dword) +sub mqtt_start_publish(byref topic as string, qos as en_qos_choices, length as dword, retain as boolean) 'API procedure, starts the procedure of publishing to the MQTT server (broker). Must be called before calling mqtt_continue_publish(). 'topic - Name of the topic to be published 'qos - QoS level @@ -752,7 +752,13 @@ sub mqtt_start_publish(byref topic as string, qos as en_qos_choices, length as d else buf=chr(0)+chr(len(topic))+topic+mqtt_get_packet_identifier() end if - buf=chr(PUBLISH+1+(qos*2))+mqtt_build_remaining_length(len(buf) + length) + buf + + if retain then + buf=chr(PUBLISH+1+(qos*2))+mqtt_build_remaining_length(len(buf) + length) + buf + else + buf=chr(PUBLISH+(qos*2))+mqtt_build_remaining_length(len(buf) + length) + buf + end if + mqtt_send_data(buf) end sub