monstrenyatko / ArduinoMqtt

MQTT client for Arduino

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LWT Example Code

intel2004 opened this issue · comments

I am a newbye on this platform and i use adafruit mqtt library first because it has qos1 supportfor publish and subscribe and last will with also qos1,but on arduino mega it doesn't work.
i found your library and it's look very nice but i can't find much information to set lastwill and qos1 for subscribe. can you up an example much detailed? thank you so much.

@intel2004
The subscribe example is available in examples/PubSub/PubSub.ino.
Just change MqttClient::QOS0 to MqttClient::QOS1 in line#157.

I don't have the ready example for LWT. Take a look at question #3 where I explained how to enable it.

Please let me know if you need my help.

just add following code below before connect to setup LWT :D

/* setup LWT */
      options.willFlag                = true;
      options.will.topicName.cstring  = "topic_WLT";
      options.will.message.cstring    = "your message when disconnect";
      options.will.retained           = 1;
      options.will.qos                = 1;