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 - xEnable- BOOL- TRUE: Activates the defined operation- FALSE: Aborts/resets the defined operation- LConTo - udiTimeOut- UDINT- Max. operating time for executing [µs], 0: No operating time limit - LConTo - Output - xDone- BOOL- TRUE: Ready condition reached- LConTo - xBusy- BOOL- TRUE: Operation is running- LConTo - xError- BOOL- TRUE: Error condition reached- LConTo - Input - sproject_id- STRING(255)- PROJECT_ID used by Google IoT CORE - scloud_region- STRING(255)- REGION used by Google IoT CORE - sregistry_id- STRING(255)- REGISTRY_ID used by Google IoT CORE - sdevice_id- STRING(255)- DEVICE_ID used by Google IoT CORE - sCommonNamePrivateKey- STRING- Common Nmae of privat key certificate - sUseCaseNamePrivateKey- STRING- Use Case Name of certificats - udiJWTExpirationTime- UDINT- 3600 - Expiration Time of the JWT, in [s]. Default 3600 s - smqtt_bridge_hostname- STRING(255)- ‘mqtt.googleapis.com’ - Used MQTT Hostname. Default ‘mqtt.googleapis.com’ - uimqtt_bridge_port- UINT- 8883 - Used MQTT Bridge port. Default 8883 - uiKeepAlive- UINT- 60 - Keep alive Time in [s]. Default 60 s - uimaximum_backoff_Time- UINT- 3200 - Maximum Backoff time allowed in [ms]. Default is 3200 ms - itfTLSContext- NBS.ITLSContext- 0 - 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 - itfAsyncProperty- NBS.IAsyncProperty- 0 - 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) - sSNTPServer- REFERENCE 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 - eError- Output Error - eMQTTError- MQTT.MQTT_ERROR- Error from MQTT - xConnected- BOOL- Connected to Cloud Broker 
Methods:
Structure:
