summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2024-10-27 22:02:05 +0100
committerThomas Schmucker <ts@its1.de>2024-10-27 22:02:05 +0100
commit8859b6b8c78beca455e1273b5a31f09e165eed03 (patch)
tree0f55dac8245781427ae842422b547160e3107718
parent5bd0a0cd5e6951723398aadc601f1fcc2a6187b8 (diff)
downloaduse-mosquitto-8859b6b8c78beca455e1273b5a31f09e165eed03.tar.gz
use-mosquitto-8859b6b8c78beca455e1273b5a31f09e165eed03.tar.bz2
use-mosquitto-8859b6b8c78beca455e1273b5a31f09e165eed03.zip
Verschiebe Einstellungen in eine eigene config.h Datei
-rw-r--r--.gitignore1
-rw-r--r--config.h.in10
-rw-r--r--makefile5
-rw-r--r--src/main.c10
4 files changed, 16 insertions, 10 deletions
diff --git a/.gitignore b/.gitignore
index cd42ee3..fa770c6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
1bin/ 1bin/
2obj/ 2obj/
3include/config.h
diff --git a/config.h.in b/config.h.in
new file mode 100644
index 0000000..a622aad
--- /dev/null
+++ b/config.h.in
@@ -0,0 +1,10 @@
1#pragma once
2
3#define CLIENT_ID "my-client-id"
4#define HOST "localhost"
5#define PORT 1883
6#define USERNAME "user"
7#define PASSWORD "password"
8#define TOPIC "topic"
9#define KEEPALIVE 10
10#define WAIT_UNTIL_RECONNECT 10
diff --git a/makefile b/makefile
index 7fada65..536bcd2 100644
--- a/makefile
+++ b/makefile
@@ -14,9 +14,12 @@ debug: CFLAGS+=-g
14$(BINARY): $(OBJ_FILES) | bin 14$(BINARY): $(OBJ_FILES) | bin
15 cc $(LDFLAGS) $^ -o $@ 15 cc $(LDFLAGS) $^ -o $@
16 16
17obj/%.o: src/%.c | obj 17obj/%.o: src/%.c include/config.h | obj
18 cc $(CFLAGS) -c $< -o $@ 18 cc $(CFLAGS) -c $< -o $@
19 19
20include/config.h:
21 cp config.h.in $@
22
20bin obj: 23bin obj:
21 mkdir -p $@ 24 mkdir -p $@
22 25
diff --git a/src/main.c b/src/main.c
index 9f76ab2..16deb68 100644
--- a/src/main.c
+++ b/src/main.c
@@ -9,20 +9,12 @@
9 9
10// Project 10// Project
11#include <mosquitto.h> 11#include <mosquitto.h>
12#include "config.h"
12 13
13#ifndef UNUSED 14#ifndef UNUSED
14# define UNUSED(x) (void) (x) 15# define UNUSED(x) (void) (x)
15#endif 16#endif
16 17
17#define CLIENT_ID "my-client-id"
18#define HOST "192.168.77.2"
19#define PORT 1883
20#define USERNAME "zigbee2mqtt"
21#define PASSWORD "xoorei2uk2booSudies4Numoek1uot"
22#define TOPIC "zigbee2mqtt/Kontaktsensor"
23#define KEEPALIVE 10
24#define WAIT_UNTIL_RECONNECT 10
25
26static volatile bool terminate = false; // NOLINT 18static volatile bool terminate = false; // NOLINT
27 19
28static void 20static void