summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2026-07-11 13:59:01 +0200
committerThomas Schmucker <ts@its1.de>2026-07-11 13:59:01 +0200
commit7735ded57fbb5834efc2f6185fb668ec70923e7f (patch)
tree84cda872968412e0fbb0de5c90977dd489bfec1a /src
parente2e32a1410331f2c478d61b3ecd0a0baf4aec511 (diff)
downloaduse-mosquitto-master.tar.gz
use-mosquitto-master.tar.bz2
use-mosquitto-master.zip
zwei Topics, überflüssige Variable entferntHEADmaster
Diffstat (limited to 'src')
-rw-r--r--src/mqtt.c6
-rw-r--r--src/publish.c15
-rw-r--r--src/subscribe.c2
3 files changed, 10 insertions, 13 deletions
diff --git a/src/mqtt.c b/src/mqtt.c
index 5a8bfc0..be4b9d2 100644
--- a/src/mqtt.c
+++ b/src/mqtt.c
@@ -49,10 +49,8 @@ mqtt_handle_messages(struct mosquitto *client,
49 mosquitto_message_callback_set(client, callback); 49 mosquitto_message_callback_set(client, callback);
50 } 50 }
51 51
52 int *mid = NULL;
53
54 for ( size_t idx = 0; topics[idx] != NULL; ++idx ) { 52 for ( size_t idx = 0; topics[idx] != NULL; ++idx ) {
55 mosquitto_subscribe(client, mid, topics[idx], 0); 53 mosquitto_subscribe(client, NULL, topics[idx], 0);
56 } 54 }
57 55
58 while ( !*quit ) { 56 while ( !*quit ) {
@@ -67,7 +65,7 @@ mqtt_handle_messages(struct mosquitto *client,
67 } 65 }
68 66
69 for ( size_t idx = 0; topics[idx] != NULL; ++idx ) { 67 for ( size_t idx = 0; topics[idx] != NULL; ++idx ) {
70 mosquitto_unsubscribe(client, mid, topics[idx]); 68 mosquitto_unsubscribe(client, NULL, topics[idx]);
71 } 69 }
72} 70}
73 71
diff --git a/src/publish.c b/src/publish.c
index 28a9c3a..542e5e9 100644
--- a/src/publish.c
+++ b/src/publish.c
@@ -18,12 +18,6 @@
18# define MAX_COMMAND_LENGTH 100 18# define MAX_COMMAND_LENGTH 100
19#endif 19#endif
20 20
21static bool
22streq(const char *lhs, const char *rhs)
23{
24 return strcmp(lhs, rhs) == 0;
25}
26
27static void 21static void
28application_cleanup(void) 22application_cleanup(void)
29{ 23{
@@ -37,6 +31,12 @@ application_init(void)
37 (void) atexit(application_cleanup); 31 (void) atexit(application_cleanup);
38} 32}
39 33
34static bool
35streq(const char *lhs, const char *rhs)
36{
37 return strcmp(lhs, rhs) == 0;
38}
39
40static void 40static void
41application_run(struct mosquitto *client) 41application_run(struct mosquitto *client)
42{ 42{
@@ -61,12 +61,11 @@ application_run(struct mosquitto *client)
61 } 61 }
62 else if ( streq(command, "send") ) { 62 else if ( streq(command, "send") ) {
63 static const char payload[] = "ich bin ein payload"; 63 static const char payload[] = "ich bin ein payload";
64 static const char topic[] = "testtopic";
65 64
66 int err = mosquitto_publish( 65 int err = mosquitto_publish(
67 client, 66 client,
68 NULL, 67 NULL,
69 topic, 68 TOPIC,
70 sizeof payload, 69 sizeof payload,
71 payload, 70 payload,
72 0, 71 0,
diff --git a/src/subscribe.c b/src/subscribe.c
index 3d8611e..d612b02 100644
--- a/src/subscribe.c
+++ b/src/subscribe.c
@@ -72,7 +72,7 @@ main(void)
72 } 72 }
73 73
74 mqtt_handle_messages(client, 74 mqtt_handle_messages(client,
75 (const char *[]){ TOPIC, "testtopic", NULL }, 75 (const char *[]){ TOPIC, TOPIC2, NULL },
76 callback, 76 callback,
77 &terminate); 77 &terminate);
78 78