MQTT_Bridge (FB)¶
FUNCTION_BLOCK MQTT_Bridge EXTENDS CBML.LConTo IMPLEMENTS IExponentialBackoff
Function Block to connect to the Google Cloud Iot Core over the MQTT Bridge
- InOut:
Scope
Name
Type
Initial
Comment
Inherited from
Input
xEnableBOOLTRUE: Activates the defined operationFALSE: Aborts/resets the defined operationLConTo
udiTimeOutUDINTMax. operating time for executing [µs], 0: No operating time limit
LConTo
Output
xDoneBOOLTRUE: Ready condition reachedLConTo
xBusyBOOLTRUE: Operation is runningLConTo
xErrorBOOLTRUE: Error condition reachedLConTo
Input
sproject_idSTRING(255)PROJECT_ID used by Google IoT CORE
scloud_regionSTRING(255)REGION used by Google IoT CORE
sregistry_idSTRING(255)REGISTRY_ID used by Google IoT CORE
sdevice_idSTRING(255)DEVICE_ID used by Google IoT CORE
sCommonNamePrivateKeySTRINGCommon Nmae of privat key certificate
sUseCaseNamePrivateKeySTRINGUse Case Name of certificats
udiJWTExpirationTimeUDINT3600
Expiration Time of the JWT, in [s]. Default 3600 s
smqtt_bridge_hostnameSTRING(255)‚mqtt.googleapis.com‘
Used MQTT Hostname. Default ‚mqtt.googleapis.com‘
uimqtt_bridge_portUINT8883
Used MQTT Bridge port. Default 8883
uiKeepAliveUINT60
Keep alive Time in [s]. Default 60 s
uimaximum_backoff_TimeUINT3200
Maximum Backoff time allowed in [ms]. Default is 3200 ms
itfTLSContextNBS.ITLSContext0
Encapsulates all the data neccecray to handle encrypted tcp connections
Static initialization, as shown in the following code snippet.
VAR commonName : STRING := 'MyRrasPi'; ciCertInfo : NBS.CERT_INFO := (psInfo:=ADR(commonName), udiSize:=LEN(commonName)); myTLSContext : NBS.TLSContext := ( ePurpose:=NBS.PURPOSE.CLIENT_SIDE, sUseCaseName:='NBSTest', sTLSVersion:='1.3', ciCertInfo:=ciCertInfo, udiVerificationMode:=2 ); END_VAR
itfAsyncPropertyNBS.IAsyncProperty0
Runs the connect process in a own background task. Use this property if the connection setup takes longer than one task cycle (e.g. TLS connections)
sSNTPServerREFERENCE TO STRING(255)
The IP address or the name of a SNTP server to get the UTC time. If the input is not set, then the local system time will be used.
Output
eErrorOutput Error
eMQTTErrorMQTT.MQTT_ERRORError from MQTT
xConnectedBOOLConnected to Cloud Broker
Methods:
Structure: