@@ -331,7 +331,7 @@ If you don't specify a client_id, the SDK will use a random hex string.
331
331
> Definition: ` System.Messaging(user, port=1883, keepalive=30, url="", client_id="") `
332
332
> Returns: MQTT messaging object.
333
333
334
- There are a slew of callback functions you may assign.
334
+ There are a number of callback functions you may assign.
335
335
Typically, you want to set these callbacks before you connect to the broker.
336
336
This is a list of the function names and their expected parameters.
337
337
For more information about the individual callbacks, see the [ paho-mqtt] ( https://github.com/eclipse/paho.mqtt.python#callbacks ) documentation.
@@ -343,6 +343,7 @@ For more information about the individual callbacks, see the [paho-mqtt](https:/
343
343
- ` on_message(client, userdata, mid) `
344
344
- ` on_log(client, userdata, level, buf) `
345
345
346
+ #### Connecting and Disconnecting
346
347
Before publishing or subscribing, you must connect your client to the broker.
347
348
After you're finished, it's good practice to disconnect from the broker before quitting your program.
348
349
These are both simple functions that take no parameters.
@@ -352,13 +353,31 @@ These are both simple functions that take no parameters.
352
353
> Definition: ` Messaging.disconnect() `
353
354
> Returns: Nothing.
354
355
356
+ #### Last Will and Testament (LWT)
357
+ MWTT brokers support the concept of a last will and testament. The last will and testament is a set of parameters that allow the MQTT broker
358
+ publish a specified message to a specific topic in the event of an abnormal disconnection. Setting the last will and testament can be accomplished
359
+ by invoking the ` set_will ` function. The last will and testament can also be removed from a MQTT client by invoking ` clear_will ` .
360
+
361
+ ** Note: set_will() and clear_will() must be invoked prior to invoking Messaging.connect()**
362
+
363
+ - ` set_will(topic, payload, qos, retain) `
364
+ - ` clear_will() `
365
+
366
+ > Definition: ` Messaging.set_will() `
367
+ > Returns: Nothing.
368
+ > Definition: ` Messaging.clear_will() `
369
+ > Returns: Nothing.
370
+
371
+
372
+ #### Subscribing to topics
355
373
You can subscribe to as many topics as you like and unsubscribe from them using the following two commands.
356
374
357
375
> Definition: ` Messaging.subscribe(topic) `
358
376
> Returns: Nothing.
359
377
> Definition: ` Messaging.unsubscribe(topic) `
360
378
> Returns: Nothing.
361
379
380
+ #### Publishing to topics
362
381
Publishing takes the topic to publish to and the message to publish as arguments. The type of message can be string or bytes.
363
382
364
383
> Definition: ` Messaging.publish(topic, message) `
0 commit comments