From 96ccb1ebf5e85b91c10eb725db9f8f43be5ef919 Mon Sep 17 00:00:00 2001 From: TharunBabu-05 Date: Sat, 3 Oct 2026 23:03:31 +0530 Subject: [PATCH] mqtt status: name the TLS handshake state While a TLS connection was being set up (or -r retried one), `mqtt status` printed "MQTT: not connected" above "TLS handshake with ...". state_name() now lists every state without a default, so -Wswitch catches a new one. --- ports/common/td_proto_cmds.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ports/common/td_proto_cmds.c b/ports/common/td_proto_cmds.c index 79b8101..4da4536 100644 --- a/ports/common/td_proto_cmds.c +++ b/ports/common/td_proto_cmds.c @@ -37,15 +37,18 @@ static bool parse_u16(const char *s, uint16_t *out) return true; } +/* No default: with every state listed, -Wswitch reports a new one. */ static const char *state_name(td_mqtt_state_t s) { switch (s) { + case TD_MQTT_OFF: return "not connected"; case TD_MQTT_CONNECTING: return "connecting"; + case TD_MQTT_TLS_HANDSHAKE: return "TLS handshake"; case TD_MQTT_WAIT_CONNACK: return "logging in"; case TD_MQTT_CONNECTED: return "connected"; case TD_MQTT_RETRY: return "reconnecting"; - default: return "not connected"; } + return "not connected"; } /* Wait (driving the connection) until it settles or timeout_ms passes. */