CloudOfThingsTransport

Description

The CloudOfThingsTransport object encapsulates the communication with the Cloud of Things. It is part of CloudOfThingsClient. Take a look at the protocol property.

This object was introduced in InCore 2.0.

› Inherits:Object

Properties

autoConnect

This property holds whether the device should be connected automatically. If autoConnect is true the client tries to reestablish the connection periodically whenever it has been lost.

This property was introduced in InCore 2.0.

› Type:Boolean
› Default:true
› Signal:autoConnectChanged()
› Attributes:Writable

cleanSessionMQTT

This property holds whether a persistent session is used or not. When the clean session flag is set to true, the client does not request a persistent session. If the client reconnects after disconnecting for any reason all information and messages that are queued from a previous session are lost. This only has effect if protocol is MQTT.

This property was introduced in InCore 2.0.

› Type:Boolean
› Default:false
› Attributes:Writable

error

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

› Type:Error
› Signal:errorChanged()
› Attributes:Readonly

errorString

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

› Type:String
› Signal:errorStringChanged()
› Attributes:Readonly

keepAlive

This property holds the interval in milliseconds in which the connectivity of the underlaying network is checked. If connection is lost and autoConnect is set to true the transport will try to reconnect. If protocol is set to CloudOfThingsTransport.MQTT this property will be the interval at which regular ping messages are sent to the broker. If protocol is set to CloudOfThingsTransport.REST this interval will be used to make a connection to the Cloud of Things. If the tcp connection could be established the ping is considered successful and pingResponseReceived() is emitted.

This property was introduced in InCore 2.0.

› Type:SignedInteger
› Default:5000
› Signal:keepAliveChanged()
› Attributes:Writable

protocol

This property holds the protocol which is used to communicate with the Cloud of Things. CloudOfThingsTransport.MQTT uses less bandwidth but does not support all features (real time notifications).

This property was introduced in InCore 2.0.

› Type:Protocol
› Default:CloudOfThingsTransport.REST
› Attributes:Writable

requestCredentialsIntervalREST

This property holds the interval which is used to request device credentials from Cloud of Things. This property is only necessary if the first registration should be delayed and does normally not have to be changed. This only has effect if protocol is REST.

This property was introduced in InCore 2.1.

› Type:SignedInteger
› Default:1000
› Signal:requestCredentialsIntervalRESTChanged()
› Attributes:Writable

requestOperationsIntervalMQTT

This property holds the interval in which pending operations from Cloud of Things are handled. A high interval saves bandwidth but increases the period until pending operations are handled. Set to 0 to disable this functionality. This only has effect if protocol is MQTT.

This property was introduced in InCore 2.0.

› Type:SignedInteger
› Default:60000
› Signal:requestOperationsIntervalMQTTChanged()
› Attributes:Writable

sendBufferInterval

This property holds the interval in which buffered Measurement and Event objects are sent. This reduces the risk of connection aborts due to too many requests. Usually this property can be left unchanged.

This property was introduced in InCore 2.0.

› Type:SignedInteger
› Default:1000
› Attributes:Writable

state

This property holds the current state of the transport.

This property was introduced in InCore 2.0.

› Type:State
› Default:CloudOfThingsTransport.Disconnected
› Signal:stateChanged()
› Attributes:Readonly

tenantForMQTT

This property holds the name of the tenant at the Cloud of Things for communication via MQTT. It is used to communicate with the cloud via <tenantForMQTT>.ram.m2m.telekom.com.

This property was introduced in InCore 2.0.

› Type:String
› Attributes:Writable

Methods

connectToHost()

This method can be used to manually connect to the cloud. This method has no effect if property state is not equal CloudOfThingsTransport.Disconnected.

This method was introduced in InCore 2.0.

disconnectFromHost()

This method disconnects the client from the cloud. Make sure to set autoConnect to false to avoid side effects.

This method was introduced in InCore 2.0.

requestPing()

This method sends a ping message. Connect to the pingResponseReceived() signal to check whether the ping was successful. Returns true if the ping request was sent successfully.

This method was introduced in InCore 2.0.

Signals

connected()

This signal is emitted after the device successfully established a connection to the Cloud of Things. Usually there is some initial overhead before measurments or events are sent.

This signal was introduced in InCore 2.0.

disconnected()

This signal is emitted when the underlying transport lost its connection.

This signal was introduced in InCore 2.0.

errorOccurred()

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

pingResponseReceived()

This signal is emitted after requestPing() is called and the corresponding response has been received.This signal is also emitted when the repeated ping via timer responded.

This signal was introduced in InCore 2.0.

sslErrorOccurred(String errorString)

This signal is emitted when an TLS/SSL-related error has occurred.

This signal was introduced in InCore 2.4.

Enumerations

Error

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

Name Value Description
CloudOfThingsTransport.NoError 0 No error occurred or was detected.
CloudOfThingsTransport.MissingTenant 1 Missing tenant: tenant and/or tenantForMQTT is empty.
CloudOfThingsTransport.TransportError 2 The underlaying transport had an error: .
CloudOfThingsTransport.SslError 3 Error while establishing TLS/SSL connection.

Protocol

This enumeration describes the protocol types which can be used to communicate with the Cloud of Things.

This enumeration was introduced in InCore 2.0.

Name Value Description
CloudOfThingsTransport.MQTT 0 MQTT over port 8883 with SSL.
CloudOfThingsTransport.REST 1 REST over HTTPS.

State

This enumeration describes the states a client can enter.

This enumeration was introduced in InCore 2.0.

Name Value Description
CloudOfThingsTransport.Disconnected 0 The client is disconnected from the cloud.
CloudOfThingsTransport.Connecting 1 A connection request has been made, but the cloud has not approved the connection yet.
CloudOfThingsTransport.Connected 2 The client is connected to the cloud.

Example

See CloudOfThingsClient example on how to use CloudOfThingsTransport.