forked from hiveeyes/terkin-datalogger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
240 lines (183 loc) · 6.43 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# ***********************
# The MicroTerkin sandbox
# ***********************
# See also https://community.hiveeyes.org/t/terkin-for-micropython/233/21
# =============
# Initial setup
# =============
#
# Refresh sources and dependencies::
#
# git pull
# make setup
#
# Establish network connectivity::
#
# export MCU_PORT=/dev/cu.usbmodemPy001711
# make connect-wifi ssid=YourNetwork password=YourPassword
#
# Transfer files::
#
# export MCU_PORT=192.168.178.33
# make install-ftp
#
# Watch log output::
#
# make console
#
# Start over::
#
# -- Press reset button
# -- Have fun
# ================
# Maintenance mode
# ================
#
# When the device is already running, it is already attached to a network.
# So, to make it stay connected and pull it out of deep sleep, you might
# want to adjust one step in the procedure above.
#
# Establish network connectivity::
#
# make terkin-agent action=maintain
#
# =============
# Main Makefile
# =============
# Load modules
include tools/help.mk
include tools/core.mk
include tools/setup.mk
include tools/release.mk
include tools/terkin.mk
include tools/pycom.mk
include tools/micropython.mk
include tools/bluetooth.mk
# ----
# Help
# ----
.DEFAULT_GOAL := help
help: show-rules
@echo "$$(tput bold)Documentation:$$(tput sgr0)"
@echo
@echo "Please check https://community.hiveeyes.org/t/operate-the-terkin-datalogger-sandbox/2332 "
@echo "in order to get an idea how to operate this software sandbox."
@echo
@echo "Have fun!"
@echo
# -----
# Setup
# -----
## Prepare sandbox environment and download requirements
setup: setup-environment download-requirements mpy-cross-setup
# -----------------------
# Discovery & Maintenance
# -----------------------
setup-terkin-agent:
$(pip3) install --pre --requirement requirements-terkin-agent.txt
.PHONY: terkin-agent
## Run the MicroTerkin Agent, e.g. "make terkin-agent action=maintain"
terkin-agent: setup-terkin-agent
sudo $(python3) tools/terkin.py $(action) $(macs)
## Load the MiniNet module to the device and start a WiFi access point.
provide-wifi:
@$(rshell) $(rshell_options) --quiet cp lib/mininet.py /flash/lib
@$(rshell) $(rshell_options) --quiet repl "~ from mininet import MiniNet ~ MiniNet().activate_wifi_ap()"
@echo
## Load the MiniNet module to the device and start a WiFi STA connection.
connect-wifi:
@$(rshell) $(rshell_options) --quiet cp lib/mininet.py /flash/lib/mininet_wip.py
@$(rshell) $(rshell_options) --quiet repl "~ from mininet_wip import MiniNet ~ MiniNet().connect_wifi_sta('$(ssid)', '$(password)')"
@echo
## Load the MiniNet module to the device and get IP address.
ip-address:
@$(rshell) $(rshell_options) --quiet cp lib/mininet.py /flash/lib
@$(rshell) $(rshell_options) --quiet repl "~ from mininet import MiniNet ~ print(MiniNet().get_ip_address()) ~"
@echo
# -----------------------------
# File compilation and transfer
# -----------------------------
## Compile all library files using mpy-cross
mpy-compile:
@echo "$(INFO) Ahead-of-time compiling to .mpy bytecode"
@echo "$(INFO) Populating folder \"lib-mpy\""
@rm -rf lib-mpy
@$(python2) $(mpy-cross-all) --out lib-mpy dist-packages
@$(python2) $(mpy-cross-all) --out lib-mpy lib
@$(python2) $(mpy-cross-all) --out lib-mpy/terkin terkin
@$(python2) $(mpy-cross-all) --out lib-mpy/hiveeyes hiveeyes
@echo "$(INFO) Size of lib-mpy"
@du -sch lib-mpy
## Upload framework, program and settings and restart attached to REPL
recycle: install-framework install-sketch reset-device-attached
## Upload framework, program and settings and restart device
recycle-ng: install-ng
@# Restart device using HTTP server after prompting the user for confirmation.
@echo
@echo "$(WARNING) It is crucial all files have been transferred successfully before restarting the device."
@echo " Otherwise, chances are high the program will crash after restart."
@echo
@echo "$(ADVICE) You might want to check the output of the file transfer process above for any errors."
@echo
@$(MAKE) confirm text="Restart device using the HTTP API?"
$(MAKE) restart-device
## Upload program and settings and restart attached to REPL
sketch-and-run: install-sketch reset-device-attached
# ------------------
# File transfer solo
# ------------------
## Install all files to the device, using rshell
install: install-requirements install-framework install-sketch
## Install all files to the device, using FTP
install-ftp:
@if test "${mpy_cross}" = "true"; then \
$(MAKE) mpy-compile && \
$(MAKE) notify status=INFO status_ansi="$(INFO)" message="Uploading MicroPython code to device using FTP" && \
$(MAKE) lftp lftp_recipe=tools/upload-mpy.lftprc; \
else \
$(MAKE) lftp lftp_recipe=tools/upload-all.lftprc; \
fi
## Install all files to the device, using best method
install-ng: check-mcu-port
@if test "${mcu_port_type}" = "ip"; then \
$(MAKE) install-ftp; \
elif test "${mcu_port_type}" = "usb"; then \
$(MAKE) notify status=INFO status_ansi="$(INFO)" message="Uploading MicroPython code to device using USB" \
$(MAKE) install; \
fi
@# User notification
@$(MAKE) notify status=OK status_ansi="$(OK)" message="MicroPython code upload finished"
install-requirements: check-mcu-port
$(rshell) $(rshell_options) mkdir /flash/dist-packages
$(rshell) $(rshell_options) rsync dist-packages /flash/dist-packages
install-framework: check-mcu-port
$(rshell) $(rshell_options) --file tools/upload-framework.rshell
install-sketch: check-mcu-port
$(rshell) $(rshell_options) --file tools/upload-sketch.rshell
refresh-requirements: check-mcu-port
rm -r dist-packages
$(MAKE) download-requirements
$(rshell) $(rshell_options) rm -r /flash/dist-packages
$(rshell) $(rshell_options) ls /flash/dist-packages
$(MAKE) install-requirements
# ------------
# Applications
# ------------
terkin: install-terkin
ratrack: install-ratrack
terkin: check-mcu-port
@#$(rshell) $(rshell_options) --file tools/upload-framework.rshell
$(rshell) $(rshell_options) --file tools/upload-terkin.rshell
ratrack: check-mcu-port
# $(rshell) $(rshell_options) --file tools/upload-framework.rshell
$(rshell) $(rshell_options) --file tools/upload-ratrack.rshell
# ---------
# Releasing
# ---------
build-annapurna:
docker run -v `pwd`/dist-packages:/opt/frozen -it goinvent/pycom-fw build FIPY annapurna-0.6.0dev2 v1.20.0.rc12.1 idf_v3.1
#release-and-publish: release publish-release
# Release this piece of software.
# Synopsis:
# "make release bump=minor" (major,minor,patch)
release: bumpversion push publish-release