ESP8266-based WiFi serial modem emulator ROM

GNUmakefile: Use dedicated script for serve_ota

The Ruby web server will now generate the MD5 and serve the built
binary, rather than doing it ahead of time and then running a web
server. This allows me to repeatedly make changes with just 'gmake'
and let another serve_ota process stay running, rather than having
to re-run serve_ota after every change to re-generate the MD5
ota.txt.

+40 -15
+2 -15
GNUmakefile
··· 18 18 19 19 UPLOAD_PORT?= /dev/cuaU0 20 20 21 - SERVER_IP?= `route -qn get 0.0.0.0 | grep 'address:' | sed 's/.*: //'` 22 - SERVER_PORT?= 8000 21 + UPLOAD_PORT?= /dev/cuaU0 23 22 24 23 include /usr/local/share/makeEspArduino/makeEspArduino.mk 25 24 26 25 serve_ota: all 27 - @[ -d release ] || mkdir release 28 - @grep _VERSION wifippp.h | sed -e 's/"$$//' -e 's/.*"//' > release/ota.txt 29 - @cp -f $(MAIN_EXE) release/update.bin 30 - @stat -f "%z" release/update.bin >> release/ota.txt 31 - @md5 -q release/update.bin >> release/ota.txt 32 - @echo http://$(SERVER_IP):$(SERVER_PORT)/update.bin >> release/ota.txt 33 - @echo "" 34 - @echo "Issue update command:" 35 - @echo "" 36 - @echo -n "AT$$" 37 - @echo "UPDATE! http://${SERVER_IP}:${SERVER_PORT}/ota.txt" 38 - @echo "" 39 - cd release && python3 -m http.server $(SERVER_PORT) 26 + ruby serve_ota.rb ${MAIN_EXE}
+38
serve_ota.rb
··· 1 + #!/usr/bin/env ruby 2 + 3 + require "webrick" 4 + 5 + host = `route -qn get 0.0.0.0 | grep 'address:' | sed 's/.*: //'`.strip 6 + port = 8000 7 + file = ARGV[0] 8 + 9 + s = WEBrick::HTTPServer.new( 10 + :Host => host, 11 + :Port => port, 12 + :DocumentRoot => "/dev/null" 13 + ) 14 + s.mount_proc "/ota.txt" do |req,res| 15 + ver = File.read("wifippp.h"). 16 + scan(/_VERSION.*/)[0]. 17 + gsub(/"$/, ""). 18 + gsub(/.*"/, "") 19 + size = File.size(file) 20 + md5 = `md5 -q #{file}`.strip 21 + 22 + res.body = "#{ver}\n" + 23 + "#{size}\n" + 24 + "#{md5}\n" + 25 + "http://#{host}:#{port}/update.bin\n" 26 + end 27 + 28 + s.mount_proc "/update.bin" do |req,res| 29 + res.body = File.binread(ARGV[0]) 30 + end 31 + 32 + puts "", 33 + "Issue update command:", 34 + "", 35 + "AT$UPDATE! http://#{host}:#{port}/ota.txt", 36 + "" 37 + 38 + s.start