-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
62 lines (54 loc) · 1.64 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
SHELL:=/bin/bash
PWD=$(shell pwd)
TAG=$(shell git describe --tags --abbrev=0 | tr -d '\n')
PORT=/dev/ttyUSB0
FQBN=esp32:esp32:esp32
FILENAME=esp32-logger
NODE_LIST_FILE="./.nodelist"
compile:
arduino-cli compile \
--fqbn $(FQBN) \
--log-level=info \
--libraries $(PWD)/libraries/ \
--build-path=$(PWD)/build \
--build-property 'compiler.cpp.extra_flags="-D FIRMWARE_VERSION="$(TAG)"" "-D CHIP_ID=${node}" -lalgobsec' \
--build-property 'compiler.warning_level=all' \
--warnings all \
.
upload:
arduino-cli upload \
-p $(PORT) \
--fqbn $(FQBN) \
--log-level=debug \
--input-dir=$(PWD)/build
monitor:
arduino-cli monitor \
-p $(PORT) \
--config Baudrate=115200
deploy-node:
@set -e; \
echo "[deploy] Building for ${node}"; \
make compile node=${node}; \
CHIP_ID_HEX=$$(printf "%x" ${node}); \
FILE=$(PWD)/build/$(FILENAME).ino.bin; \
MD5=$$(md5sum $$FILE | cut -d' ' -f1); \
MODE=firmware; \
curl --verbose --compressed -L -X POST -F "MD5=$$MD5" -F "name=$$MODE" -F "data=@$$FILE;filename=$$MODE" "http://esp$$CHIP_ID_HEX.local/update"; \
echo "[deploy] Built and uploaded on ${node} - http://esp$$CHIP_ID_HEX.local/";
deploy:
while read NODE; do \
make deploy-node node=$$NODE; \
done < ${NODE_LIST_FILE}
whereis:
@echo "TODO this should loop over NODES and log ID + location from config"; \
echo "will need to make api endpoint on the node itself"
# Finds (using avahi) locally available nodes and adds their IDs to .nodelist
discover:
avahi-browse --resolve _http._tcp --parsable --terminate \
| grep wlp \
| grep ESP32-LOGGER \
| cut -d'=' -f3 \
| cut -d'"' -f1 \
> ${NODE_LIST_FILE}
clean:
rm -rf ./build