# The machine condition monitor firmware: compile, upload, and the DSP tests.
#   make             compile machine_monitor/ for an ESP32 DevKit and print its size
#   make flash PORT=/dev/ttyUSB0
#   make test        run the DSP tests (FFT, velocity RMS, noise, crest factor, peaks, zones, runs) with g++
# Needs the esp32 core (3.x or 4.x) and the libraries PubSubClient, ArduinoJson 7, OneWire, DallasTemperature.

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

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

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

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

clean:
	rm -f test/test_vib_logic

.PHONY: all flash test clean
