Добавить прошивку 1.4 с выключением на паузе

This commit is contained in:
AidarKC
2026-10-30 14:01:45 +03:00
parent 09c3eb2806
commit 2761b44ab2
4 changed files with 15 additions and 9 deletions
@@ -441,8 +441,8 @@ public final class BreathServer {
}
private static String quoted(String s){return "\""+s.replace("\\","\\\\").replace("\"","\\\"")+"\"";}
private static void serveWeb(HttpExchange x,String path,String method) throws Exception {
if(path.equals("/firmware/manifest.json")){byte[] bytes="{\"current\":\"1.3\",\"stable\":{\"version\":\"1.3\",\"file\":\"breathmonitor-v1.3.bin\"},\"test\":{\"version\":\"1.2\",\"file\":\"breathmonitor-v1.2.bin\"}}".getBytes(StandardCharsets.UTF_8);if(method.equals("HEAD")){x.getResponseHeaders().set("Content-Type","application/json; charset=utf-8");x.sendResponseHeaders(200,-1);}else send(x,200,"application/json; charset=utf-8",bytes);return;}
if(path.startsWith("/firmware/")){String resource=path.substring("/firmware/".length());if(!resource.matches("breathmonitor-v1\\.(1|2|3)\\.bin"))throw new HttpError(404,"Firmware not found");try(InputStream in=BreathServer.class.getResourceAsStream("/firmware/"+resource)){if(in==null)throw new HttpError(404,"Firmware not installed");byte[] bytes=in.readAllBytes();if(method.equals("HEAD")){x.getResponseHeaders().set("Content-Type","application/octet-stream");x.sendResponseHeaders(200,-1);}else send(x,200,"application/octet-stream",bytes);return;}}
if(path.equals("/firmware/manifest.json")){byte[] bytes="{\"current\":\"1.4\",\"stable\":{\"version\":\"1.4\",\"file\":\"breathmonitor-v1.4.bin\"},\"test\":{\"version\":\"1.2\",\"file\":\"breathmonitor-v1.2.bin\"}}".getBytes(StandardCharsets.UTF_8);if(method.equals("HEAD")){x.getResponseHeaders().set("Content-Type","application/json; charset=utf-8");x.sendResponseHeaders(200,-1);}else send(x,200,"application/json; charset=utf-8",bytes);return;}
if(path.startsWith("/firmware/")){String resource=path.substring("/firmware/".length());if(!resource.matches("breathmonitor-v1\\.(1|2|3|4)\\.bin"))throw new HttpError(404,"Firmware not found");try(InputStream in=BreathServer.class.getResourceAsStream("/firmware/"+resource)){if(in==null)throw new HttpError(404,"Firmware not installed");byte[] bytes=in.readAllBytes();if(method.equals("HEAD")){x.getResponseHeaders().set("Content-Type","application/octet-stream");x.sendResponseHeaders(200,-1);}else send(x,200,"application/octet-stream",bytes);return;}}
String name = switch(path){case "/","/index.html" -> "index.html";
case "/app.js" -> "app.js";case "/style.css" -> "style.css";
default -> null;};