monstrenyatko / ArduinoMqtt

MQTT client for Arduino
MIT License
72 stars 13 forks source link

LWT Example Code #5

Closed intel2004 closed 7 years ago

intel2004 commented 7 years ago

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.

monstrenyatko commented 7 years ago

@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.

tarzan115 commented 7 years ago

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;