diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 27 |
1 files changed, 20 insertions, 7 deletions
@@ -23,16 +23,33 @@ | |||
23 | 23 | ||
24 | PROGNAME = mush | 24 | PROGNAME = mush |
25 | 25 | ||
26 | FQBN = esp8266:esp8266:espmxdevkit | 26 | CORE = esp8266:esp8266 |
27 | |||
28 | FQBN = $(CORE):espmxdevkit | ||
27 | MDNS_NAME = $(PROGNAME) | 29 | MDNS_NAME = $(PROGNAME) |
28 | OTA_PORT = 8266 | 30 | OTA_PORT = 8266 |
29 | OTA_PASS = | 31 | OTA_PASS = |
30 | 32 | ||
31 | SERIAL_DEV = $(firstword $(wildcard /dev/ttyUSB* /dev/ttyACM*)) | 33 | .DEFAULT_GOAL = all |
32 | 34 | ||
33 | cli = arduino-cli -b "$(FQBN)" | 35 | init: |
36 | [ -e /home/d/.arduino15/arduino-cli.yaml ] || arduino-cli config init | ||
37 | arduino-cli config set board_manager.additional_urls https://arduino.esp8266.com/stable/package_esp8266com_index.json | ||
38 | arduino-cli core update-index | ||
39 | arduino-cli core install $(CORE) | ||
40 | arduino-cli lib update-index | ||
41 | arduino-cli lib install 'DHT sensor library' | ||
34 | 42 | ||
43 | SERIAL_DEV = $(firstword $(wildcard /dev/ttyUSB* /dev/ttyACM*)) | ||
44 | |||
45 | ifneq (,$(wildcard init)) | ||
35 | BUILD_DIR != $(cli) compile --show-properties | sed -ne 's/^build.path=//p' | 46 | BUILD_DIR != $(cli) compile --show-properties | sed -ne 's/^build.path=//p' |
47 | PLAT_PATH != $(cli) compile --show-properties | sed -ne 's/^runtime.platform.path=//p' | ||
48 | PY_PATH != $(cli) compile --show-properties | sed -ne 's/^runtime.tools.python3.path=//p' | ||
49 | MDNS_IP != getent ahostsv4 $(MDNS_NAME).local | (read ip _; echo $$ip) | ||
50 | endif | ||
51 | |||
52 | cli = arduino-cli -b "$(FQBN)" | ||
36 | 53 | ||
37 | SRC := CCS811.cpp $(PROGNAME).ino | 54 | SRC := CCS811.cpp $(PROGNAME).ino |
38 | HDRS := CCS811.h ota.h wifiinfo.h | 55 | HDRS := CCS811.h ota.h wifiinfo.h |
@@ -51,10 +68,6 @@ $(BIN) $(ELF): $(SRC) $(HDRS) | |||
51 | upload: $(ELF) | 68 | upload: $(ELF) |
52 | $(cli) upload -p "$(SERIAL_DEV)" | 69 | $(cli) upload -p "$(SERIAL_DEV)" |
53 | 70 | ||
54 | PLAT_PATH != $(cli) compile --show-properties | sed -ne 's/^runtime.platform.path=//p' | ||
55 | PY_PATH != $(cli) compile --show-properties | sed -ne 's/^runtime.tools.python3.path=//p' | ||
56 | MDNS_IP != getent ahostsv4 $(MDNS_NAME).local | (read ip _; echo $$ip) | ||
57 | |||
58 | ota: $(BIN) | 71 | ota: $(BIN) |
59 | [ "$(MDNS_IP)" ] | 72 | [ "$(MDNS_IP)" ] |
60 | "$(PY_PATH)/python3" "$(PLAT_PATH)/tools/espota.py" -i "$(MDNS_IP)" -p "$(OTA_PORT)" --auth="$(OTA_PASS)" -f "$(BIN)" | 73 | "$(PY_PATH)/python3" "$(PLAT_PATH)/tools/espota.py" -i "$(MDNS_IP)" -p "$(OTA_PORT)" --auth="$(OTA_PASS)" -f "$(BIN)" |