summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile60
1 files changed, 60 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..481382a
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,60 @@
1# Optionally some environment variables can be set:
2#
3# FQBN Fully Qualified Board Name; if not set in the environment
4# it will be assigned a value in this makefile
5#
6# SERIAL_DEV Serial device to upload the sketch; if not set in the
7# environment it will be assigned:
8# /dev/ttyUSB0 if it exists, or
9# /dev/ttyACM0 if it exists, or
10# unknown
11#
12# MDNS_NAME Hostname of the Arduino; if not set in the environment
13# it will be assigned a value in this makefile. This is
14# needed for OTA update, the device will be searched
15# on the local subnet using this name
16#
17# OTA_PORT Port used by OTA update; if not set in the environment
18# it will be assigned the default value of 8266 in this
19# makefile
20#
21# OTA_PASS Password used for OTA update; if not set in the environment
22# it will be assigned the default value of an empty string
23
24PROGNAME = mush
25
26FQBN = esp8266:esp8266:espmxdevkit
27MDNS_NAME = $(PROGNAME)
28OTA_PORT = 8266
29OTA_PASS =
30
31SERIAL_DEV = $(firstword $(wildcard /dev/ttyUSB* /dev/ttyACM*))
32
33cli = arduino-cli -b "$(FQBN)"
34
35BUILD_DIR != $(cli) compile --show-properties | sed -ne 's/^build.path=//p'
36
37SRC := CCS811.cpp $(PROGNAME).ino
38HDRS := CCS811.h ota.h wifiinfo.h
39BIN := $(BUILD_DIR)/$(PROGNAME).ino.bin
40ELF := $(BUILD_DIR)/$(PROGNAME).ino.elf
41
42all: $(ELF)
43.PHONY: all
44
45compile: $(ELF)
46.PHONY: compile
47
48$(BIN) $(ELF): $(SRC) $(HDRS)
49 $(cli) compile --warnings all
50
51upload:
52 $(cli) upload -p "$(SERIAL_DEV)"
53
54PLAT_PATH != $(cli) compile --show-properties | sed -ne 's/^runtime.platform.path=//p'
55PY_PATH != $(cli) compile --show-properties | sed -ne 's/^runtime.tools.python3.path=//p'
56MDNS_IP != getent ahostsv4 $(MDNS_NAME).local | (read ip _; echo $$ip)
57
58ota: $(BIN)
59 "$(PY_PATH)/python3" "$(PLAT_PATH)/tools/espota.py" -i "$(MDNS_IP)" -p "$(OTA_PORT)" --auth="$(OTA_PASS)" -f "$(BIN)"
60