Skip to content

Latest commit

 

History

History
259 lines (162 loc) · 7.35 KB

MqttAbstractSubscription.rst

File metadata and controls

259 lines (162 loc) · 7.35 KB

MqttAbstractSubscription

Description

The MqttAbstractSubscription object provides common properties and mechanisms for subscription objects.

› Inherits

Object <object_Object>

› Inherited by

MqttSubscription <object_MqttSubscription>, MqttWildcardSubscription <object_MqttWildcardSubscription>

Overview

Properties

  • autoSubscribe <property_MqttAbstractSubscription_autoSubscribe>
  • enabled <property_MqttAbstractSubscription_enabled>
  • error <property_MqttAbstractSubscription_error>
  • errorString <property_MqttAbstractSubscription_errorString>
  • qos <property_MqttAbstractSubscription_qos>
  • subscribed <property_MqttAbstractSubscription_subscribed>
  • Object.objectId <property_Object_objectId>
  • Object.parent <property_Object_parent>

Methods

  • subscribe() <method_MqttAbstractSubscription_subscribe>
  • unsubscribe() <method_MqttAbstractSubscription_unsubscribe>
  • Object.deserializeProperties() <method_Object_deserializeProperties>
  • Object.fromJson() <method_Object_fromJson>
  • Object.serializeProperties() <method_Object_serializeProperties>
  • Object.toJson() <method_Object_toJson>

Signals

  • errorOccurred() <signal_MqttAbstractSubscription_errorOccurred>
  • Object.completed() <signal_Object_completed>

Enumerations

  • Error <enum_MqttAbstractSubscription_Error>

Properties

single: autoSubscribe

autoSubscribe

This property holds whether to subscribe the topics automatically whenever the associated MqttClient <object_MqttClient> successfully established a connection to the MQTT broker.

› Type

Boolean

› Default

true

› Signal

autoSubscribeChanged()

› Attributes

Writable

single: enabled

enabled

This property holds whether the subscription is enabled. If disabled, the topics are not subscribed and unsubscribed if subscribed before.

This property was introduced in InCore 2.7.

› Type

Boolean

› Default

true

› Signal

enabledChanged()

› Attributes

Writable

single: error

error

This property holds the most recently occurred error or MqttAbstractSubscription.NoError <enumitem_MqttAbstractSubscription_NoError> if no error occurred. If the same error occurs multiple times this property does not change. Use the errorOccurred() <signal_MqttAbstractSubscription_errorOccurred> signal to detect multiple occurrences of the same error.

› Type

Error <enum_MqttAbstractSubscription_Error>

› Signal

errorChanged()

› Attributes

Readonly

single: errorString

errorString

This property holds the current human readable error string corresponding to the current value in the error <property_MqttAbstractSubscription_error> property. It may include additional information such as failure reasons or locations.

› Type

String

› Signal

errorStringChanged()

› Attributes

Readonly

single: qos

qos

This property holds the Quality of Service to set for the subscribed topics. The QoS level defines how hard the broker will try to ensure that a message is received. MQTT defines three QoS levels:

  • 0: The broker will deliver the message once, with no confirmation. This level could be used, for example, with ambient sensor data where it does not matter if an individual reading is lost as the next one will be published soon after.
  • 1: The broker will deliver the message at least once, with confirmation required.
  • 2: The broker will deliver the message exactly once by using a four step handshake. This level could be used, for example, with billing systems where duplicate or lost messages could lead to incorrect charges being applied.
› Type

SignedInteger

› Default

0

› Signal

qosChanged()

› Attributes

Writable

single: subscribed

subscribed

This property holds whether the topics have been subscribed successfully.

› Type

Boolean

› Default

false

› Signal

subscribedChanged()

› Attributes

Readonly

Methods

single: subscribe

subscribe()

This method subscribes the configured topics using the parent MqttClient <object_MqttClient> object. Once subscribed the MqttTopic::data <property_DataObject_data> properties are updated whenever the MQTT broker receives updates from the topic publisher.

This method usually never has to be called manually. Instead the autoSubscribe <property_MqttAbstractSubscription_autoSubscribe> property should be left at its default value or set to true.

single: unsubscribe

unsubscribe()

This method unsubscribes the configured topics using the parent MqttClient <object_MqttClient> object. The MqttTopic::data <property_DataObject_data> properties will not be updated any longer if the MQTT broker receives updates from the topic publisher.

Signals

single: errorOccurred

errorOccurred()

This signal is emitted whenever an error has occurred, regardless of whether the error <property_MqttAbstractSubscription_error> property has changed or not. In contrast to the change notification signal of the error <property_MqttAbstractSubscription_error> property this signal is also emitted several times if a certain error occurs several times in succession.

Enumerations

single: Error

Error

This enumeration describes all errors which can occur in MqttAbstractSubscription objects. The most recently occurred error is stored in the error <property_MqttAbstractSubscription_error> property.

single: MqttAbstractSubscription.NoError

single: MqttAbstractSubscription.InvalidClient

Name Value Description
MqttAbstractSubscription.NoError 0 No error occurred or was detected.
MqttAbstractSubscription.InvalidClient 1 Parent object is not an MqttClient.