-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
97 lines (77 loc) · 2.21 KB
/
Makefile
File metadata and controls
97 lines (77 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
.PHONY: all build run test clean docker-up docker-down deps tidy
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOMOD=$(GOCMD) mod
# Binaries
HUB_BINARY=bin/hub
all: deps build
# Download and tidy dependencies
deps:
cd pkg/models && $(GOMOD) tidy
cd pkg/coords && $(GOMOD) tidy
cd pkg/database && $(GOMOD) tidy
cd pkg/hub && $(GOMOD) tidy
cd cmd/hub && $(GOMOD) tidy
tidy: deps
# Build
build: build-hub
build-hub:
cd cmd/hub && $(GOBUILD) -o ../../$(HUB_BINARY) .
# Run locally (requires docker-compose up first for DB and MQTT)
run: build-hub
./$(HUB_BINARY)
# Debug with delve (headless mode for IDE attachment)
debug: build-hub
dlv exec --headless --listen=:2345 --api-version=2 --accept-multiclient ./$(HUB_BINARY)
# Tests
test:
cd pkg/coords && $(GOTEST) -v ./...
# Docker commands
docker-up:
docker compose up -d
docker-down:
docker compose down
docker-logs:
docker compose logs -f
docker-reset:
docker compose down -v
docker compose up -d
# Database
db-shell:
docker exec -it rftrack-db psql -U rftrack -d rftrack
# MQTT testing
mqtt-pub-test:
@echo '{"id": 1, "rssi": -65, "ssid": "TestNetwork"}' | \
mosquitto_pub -h localhost -t "sensors/hub-01/detections" -s
mqtt-sub:
mosquitto_sub -h localhost -t "sensors/#" -v
# Simulate sensors (requires mosquitto-clients)
simulate:
./scripts/simulate_sensors.sh 0.1 10 0.5
# Clean
clean:
rm -rf bin/
docker compose down -v
# Help
help:
@echo "RFTrack Hub - Available targets:"
@echo ""
@echo " deps - Download Go dependencies"
@echo " build - Build hub binary"
@echo " run - Run single hub locally"
@echo " debug - Run with Delve debugger (port 2345)"
@echo " test - Run tests"
@echo ""
@echo " docker-up - Start infrastructure (DB, MQTT)"
@echo " docker-down - Stop infrastructure"
@echo " docker-reset - Reset infrastructure (wipe data)"
@echo " docker-logs - Tail infrastructure logs"
@echo ""
@echo " db-shell - Open psql shell"
@echo " mqtt-pub-test - Publish test MQTT message"
@echo " mqtt-sub - Subscribe to all MQTT topics"
@echo " simulate - Run sensor simulator"
@echo ""
@echo " clean - Remove binaries and Docker volumes"