With MQTT_SKIP_PUBLISH_IF_DISCONNECTED disabled
Documentation says that a publish of qos=0 when disconnected will return -1
This is both in the notes section and in the @return
Client doesn't have to be connected for this API to work, enqueueing the
messages with qos>1 (returning -1 for all the qos=0 messages if
disconnected). If MQTT_SKIP_PUBLISH_IF_DISCONNECTED is enabled, this API will
not attempt to publish when the client is not connected and will always
return -1.
@return message_id of the publish message (for QoS 0 message_id will always
be zero) on success. -1 on failure.
I think the issue is here and an else { ret = -1; } on the if qos check would be all that's needed to fix it
With
MQTT_SKIP_PUBLISH_IF_DISCONNECTED
disabled Documentation says that a publish ofqos=0
when disconnected will return-1
This is both in the notes section and in the@return
I think the issue is here and an
else { ret = -1; }
on theif qos
check would be all that's needed to fix ithttps://github.com/espressif/esp-mqtt/blob/0e4cec94978b7bebafaa5fbab0b395f86c3c91ab/mqtt_client.c#L2003-L2016