class documentation

class MQTTAgent:

Known subclasses: rp2da2.mqtt.mqtt.Will

Constructor: MQTTAgent(topic_filter, qos)

View In Hierarchy

MQTT Agent

This is a virtual class acting as the base for MQTT agents that set up subscriptions, process received publications and publish.

Method __init__ Initialise the subscription
Method get_filter Get the topic filter for this subscription
Method handle_publication Handle a publication
Method matches check if topic matches filter
Method _create_pub_check Create Publication check task
Class Variable _client Undocumented
Class Variable _dcc Undocumented
Instance Variable _qos Undocumented
Instance Variable _topic_filter Undocumented
def __init__(self, topic_filter, qos):
overridden in rp2da2.mqtt.mqtt.Will

Initialise the subscription

Parameters
topic_filterthe topic filter to match against received topics
qosthe Quality of Service for this subscription. Must be either MQTTClient.QOS0 or MQTTClient.QOS1
def get_filter(self):

Get the topic filter for this subscription

Returns
The topic filter as a string
def handle_publication(self, topic, dup_flag, ret_flag, payload):
overridden in rp2da2.mqtt.mqtt.Will

Handle a publication

This method is called by the MQTT client when a publication is received. It must be implemented by the derived class.

Parameters
topicthe topic of the publication
dup_flagTrue if this is a duplicate publication
ret_flagTrue if this is a retained publication
payloadthe payload of the publication as a string
def matches(self, topic):

check if topic matches filter

Parse the received topic against the topic filter to see if it matches.

'+' matches a single item in the topic name. '#' matches any remaining topic name including none

Parameters
self
topicthe received topic as a string
Returns
True if matches else false
def _create_pub_check(self):

Create Publication check task

Creates a task to periodically check to see if agent has anything to publish and publish it.

This is the default version for those agents that do not publish. It should be overridden in the derived class for any agent that publishes.

_client =

Undocumented

_dcc =

Undocumented

_qos =

Undocumented

_topic_filter =

Undocumented