Skip to content

Commit

Permalink
mqtt_start_publish with retain as parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
salhk committed May 23, 2024
1 parent 88f15bc commit 520c4fd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mqtt/mqtt.tbh
Original file line number Diff line number Diff line change
Expand Up @@ -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().
'<b>topic</b> - Name of the topic to be published
'<b>qos</b> - QoS level
Expand Down
10 changes: 8 additions & 2 deletions mqtt/mqtt.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -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().
'<b>topic</b> - Name of the topic to be published
'<b>qos</b> - QoS level
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 520c4fd

Please sign in to comment.