diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | config.h.in | 10 | ||||
| -rw-r--r-- | makefile | 5 | ||||
| -rw-r--r-- | src/main.c | 10 |
4 files changed, 16 insertions, 10 deletions
| @@ -1,2 +1,3 @@ | |||
| 1 | bin/ | 1 | bin/ |
| 2 | obj/ | 2 | obj/ |
| 3 | include/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 | ||
| @@ -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 | ||
| 17 | obj/%.o: src/%.c | obj | 17 | obj/%.o: src/%.c include/config.h | obj |
| 18 | cc $(CFLAGS) -c $< -o $@ | 18 | cc $(CFLAGS) -c $< -o $@ |
| 19 | 19 | ||
| 20 | include/config.h: | ||
| 21 | cp config.h.in $@ | ||
| 22 | |||
| 20 | bin obj: | 23 | bin obj: |
| 21 | mkdir -p $@ | 24 | mkdir -p $@ |
| 22 | 25 | ||
| @@ -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 | |||
| 26 | static volatile bool terminate = false; // NOLINT | 18 | static volatile bool terminate = false; // NOLINT |
| 27 | 19 | ||
| 28 | static void | 20 | static void |
