# The water tank monitor firmware: compile, upload, and the logic tests.
#   make             compile tank_monitor/ for an ESP32 DevKit and print its size
#   make flash PORT=/dev/ttyUSB0
#   make test        run the logic tests (tank shapes, pings, 4 to 20 mA, flow, pump rule, use, night) with g++
# Needs the esp32 core (3.x or 4.x) and the libraries PubSubClient and ArduinoJson 7.

FQBN ?= esp32:esp32:esp32
PORT ?= /dev/ttyUSB0
CLI  ?= arduino-cli

all:
	$(CLI) compile --fqbn $(FQBN) --warnings all tank_monitor

flash:
	$(CLI) compile --fqbn $(FQBN) --upload -p $(PORT) tank_monitor

test:
	g++ -std=c++17 -O1 -Wall -Wextra -Werror -Itank_monitor test/test_tank_logic.cpp -o test/test_tank_logic
	./test/test_tank_logic

clean:
	rm -f test/test_tank_logic

.PHONY: all flash test clean
