'MqttTLS' field in 'Status 6' to indicate if the MQTT connection is encrypted (#22995)

This commit is contained in:
s-hadinger 2025-02-12 14:56:47 +01:00 committed by GitHub
parent 3ef9fe9f6e
commit bc7a1f5dbc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 12 additions and 2 deletions

View File

@ -9,6 +9,7 @@ All notable changes to this project will be documented in this file.
- Support for RC-switch decoding of 64-bit received data
- Berry `tasmota.defer()` (#22976)
- Support for Lithuanian language translations by zzdovydas (#22971)
- `MqttTLS` field in `Status 6` to indicate if the MQTT connection is encrypted
### Breaking Changed

View File

@ -131,6 +131,7 @@
#define D_JSON_MODEL "Model"
#define D_JSON_MOISTURE "Moisture"
#define D_JSON_MQTT_COUNT "MqttCount"
#define D_JSON_MQTT_TLS "MqttTLS"
#define D_JSON_NULL "null"
#define D_JSON_NO "No"
#define D_JSON_NOISE "Noise"

View File

@ -1033,10 +1033,14 @@ void CmndStatus(void)
}
if (((0 == payload) || (6 == payload)) && Settings->flag.mqtt_enabled) { // SetOption3 - Enable MQTT
uint32_t mqtt_tls = 0;
#ifdef USE_MQTT_TLS
mqtt_tls = MqttTLSEnabled() ? 1 : 0;
#endif // USE_MQTT_TLS
Response_P(PSTR("{\"" D_CMND_STATUS D_STATUS6_MQTT "\":{\"" D_CMND_MQTTHOST "\":\"%s\",\"" D_CMND_MQTTPORT "\":%d,\"" D_CMND_MQTTCLIENT D_JSON_MASK "\":\"%s\",\""
D_CMND_MQTTCLIENT "\":\"%s\",\"" D_CMND_MQTTUSER "\":\"%s\",\"" D_JSON_MQTT_COUNT "\":%d,\"MAX_PACKET_SIZE\":%d,\"KEEPALIVE\":%d,\"SOCKET_TIMEOUT\":%d}}"),
D_CMND_MQTTCLIENT "\":\"%s\",\"" D_CMND_MQTTUSER "\":\"%s\",\"" D_JSON_MQTT_COUNT "\":%d,\"" D_JSON_MQTT_TLS "\":%d\"MAX_PACKET_SIZE\":%d,\"KEEPALIVE\":%d,\"SOCKET_TIMEOUT\":%d}}"),
SettingsText(SET_MQTT_HOST), Settings->mqtt_port, EscapeJSONString(SettingsText(SET_MQTT_CLIENT)).c_str(),
TasmotaGlobal.mqtt_client, EscapeJSONString(SettingsText(SET_MQTT_USER)).c_str(), MqttConnectCount(), MQTT_MAX_PACKET_SIZE, Settings->mqtt_keepalive, Settings->mqtt_socket_timeout);
TasmotaGlobal.mqtt_client, EscapeJSONString(SettingsText(SET_MQTT_USER)).c_str(), MqttConnectCount(), mqtt_tls, MQTT_MAX_PACKET_SIZE, Settings->mqtt_keepalive, Settings->mqtt_socket_timeout);
CmndStatusResponse(6);
}

View File

@ -978,6 +978,10 @@ uint16_t MqttConnectCount(void) {
return Mqtt.connect_count;
}
bool MqttTLSEnabled(void) {
return Mqtt.mqtt_tls;
}
void MqttDisconnected(int state) {
/*
// Possible values for state - PubSubClient.h