Skip to content

Commit

Permalink
mqtt disallow empty payload
Browse files Browse the repository at this point in the history
  • Loading branch information
salhk committed Apr 9, 2024
1 parent 3ee05d6 commit 54b15f6
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions mqtt/mqtt.tbs
Original file line number Diff line number Diff line change
Expand Up @@ -541,18 +541,24 @@ sub mqtt_proc_data()
end if
mqtt_proc_data_variables.remaining_length=mqtt_proc_data_variables.remaining_length-mqtt_proc_data_variables.topic_length-len(mqtt_proc_data_variables.packet_identifier)-2

proc_data_state=EN_MQTT_PD_STATES_READING_PAYLOAD_DATA
if mqtt_proc_data_variables.remaining_length=0 then
#if MQTT_DEBUG_PRINT=1
mqtt_debug_print("Notification: topic="+mqtt_proc_data_variables.topic+", NO DATA SENT")
#endif
mqtt_publish_reply()
else
proc_data_state=EN_MQTT_PD_STATES_READING_PAYLOAD_DATA
end if

case EN_MQTT_PD_STATES_READING_PAYLOAD_DATA:
buf=mqtt_sock_getdata(mqtt_proc_data_variables.remaining_length)
mqtt_proc_data_variables.remaining_length=mqtt_proc_data_variables.remaining_length-len(buf)
#if MQTT_DEBUG_PRINT=1
mqtt_debug_print("Notification: topic="+mqtt_proc_data_variables.topic+", data="+buf)
#endif
callback_mqtt_notif(mqtt_proc_data_variables.topic,buf,mqtt_proc_data_variables.remaining_length)
mqtt_publish_reply()
end select
if mqtt_proc_data_variables.remaining_length=0 then
#if MQTT_DEBUG_PRINT=1
mqtt_debug_print("Notification: topic="+mqtt_proc_data_variables.topic+", data="+buf)
#endif
callback_mqtt_notif(mqtt_proc_data_variables.topic,buf,mqtt_proc_data_variables.remaining_length)
mqtt_publish_reply()
end if

case PUBACK: #if MQTT_DEBUG_PRINT=1
mqtt_debug_print("Publish ack.")
Expand Down

0 comments on commit 54b15f6

Please sign in to comment.