espressif / esp-mqtt

ESP32 mqtt component
Apache License 2.0
603 stars 255 forks source link

Publish null data (IDFGH-1127) #117

Closed LaurentLouf closed 5 years ago

LaurentLouf commented 5 years ago

Add some simple checks to handle the case where the pointer on the data to be published is null. Not quite sure what to do with the case where we have a fragmented message : can this happen without a payload ? Can this connection->message.length > connection->buffer_length be true ?

david-cermak commented 5 years ago

Hi @LaurentLouf

Thanks for this PR to publish empty payload messages.

About fragmented message: Yes, at this moment it is possible that a null message might get fragmented (should be solved by recently added mqtt_header_complete). This however is not 100%, plus works only for publish messages.

We are about to merge a reception rework to receive only one message at a time. With this update it won't be possible to fragment null data message anymore (only payload itself could be fragmented)

david-cermak commented 5 years ago

Thanks for this work @LaurentLouf, it's been cherry-picked as 2e0e93a2d37a2a082e889b99911011f000274402 and 2b04d177c76728a5a389a08a4a9a78238549a13a.