Skip to content
Snippets Groups Projects
Commit 02a3031a authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Convert spaces to underscores in MQTT topics

e.g. "action/hack/smtp login" -> "smtp_login", best practices and all.
parent 94f85d5f
Branches
Tags
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #3705 passed
...@@ -132,6 +132,7 @@ static char* format_topic(struct mqtt* mqtt, enum server_type type, enum topic_d ...@@ -132,6 +132,7 @@ static char* format_topic(struct mqtt* mqtt, enum server_type type, enum topic_d
char* mqtt_topic(struct mqtt* mqtt, enum topic_depth depth, char* str, size_t size, const char* fmt, ...) char* mqtt_topic(struct mqtt* mqtt, enum topic_depth depth, char* str, size_t size, const char* fmt, ...)
{ {
char* p;
va_list argptr; va_list argptr;
char sbuf[1024]=""; char sbuf[1024]="";
...@@ -142,7 +143,9 @@ char* mqtt_topic(struct mqtt* mqtt, enum topic_depth depth, char* str, size_t si ...@@ -142,7 +143,9 @@ char* mqtt_topic(struct mqtt* mqtt, enum topic_depth depth, char* str, size_t si
va_end(argptr); va_end(argptr);
} }
return format_topic(mqtt, mqtt->startup->type, depth, str, size, sbuf); REPLACE_CHARS(sbuf, ' ', '_', p);
format_topic(mqtt, mqtt->startup->type, depth, str, size, sbuf);
return str;
} }
static int mqtt_sub(struct mqtt* mqtt, const char* topic) static int mqtt_sub(struct mqtt* mqtt, const char* topic)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment