@@ -168,9 +168,10 @@ class MQTT:
168
168
in seconds.
169
169
:param int connect_retries: How many times to try to connect to the broker before giving up
170
170
on connect or reconnect. Exponential backoff will be used for the retries.
171
- :param class user_data: arbitrary data to pass as a second argument to the callbacks.
172
- This works with all callbacks but "on_message"; there, it is necessary to extract
173
- the user_data from the MQTT object (passed as 1st argument) using the 'user_data' member.
171
+ :param class user_data: arbitrary data to pass as a second argument to most of the callbacks.
172
+ This works with all callbacks but the "on_message" and those added via add_topic_callback();
173
+ for those, to get access to the user_data use the 'user_data' member of the MQTT object
174
+ passed as 1st argument.
174
175
175
176
"""
176
177
@@ -415,6 +416,9 @@ def add_topic_callback(self, mqtt_topic: str, callback_method) -> None:
415
416
416
417
:param str mqtt_topic: MQTT topic identifier.
417
418
:param function callback_method: The callback method.
419
+
420
+ Expected method signature is ``on_message(client, topic, message)``
421
+ To get access to the user_data, use the client argument.
418
422
"""
419
423
if mqtt_topic is None or callback_method is None :
420
424
raise ValueError ("MQTT topic and callback method must both be defined." )
@@ -439,6 +443,7 @@ def on_message(self):
439
443
"""Called when a new message has been received on a subscribed topic.
440
444
441
445
Expected method signature is ``on_message(client, topic, message)``
446
+ To get access to the user_data, use the client argument.
442
447
"""
443
448
return self ._on_message
444
449
0 commit comments