Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ lint:
test: $(BUILD)/run-tests
$(BUILD)/run-tests

$(BUILD)/run-tests: $(CORE_SRCS) $(TEST_SRCS) $(CORE_HDRS) $(TEST_HDRS) | $(BUILD)/.dir
$(CC) $(CFLAGS) $(CObjINC) -Itests $(CORE_SRCS) $(TEST_SRCS) -o $@
$(BUILD)/run-tests: $(CORE_SRCS) $(TEST_SRCS) src/tools/ha_discovery.c $(CORE_HDRS) $(TEST_HDRS) | $(BUILD)/.dir
$(CC) $(CFLAGS) $(CObjINC) -Isrc/tools -Itests $(CORE_SRCS) $(TEST_SRCS) src/tools/ha_discovery.c -o $@

# --- Host: native tools (for local development and the broker smoke test) ---
# Named distinctly from the m68k binaries so the two don't collide on a
Expand Down Expand Up @@ -193,6 +193,7 @@ m68k: library-headers | $(BUILD)/.dir
$(M68K_CC) $(M68K_CFLAGS) $(VERSION_DEFS) -I$(LIB_INCDIR) src/amiga/args.c src/amiga/sub_main_lib.c -o $(BUILD)/mqtt_sub
$(M68K_CC) $(M68K_CFLAGS) $(VERSION_DEFS) $(CORE_SRCS) $(TOOLS_SRCS) $(AMIGA_SRCS) src/amiga/pub_main.c -o $(BUILD)/mqtt_pub-static
$(M68K_CC) $(M68K_CFLAGS) $(VERSION_DEFS) $(CORE_SRCS) $(TOOLS_SRCS) $(AMIGA_SRCS) src/amiga/sub_main.c -o $(BUILD)/mqtt_sub-static
$(M68K_CC) $(M68K_CFLAGS) $(VERSION_DEFS) -I$(LIB_INCDIR) src/tools/ha_discovery.c src/amiga/mqttstats_main.c -lamiga -o $(BUILD)/mqttstats

m68k-docker:
$(DOCKER) run --rm --platform linux/amd64 $(DOCKER_USER) -v "$(CURDIR)":/work -w /work \
Expand Down Expand Up @@ -507,7 +508,7 @@ dist: guide $(LHA)
$(MAKE) build
@grep -aq "amisslmaster.library" $(BUILD)/mqtt.library || { echo "dist: $(BUILD)/mqtt.library has no AmiSSL/TLS support - refusing to release (see M68K_HAS_AMISSL / make fetch-amissl-sdk)"; exit 1; }
@v=$$(sed -n 's/^#define MIDGE_VERSION[[:space:]]*"\(.*\)"$$/\1/p' src/version.h); \
for b in mqtt_pub mqtt_sub mqtt_pub-static mqtt_sub-static; do \
for b in mqtt_pub mqtt_sub mqtt_pub-static mqtt_sub-static mqttstats; do \
grep -aqF "\$$VER: $$b $$v (" $(BUILD)/$$b || { echo "dist: $(BUILD)/$$b lacks \"\$$VER: $$b $$v (...)\" - stale build/?"; exit 1; }; \
done; \
grep -aqF "\$$VER: mqtt.library 1.0 (" $(BUILD)/mqtt.library || { echo "dist: $(BUILD)/mqtt.library lacks \"\$$VER: mqtt.library 1.0 (...)\" - stale build/? (library \$$VER tracks LibVersion.LibRevision, not MIDGE_VERSION - see src/library/libinit.c)"; exit 1; }
Expand All @@ -517,7 +518,8 @@ dist: guide $(LHA)
$(BUILD)/dist/midge/developer/inline $(BUILD)/dist/midge/developer/libraries \
$(BUILD)/dist/midge/developer/examples
cp $(BUILD)/mqtt_pub $(BUILD)/mqtt_sub $(BUILD)/mqtt_pub-static $(BUILD)/mqtt_sub-static \
$(BUILD)/midge.guide LICENSE midge.readme $(BUILD)/dist/midge/
$(BUILD)/mqttstats $(BUILD)/midge.guide LICENSE midge.readme $(BUILD)/dist/midge/
cp icons/mqttstats.info $(BUILD)/dist/midge/mqttstats.info
cp $(BUILD)/mqtt.library $(BUILD)/dist/midge/libs/
cp src/library/mqtt_lib.sfd src/library/mqtt.doc $(BUILD)/dist/midge/developer/
cp $(LIB_INCDIR)/fd/mqtt_lib.fd $(BUILD)/dist/midge/developer/fd/
Expand Down
12 changes: 11 additions & 1 deletion docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ src/core/ portable C99, zero OS/libc-beyond-C99 dependencies

src/host/ host-native platform glue (BSD sockets, getopt)
src/amiga/ AmigaOS platform glue (bsdsocket.library, ReadArgs)
src/tools/ mqtt_pub/mqtt_sub logic shared by the static host/Amiga builds
src/tools/ mqtt_pub/mqtt_sub logic shared by the static host/Amiga builds,
plus ha_discovery.[ch] (portable Home Assistant MQTT Discovery
topic/payload builder, used by mqttstats below)
src/library/ mqtt.library (see "mqtt.library" below)
```

Expand All @@ -39,6 +41,14 @@ reuse `src/amiga/args.c`'s ReadArgs parsing and `tool_opts` for an
identical CLI contract, but call through `mqtt.library` instead of linking
`src/core`/`src/tools` directly - see "Two build flavours" below.

`src/amiga/mqttstats_main.c` is a separate, self-contained Commodity (the
telemetry piece of the Home Assistant integration - I2C sensor support is
a deferred follow-up) that links `mqtt.library` and `src/tools/ha_discovery.c`
directly; it doesn't go through `tool_opts`/ReadArgs at all, since its
config comes from Workbench ToolTypes via amiga.lib's `ArgArrayInit()`
instead of a CLI template. See `userdocs/mqttstats.md` for the ToolTypes
reference and Home Assistant setup.

## The transport vtable

```c
Expand Down
Binary file added icons/mqttstats.info
Binary file not shown.
Binary file added icons/mqttstats.info.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ nav:
- Home: index.md
- Installation: Installation.md
- CLI Reference: CLI-Reference.md
- mqttstats: mqttstats.md
- mqtt.library: mqtt-library.md
- mqtt.library API Reference: mqtt-library-reference.md
Loading