Skip to content

Commit 2dbb232

Browse files
committed
arduino-cli: Add 'make ota' for updates with ArduinoOTA library
1 parent 9d16d08 commit 2dbb232

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/arduino-cli.mk

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ ifeq ($(MONITOR_PORT),)
3131
$(error missing MONITOR_PORT)
3232
endif
3333

34-
BUILD_DEFINES := MONITOR_BAUDRATE WIFI_SSID WIFI_PASSWORD
34+
OTA_HOSTNAME ?= $(notdir $(PWD))
35+
OTA_IP ?= $(shell getent ahostsv4 "$(OTA_HOSTNAME)" 2>/dev/null | awk '/STREAM/{print $$1; exit}')
36+
37+
BUILD_DEFINES := \
38+
MONITOR_BAUDRATE \
39+
WIFI_SSID \
40+
WIFI_PASSWORD \
41+
OTA_HOSTNAME \
42+
OTA_PORT \
43+
OTA_PASSWORD
3544
BUILD_DEFINES_H = $(BUILD_PATH)/defines.h
3645
BUILD_FLAGS=--build-property "build.extra_flags=-include $(BUILD_DEFINES_H)"
3746

@@ -48,7 +57,7 @@ $(BUILD_DEFINES_H): Makefile $(wildcard *.mk) $(MAKEFILE_LIST)
4857
@echo -n > $@
4958
@for line in $(foreach def,$(BUILD_DEFINES),\
5059
$(if $(strip $($(def))),\
51-
$(if $(filter %_BAUDRATE,$(def)),\
60+
$(if $(filter %_BAUDRATE %_PORT,$(def)),\
5261
"#define $(def) $($(def))",\
5362
"#define $(def) \"$($(def))\"")\
5463
)$\
@@ -64,6 +73,11 @@ compile: preprocess
6473
upload:
6574
$(ARDUINO_CLI) upload $(VERBOSE) -b $(BOARD_FQDN) -p $(MONITOR_PORT) --input-dir $(BUILD_PATH)
6675

76+
.PHONY: ota
77+
ota:
78+
@echo $(ARDUINO_CLI) upload $(VERBOSE) -b $(BOARD_FQDN) -p $(OTA_IP) --upload-field "password=<hidden>" --input-dir $(BUILD_PATH)
79+
@$(ARDUINO_CLI) upload $(VERBOSE) -b $(BOARD_FQDN) -p $(OTA_IP) --upload-field "password=$(OTA_PASSWORD)" --input-dir $(BUILD_PATH)
80+
6781
.PHONY: monitor
6882
monitor:
6983
ifeq ($(MONITOR_CMD),picocom)

0 commit comments

Comments
 (0)