This returns the status of a MQTT connection.
Input:
handle : INT
The handle to the MQTT connection.
Returns: SINT
0
|
- Connected to the MQTT server.
|
1
|
- Invalid MQTT connection.
|
2
|
- Not connected to MQTT server.
|
3
|
- MQTT server not found.
|
4
|
- No reply from MQTT server
|
5
|
- Connection rejected, unacceptable protocol version.
|
6
|
- Connection rejected, client ID rejected.
|
7
|
- Connection rejected, server unavailable.
|
8
|
- Connection rejected, bad user-name or password.
|
9
|
- Connection rejected, not authorized.
|
20
|
- Secure connection failed.
|
21
|
- Secure connection require client certificate.
|
22
|
- Certificate verification failed.
|
23
|
- Client certificate is incomplete. (Encryption key or client certificate is missing)
|
Declaration:
FUNCTION mqttStatus : SINT;
VAR_INPUT
handle : INT;
END_VAR;
Example:
INCLUDE rtcu.inc
VAR
mqtt : INT;
text : STRING;
rc : SINT;
END_VAR;
PROGRAM example;
gsmPower(power := ON);
gprsOpen();
BEGIN
...
IF mqtt < 1 AND gprsConnected() THEN
text := strFormat(format := "RTCU_\4", v4 := boardSerialNumber());
mqtt := mqttOpen(ip := "test.mosquitto.org", port := 8883, clientid := text, useTLS := TRUE);
IF NOT mqttConnected(handle := mqtt) THEN
rc := mqttStatus(handle := mqtt);
DebugFmt(message := "Status=\1", v1 := rc);
END_IF;
END_IF;
...
END;
END_PROGRAM;
|