aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/Makefile')
-rw-r--r--firmware/Makefile30
1 files changed, 28 insertions, 2 deletions
diff --git a/firmware/Makefile b/firmware/Makefile
index 0fd1699..0595792 100644
--- a/firmware/Makefile
+++ b/firmware/Makefile
@@ -9,7 +9,29 @@ BUILD_FLAGS = -D WIFI_SSID="\\\"$(WIFI_SSID)\\\"" \
9 -D WIFI_PASS="\\\"$(WIFI_PASS)\\\"" \ 9 -D WIFI_PASS="\\\"$(WIFI_PASS)\\\"" \
10 -D MQTT_URI="\\\"$(MQTT_URI)\\\"" 10 -D MQTT_URI="\\\"$(MQTT_URI)\\\""
11 11
12.PHONY: build upload monitor clean debug-flags test 12PORT ?= $(shell ls /dev/ttyUSB* /dev/ttyACM* 2>/dev/null | head -n 1)
13
14ifdef BAUD
15 BAUD := $(BAUD)
16else ifneq ("$(wildcard .baud_detected)","")
17 BAUD := $(shell cat .baud_detected)
18else
19 BAUD := 115200
20endif
21
22detect-baud:
23 @echo "[*] Detecting correct baud rate..."
24 @if screen -L -dmS test_screen $(PORT) 74880; then \
25 sleep 1; \
26 grep -q "rst:" screenlog.0 && echo "74880" > .baud_detected || echo "115200" > .baud_detected; \
27 rm -f screenlog.0; \
28 screen -S test_screen -X quit; \
29 else \
30 echo "115200" > .baud_detected; \
31 fi
32 @echo "[✓] Set BAUD=$$(cat .baud_detected)"
33
34.PHONY: build upload monitor clean debug-flags test detect-baud
13 35
14build: 36build:
15 @echo "Starting build with SSID=$(WIFI_SSID)" 37 @echo "Starting build with SSID=$(WIFI_SSID)"
@@ -20,7 +42,11 @@ upload:
20 PLATFORMIO_BUILD_FLAGS="$(BUILD_FLAGS)" pio run -e $(ENV) -t upload 42 PLATFORMIO_BUILD_FLAGS="$(BUILD_FLAGS)" pio run -e $(ENV) -t upload
21 43
22monitor: 44monitor:
23 pio device monitor -e $(ENV) 45 @PORT=$(PORT); \
46 BAUD=$(BAUD); \
47 if [ -z "$$PORT" ]; then echo "[ERROR] Port /dev/ttyUSB* or /dev/ttyACM* not found"; exit 1; fi; \
48 echo "[*] Opening monitor: $$PORT @ $$BAUD baud"; \
49 screen $$PORT $$BAUD
24 50
25clean: 51clean:
26 pio run -e $(ENV) -t clean 52 pio run -e $(ENV) -t clean