knolleary / pubsubclient

A client library for the Arduino Ethernet Shield that provides support for MQTT.
http://pubsubclient.knolleary.net/
MIT License
3.78k stars 1.46k forks source link

publish fails with Qos1 or 2 with retain flag set #971

Open Gendiaaa opened 1 year ago

Gendiaaa commented 1 year ago

hello Mr Knolleary

i was not able to publish to topic using a retain flag and Qos as this function shows boolean publish_P(const char topic, const uint8_t payload, unsigned int plength, uint8_t qos, boolean retained); i follow the same same and got this error C:\Users\gendi\OneDrive\Documents\Arduino\DosingEsp32working in edit\DosingEsp32working in edit.ino:1415:70: error: no matching function for call to 'PubSubClient::publish(char [60], uint8_t, unsigned int&, int, bool)' client.publish(buf_topic,(uint8_t) msg , arrSize, MQTTpubQos, true); ^ In file included from C:\Users\gendi\OneDrive\Documents\Arduino\DosingEsp32working in edit\DosingEsp32working in edit.ino:10: c:\Users\gendi\OneDrive\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:151:12: note: candidate: 'boolean PubSubClient::publish(const char, const char)' boolean publish(const char topic, const char payload); ^~~ c:\Users\gendi\OneDrive\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:151:12: note: candidate expects 2 arguments, 5 provided c:\Users\gendi\OneDrive\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:152:12: note: candidate: 'boolean PubSubClient::publish(const char, const char, boolean)' boolean publish(const char topic, const char payload, boolean retained); ^~~ c:\Users\gendi\OneDrive\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:152:12: note: candidate expects 3 arguments, 5 provided c:\Users\gendi\OneDrive\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:153:12: note: candidate: 'boolean PubSubClient::publish(const char, const uint8_t, unsigned int)' boolean publish(const char topic, const uint8_t payload, unsigned int plength); ^~~ c:\Users\gendi\OneDrive\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:153:12: note: candidate expects 3 arguments, 5 provided c:\Users\gendi\OneDrive\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:154:12: note: candidate: 'boolean PubSubClient::publish(const char, const uint8_t, unsigned int, boolean)' boolean publish(const char topic, const uint8_t payload, unsigned int plength, boolean retained); ^~~ c:\Users\gendi\OneDrive\Documents\Arduino\libraries\pubsubclient-master\src/PubSubClient.h:154:12: note: candidate expects 4 arguments, 5 provided

exit status 1

Compilation error: no matching function for call to 'PubSubClient::publish(char [60], uint8_t*, unsigned int&, int, bool)'

any advice to how to publish Qos2 with retain flag set , i am using V2.8