From 13a0acf2ac6f3a8e930fcf0f13643ad0531ed76e Mon Sep 17 00:00:00 2001 From: Manuel Weiser Date: Thu, 19 Feb 2026 17:00:21 +0100 Subject: [PATCH] Remove deprecated HTML files and scripts, refactor API to support asynchronous requests, and improve WebSocket handling for scale actions. --- html/.DS_Store | Bin 6148 -> 0 bytes html/favicon.ico | Bin 16958 -> 0 bytes html/header.html | 43 -- html/index.html | 91 --- html/logo.png | Bin 8852 -> 0 bytes html/setup.html | 87 --- html/style.css | 1207 --------------------------------------- html/upgrade.html | 151 ----- html/waage.html | 136 ----- html/wifi.html | 67 --- platformio.ini | 8 +- scripts/combine_html.py | 34 -- scripts/gzip_files.py | 48 -- src/api.cpp | 208 ++++--- src/api.h | 5 + src/main.cpp | 16 +- src/nfc.cpp | 16 +- src/scale.cpp | 13 +- src/scale.h | 7 +- src/website.cpp | 270 ++++----- 20 files changed, 260 insertions(+), 2147 deletions(-) delete mode 100644 html/.DS_Store delete mode 100644 html/favicon.ico delete mode 100644 html/header.html delete mode 100644 html/index.html delete mode 100644 html/logo.png delete mode 100644 html/setup.html delete mode 100644 html/style.css delete mode 100644 html/upgrade.html delete mode 100644 html/waage.html delete mode 100644 html/wifi.html delete mode 100644 scripts/combine_html.py delete mode 100644 scripts/gzip_files.py diff --git a/html/.DS_Store b/html/.DS_Store deleted file mode 100644 index 68ead1702758a26b6df9c1f25d3977e3b2071d37..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKJxc>Y5Pcg{L~K%6SneKIU)DOg_^l**wOa?c=;2U#^z*f-&b9VT~nfX1qd%Tl!70V!xy{L%|hmYK9w* zODxn{(K4e~N#6_;;u~?ueWskb(%DQ`nBxqmoO|Lbm3sf|oY(1`-@e-}Cdbd@3^)VM zz%Mbtnk~{hF!a_La0Z-#4FmFhh*ZHmVPmMD4mSD(Aa-e1VPD=75)%{V2^&MsP=bXL zEi|MjMzC<&WAe)rHij0CpgVJ&v~x%=l%TuQ9@QNoH}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wcl&e%_aCKv=TundEkQ@K1jEGRgImeposi+NGb)Uo z(Bj$%gWr2vjssiduucv4ODac=#bvNljWUGGh+cjP{%w1qq1ffW@B|`{UZnbO zI~-efBaABuQf*Wf3L*Nv8;G8J9KOZtz)&59KPwZZn38@LaFC3Q@gmqCIt_bSE|v}` zF?L#w{oCa@drW}~$CY^eq!O=zM}ZmV{e*{zOzSzf-(?`l?-2-v#PTyuH(9&>YB!b4}gvI(nME2-AgzW|YEUqyiK z&2;w7xqUC)zefC>gdw*$rSqXHZz4#wW5V-ZcCR zLRjd0NGSO{T$}d7(nMHs?h-Hq%i(FRK>vI#4)0On^nN80CuJDgqQQbb19~Uv(NIaa z)*%LCl#e>?+5u-!@A2b?Mw68T6~#qnWD}>dagi2}kp~&aNGVk>W+XF^KsKbl6Ayo+LYe?3@~lNe|-L3bIm@Vqy9|~UTVSEsXIixldOAlDEOcXF9-ZY_tij|C6{a;)E@O%ex!DqE zRYIzZ3ixxMV``mrw~19XIK4V+IG4R=UEAQ)2%H5bo4c5?cuK6F!tQs@_3OO%RYoMy z#$2}}+dEb3wrtU+2Om+#Vo4R9cTol0P+Rq9v<}0XP~17WzTH({*XPa8EVI{`9IAeU zRkcNJlpTt-f{j5l=r%8~elV@ABRBqIXl|F1qXE{s}tp@%;py=>LSKrbXl3Nk2%9 zfA{+*=JTsJ_y - - - - - FilaMan - Filament Management Tool - - - - - - - diff --git a/html/index.html b/html/index.html deleted file mode 100644 index c79bd29..0000000 --- a/html/index.html +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - FilaMan - Filament Management Tool - - - - - - - -
-

FilaMan

-

Filament Management Tool

-

Your smart solution for Filament Management in 3D printing.

- -

About FilaMan

-

- FilaMan is a tool designed to simplify filament spool management. It allows you to identify and weigh filament spools, - automatically syncing data with the FilaMan-System. -

- -

Get more information at https://www.filaman.app.

- -
-
-

Spool Identification

-

Easily identify filament spools using NFC tags.

-
-
-

Automatic Syncing

-

Seamlessly update spool data with the FilaMan API for accurate tracking.

-
-
-

Scale Integration

-

Built-in scale support for precise remaining weight calculation.

-
-
-
- - - - diff --git a/html/logo.png b/html/logo.png deleted file mode 100644 index c4adb610e867ed362615057427d8fb2f2c9262f7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8852 zcmb7qby(D0*Dj%ggwmY@64FBt-616{J@f!GLk!(WqjX6KNOyyRfONMsf=YvQ_d$K$ zC%)(X&biJXznNM4Uh7_K-+Qk$*Id_xsj0|eV~}AWAt7Na$V;o=y^H^R&>!5r7C{^q zkdW?ALo{^}y2?r*GdPqTYz{ZIV0VMs-{D9|!eVarU^80_1dXYM6$B;%*llb9&_K*Z z06M(NoXYl67S<4X4@V0P4;4)_4_h-qbAXsAhOisxjsR+b0MocZ?O;wIHxa-uUeMj= zpUWHonqMvmTM>Y+vKoyP+|h!Dmz|fL6CjE~BkX8y2~wAq{Ui9!5&>8v5cVJr4p&!K zc2{n8xT6&Zm!O~^2PcpN2xPnSU~_VZA;4~IFekd76u&v7Eu738A@&Fe97gk#6Ko21 zMu-3acR0--|7jw_qT9^{8bIi=?}T?gyZ;$ z+_`i9!` z8%_urmpkG9ID~&};XetSG~MkjIMgki;LeU_7BVh(>e2lY?x!vwDYzZnQRD6^S%?6* z{#sUpxLMfgN<;3ncDg$x5da_0{{Ub78~jtW->k}T^E*=RUvYmy3Q|&Pj&Mte-5utn zE+g^~r#3Ss?c^1lEbi246q|G7as=btx93kJE9 z1o$iOuMpk8FcAPhkmGM@Ui??+?$AKWcimtPMu4Tkh`UOGoIqYSP9Pf>mnN40h?@_@ z%frIS1>)rVmF1T|+#F)*{{Qm+*#R`d=4K!S1Yu|K%lh3B5_X8+)^F1e^0N&h^^C#*Aw?w#t9W5lR?yiyuK*G`za;LaE zjoQzaq5;wX@5TlHKSNxtE$--ki^#Qhq_& z^j-*ZMt2>7UR~`+a8^3($8>vmnabesWudL{W1i&wA@F38?~bu;R2SktnO+bhp;rIH zVf4!>r=s4*wkAa&1)(T0)#P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&pLC#)+3Sfz)vZu`w(drC zG}n3F!-LBSM;Rof;GOvv@d2-#g)vOAD+k7_Ei`f^?Cux3uu3yeip3B;jcguy=23Jk z4K8k~rRAANV`^AOq~_dw-NT4IP>Rdkr{nuGWzog10#_?9$yoS8_fYLvf+-bD6<@lz z$IMO&Y7dKqLFQJh`Hn|=O6gREj~N%er!+D%FvM*DYe>rTgCObQL@8>z zZFI>OGdobM4=J!R3!X_+;sy)gp6$FO)UN-Ytc^9NVk!sVd4^e%E+!2=Cn;S`v0_Zm zUoz|!qrU9v$@;KM*<`xEM@8J)VZuOYV`$Bmz=0VZzBbvuURF71y*{L^_jEi7csZN~ z2iAWbx3L8o^?c2g@f9m63wd9bv%+l0*m26MDm>odByut!t!s36HwlL}6Y1Y>wug71 ze*twKYiMFRxfzMn#17dNahx_;GdS2^F9+q;W)u5vdUo$_6xr<_FLiarMC=N5KgerT z7dfBC-mh>_)%pBGZ}w=K^};UWRh8|mxi`0YHBzmtc;O~c1mZBL6lnTle}GFY&G;dr z={qSCZ4Lwwc&{)4+#mZbIiIew2Qv{reRqaWUFf_?3JzLrR=<2>l(=vc!(1o?>w_X- zl!{Js9e(S*^t_2|Bj~J{2c(#^yo@URf`|_1h%#q@;Pj=urMXG-I3!oHJ`PS~YieSu zl;8D$&$!{X(v;-h)6op|;t<~pD&Oqu*M>`qHrJ-}>2K@XpiGqxZbeW_{!2bdFEFGT! diff --git a/html/setup.html b/html/setup.html deleted file mode 100644 index 147fcfc..0000000 --- a/html/setup.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - FilaMan - Setup - - - - - - -
-

Device Setup

- -
-
-
Registration
-

Status: {{registered}}

-
- - -
-
- - -
- -
-
-
-
- - - - diff --git a/html/style.css b/html/style.css deleted file mode 100644 index d51700c..0000000 --- a/html/style.css +++ /dev/null @@ -1,1207 +0,0 @@ -/* Allgemeine Stile */ -:root { - --primary-color: #63bb67; /* Hauptfarbe Grün */ - --primary-light: #8cd590; /* Helleres Grün */ - --background-green: #28902D; /* Dunkleres Hintergrund-Grün */ - --text-color: #1e293b; /* Dunkelgrau für Text */ - --inner-box-bg: #63bb67; /* Grüner Hintergrund für innere Boxen */ - --inner-text-color: #ffffff; /* Weißer Text in Boxen */ - --stat-value-color: #ffd700; /* Gelber Text für Werte */ - --header-bg: #28902D; /* Hintergrundfarbe für den Header */ - --header-border: #f7208c; /* Pinke Randfarbe für den Header */ - --accent-color: #d51274; /* Pink für Akzentfarben */ - --header-text: #40e8b7; /* Türkisfarbener Text */ - --background-light: #63bb67; /* Helleres Grün für Container */ - --border-color: rgba(255, 255, 255, 0.1); /* Subtile Borders */ - --card-background: rgba(255, 255, 255, 0.15); - --card-shadow: 0 4px 15px rgba(31, 41, 55, 0.1); - --glass-bg: rgba(255, 255, 255, 0.15); - --glass-border: 1px solid rgba(255, 255, 255, 0.2); - --glass-blur: blur(12px); - --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.1); -} - -body { - font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; - margin: 0; - padding: 0; - background: var(--background-green); - background-image: radial-gradient(circle at center, var(--primary-color) 0%, var(--background-green) 100%); - color: var(--text-color); - display: flex; - flex-direction: column; - min-height: 100vh; -} - -/* Header und Navigation */ -.navbar { - background: var(--header-bg); - border: 2px solid var(--header-border); - width: calc(100% - 4rem); - max-width: 1400px; - display: flex; - justify-content: space-between; - align-items: center; - padding: 0 1.5rem; - box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1); - position: fixed; - top: 1rem; - left: 50%; - transform: translateX(-50%); - z-index: 1000; - border-radius: 1rem; - height: 80px; -} - -.logo { - height: 70px; - width: auto; - margin-right: 15px; -} - -.navbar a { - color: var(--inner-text-color); - text-decoration: none; - font-weight: 600; - padding: 0.5rem 1rem; - border-radius: 0.75rem; - background: rgba(255, 255, 255, 0.05); - border: 1px solid transparent; - transition: all 0.3s; -} - -.navbar a:hover { - background-color: rgba(255, 255, 255, 0.1); - transform: translateY(-1px); -} - -/* Logo und Text im Header */ -.logo-text { - display: flex; - flex-direction: column; - align-items: flex-start; - justify-content: center; -} - -.logo-text h4 { - font-size: 1rem; - color: var(--header-text); - margin: 0 !important; -} - -.logo-text h1 { - font-size: 1.75rem; - font-weight: 600; - color: var(--header-border); - margin: 5px !important; - text-shadow: 1px 1px 0 var(--accent-color); -} - -/* Status Container in der Navbar */ -.status-container { - background: var(--inner-box-bg) !important; - border-radius: 1rem; - padding: 0.5rem 1rem; - display: flex; - align-items: center; - gap: 1rem; -} - -.status-item { - background: rgba(0, 0, 0, 0.1) !important; - color: var(--inner-text-color) !important; - padding: 0.25rem 0.75rem; - border-radius: 0.5rem; - display: flex; - align-items: center; - gap: 0.5rem; -} - -.status-dot { - width: 8px; - height: 8px; - border-radius: 50%; - display: inline-block; - margin-right: 4px; -} - -.online { - background-color: #63bb67; -} - -.offline { - background-color: #dc2626; -} - -.status-dot.offline { - cursor: pointer; -} - -.status-dot.offline:hover { - opacity: 0.8; - transform: scale(1.1); -} - -.ram-status { - color: var(--inner-text-color); - font-size: 0.9em; - padding: 0.25rem 0.75rem; - background: rgba(99, 187, 103, 0.1); - border-radius: 0.5rem; -} - -/* Inhalt */ -.container { - padding: 20px; - width: 100%; - max-width: none; - background: white; - border-radius: 8px; - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); - margin-top: 20px; /* Platz für die fixe Navbar */ -} - -/* Überschriften */ -h1 { - color: #007bff; - text-align: center; -} - -h3 { - color: #007bff !important; - font-size: 24px; - margin-top: 5px; - margin-bottom: 5px; - font-weight: bold; - text-align: center; -} - -/* Formulare */ -form { - display: flex; - flex-direction: column; - gap: 10px; - padding: 20px; -} - -label { - font-weight: bold; -} - -input[type="text"], input[type="submit"], input[type="number"] { - padding: 10px; - border: 1px solid #ccc; - border-radius: 5px; - font-size: 16px; -} - -input[type="number"] { - width: 108px !important; -} - -input[type="text"]:focus, input[type="number"]:focus { - border-color: #007bff; - outline: none; -} - -input[type="submit"] { - background-color: #007bff; - color: white; - border: none; - cursor: pointer; - transition: background 0.3s; -} - -input[type="submit"]:hover { - background-color: #0056b3; -} - -/* Buttons */ -button { - padding: 10px 15px; - border: none; - border-radius: 5px; - background-color: #007bff; - color: white; - font-size: 16px; - cursor: pointer; - transition: background 0.3s; -} - -button:hover { - background-color: #0056b3; -} - -/* Statusnachricht */ -#statusMessage { - margin-top: 10px; - padding: 10px; - border-radius: 5px; - background-color: #8cc4fd; - text-align: center; - font-weight: bold; -} - -.features { - display: flex; - justify-content: space-between; - margin-top: 30px; - text-align: left; -} -.feature { - flex: 1; - padding: 0 20px; - border-radius: 8px; - margin: 0 10px 10px; - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05); - border: var(--glass-border); -} -.feature h3 { - font-size: 1.4rem; - margin-bottom: 10px; - color: #007bff; -} -.feature p { - font-size: 1rem; - color: #ffffff; -} - -p { - font-size: 1rem; - color: #ffffff; -} - -a { - color: #007bff; - text-decoration: none; - font-weight: bold; - cursor: pointer; -} -a:hover { - text-decoration: underline; -} - -/* Karten-Stil für optische Trennung */ -.card { - background: var(--primary-color); - width: 500px; - padding: 15px; - margin: 20px auto; - border-radius: 8px; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); -} - -/* Versteckte Elemente */ -.hidden { - display: none; -} - -/* Dropdown-Stil */ -.styled-select { - width: 100%; - padding: 12px 15px; - font-size: 16px; - border: 2px solid #e0e0e0; - border-radius: 8px; - background-color: #fff; - cursor: pointer; - appearance: none; - -webkit-appearance: none; - -moz-appearance: none; - background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23007bff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e"); - background-repeat: no-repeat; - background-position: right 15px center; - background-size: 15px; - transition: all 0.3s ease; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); -} - -.styled-select:hover { - border-color: #007bff; - box-shadow: 0 3px 6px rgba(0, 123, 255, 0.1); -} - -.styled-select:focus { - border-color: #007bff; - outline: none; - box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25); -} - -.styled-select:disabled { - background-color: #f5f5f5; - cursor: not-allowed; - opacity: 0.7; -} - -/* NFC-Status */ -.nfc-status { - font-weight: bold; - margin-top: 10px; -} - -.nfc-card-data { - padding-left: 20px !important; - color: white !important; - font-weight: bold !important; - margin: 0 auto !important; -} - -.nfc-success { - color: green; -} - -.nfc-error { - color: red; -} - -/* Füge diese neuen Styles zu deiner style.css hinzu */ - -.three-column-layout { - display: flex; - justify-content: space-between; - gap: 20px; - margin-top: 5px; - width: 100%; -} - -.column { - flex: 1; - min-width: 0; /* Verhindert Überlauf bei flex-Elementen */ -} - -.feature-box { - background: var(--inner-box-bg); - border: 1px solid rgba(99, 187, 103, 0.2); - border-radius: 0.5rem; - padding: 1rem; - color: var(--inner-text-color); - margin: 10px 0 0 0; -} - -.feature-box h2 { - color: var(--inner-text-color); - font-size: 1.4rem; - margin-bottom: 1rem; - margin-top: 0; - color: var(--accent-color); - text-align: center; -} - -.feature-box ul { - list-style: none; - padding: 0; - margin: 0; -} - -.feature-box ul li { - padding: 8px 5px 5px 5px; - border-bottom: 1px solid #eee; -} - -.content { - width: 95%; - max-width: 1400px; - margin: 0 auto; - padding-top: 100px; - padding-bottom: 20px;; -} - -.tray { - border-radius: 8px; - padding: 15px; - margin: 10px 0; - color: var(--inner-text-color); - background: var(--background-green); - border: 1px solid var(--border-color); - border-radius: 8px; -} - -.tray p { - margin: 5px 0; -} - -/* Responsive Design */ -@media (max-width: 1024px) { - .three-column-layout { - flex-direction: column; - } - - .column { - width: 100%; - } -} - -.nfc-status-display { - display: flex; - align-items: center; - gap: 10px; - padding: 10px 0; -} - -.status-circle { - width: 20px; - height: 20px; - border-radius: 50%; - display: inline-block; - border: 2px solid #ccc; - background-color: #ffffff; -} - -.status-circle.success { - background-color: #28a745; - border-color: #218838; -} - -.status-circle.error { - background-color: #dc3545; - border-color: #c82333; -} - -.nfc-data { - padding: 10px; - background-color: var(--primary-color); - border-radius: 4px; - margin-top: 5px; - width: 100%; -} - -.nfc-data p { - margin: 5px 0; - font-size: 0.9em; -} - -.nfc-status-display { - display: flex; - flex-direction: column; - gap: 10px; -} - -.error-message { - padding: 10px; - background-color: #fff3f3; - border-radius: 4px; - border-left: 4px solid #dc3545; -} - -.info-message { - padding: 10px; - background-color: var(--header-bg); - border-radius: 4px; - border-left: 4px solid #39d82e; -} - -.info-message-inner { - background-color: var(--header-bg) !important; -} - -.nfc-header { - display: grid; - grid-template-columns: 40px 1fr 40px; - align-items: center; - margin-bottom: 10px; -} - -.nfc-header h2 { - margin: 0; - grid-column: 2; - text-align: center; - color: var(--accent-color); -} - -.nfc-header .status-circle { - grid-column: 3; - justify-self: end; -} - -.content-header { - display: flex; - justify-content: center; - align-items: center; - position: relative; -} - -.connection-status { - display: flex; - align-items: center; - gap: 10px; - background-color: #fff3f3; - border: 1px solid #dc3545; - border-radius: 4px; - padding: 10px 15px; - margin: 15px auto; - color: #dc3545; - position: fixed; - top: 20px; - left: 50%; - transform: translateX(-50%); - z-index: 1000; - box-shadow: 0 2px 4px rgba(0,0,0,0.1); - max-width: 90%; - opacity: 0; - transition: opacity 0.3s ease; -} - -.connection-status.visible { - opacity: 1; -} - -.spinner { - flex-shrink: 0; - width: 16px; - height: 16px; - border: 2px solid rgba(220, 53, 69, 0.2); - border-top-color: #dc3545; - border-radius: 50%; -} - -.connection-status.visible .spinner { - animation: spin 0.8s linear infinite; -} - -@keyframes spin { - to { transform: rotate(360deg); } -} - -.connection-status.hidden { - display: none; -} - -.nfc-actions { - display: flex; - gap: 10px; - justify-content: center; /* Zentriert das div */ -} - -.btn { - padding: 8px 16px; - border-radius: 4px; - border: none; - cursor: pointer; - font-weight: bold; -} - -.btn-primary { - background-color: #007bff; - color: white; -} - -.btn-primary:hover { - background-color: #0056b3; -} - -.btn-danger { - background-color: #dc3545; - color: white; -} - -.btn-danger:hover { - background-color: #c82333; -} - -/* Filament Select Styling */ -#filamentSelect { - width: 100%; - padding: 12px 15px; - font-size: 16px; - border: 2px solid #e0e0e0; - border-radius: 8px; - background-color: #fff; - cursor: pointer; - appearance: none; - -webkit-appearance: none; - -moz-appearance: none; - background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23007bff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e"); - background-repeat: no-repeat; - background-position: right 15px center; - background-size: 15px; - transition: all 0.3s ease; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05); -} - -#filamentSelect:hover { - border-color: #007bff; - box-shadow: 0 3px 6px rgba(0, 123, 255, 0.1); -} - -#filamentSelect:focus { - border-color: #007bff; - outline: none; - box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25); -} - -#filamentSelect option { - padding: 8px 15px; - font-size: 16px; - background-color: #fff; - color: #000; /* Standard Textfarbe für alles außer dem Farbblock */ -} - -#filamentSelect option::first-letter { - font-size: 16px; - margin-right: 5px; -} - -#filamentSelect option::before { - content: ''; - display: inline-block; - width: 12px; - margin-right: 8px; -} - -/* Color Box im Select */ -.color-box { - display: inline-block; - width: 12px; - height: 12px; - border: 1px solid #333; - border-radius: 2px; - margin-right: 5px; - vertical-align: middle; -} - -#filamentSelect option span { - display: inline-block; - pointer-events: none; -} - -#filamentSelect option span:first-child { - margin-right: 5px; - font-size: 16px; -} - -/* Filament Select Option Styling */ -#filamentSelect option span.color-circle { - display: inline-block; - width: 12px; - height: 12px; - border-radius: 50%; - margin-right: 8px; - border: 1px solid #333; - vertical-align: middle; -} - -/* Custom Dropdown */ -.custom-dropdown { - position: relative; - width: 100%; - font-family: inherit; - cursor: default; /* Container selbst soll normalen Cursor haben */ - color: black; -} - -.dropdown-button { - padding: 12px 15px; - border: 2px solid #e0e0e0; - border-radius: 8px; - background-color: #fff; - cursor: pointer; - display: flex; - align-items: center; - gap: 8px; - transition: all 0.3s ease; -} - -.dropdown-button:hover { - border-color: #007bff; -} - -.selected-color { - width: 16px; - height: 16px; - border-radius: 50%; - border: 1px solid #333; - flex-shrink: 0; -} - -.dropdown-arrow { - margin-left: auto; - color: #007bff; - font-size: 12px; -} - -.dropdown-content { - display: none; - position: absolute; - top: 100%; - left: 0; - right: 0; - background-color: #fff; - border: 1px solid #e0e0e0; - border-radius: 8px; - margin-top: 4px; - max-height: 300px; - overflow-y: auto; - z-index: 1000; - box-shadow: 0 2px 4px rgba(0,0,0,0.1); -} - -.dropdown-content.show { - display: block; -} - -.dropdown-option { - padding: 10px 15px; - cursor: pointer; - display: flex; - align-items: center; - gap: 8px; -} - -.dropdown-option:hover { - background-color: #f8f9fa; -} - -.option-color { - width: 16px; - height: 16px; - border-radius: 50%; - border: 1px solid #333; - flex-shrink: 0; -} - -/* Multi-color filament styles */ -.option-colors { - display: flex; - flex-shrink: 0; - gap: 2px; -} - -.multi-color { - width: 14px; - height: 14px; - border-radius: 50%; - border: 1px solid #333; -} - -/* Coaxial pattern (horizontal stripes) */ -.multi-color.coaxial { - border-radius: 50%; - position: relative; -} - -/* Longitudinal pattern (vertical stripes) */ -.multi-color.longitudinal { - border-radius: 50%; - position: relative; -} - -/* Container for multiple colors in selected display */ -.multi-color-container { - display: flex !important; - background: none !important; - border: none !important; - gap: 2px; - align-items: center; - justify-content: flex-start; - width: auto !important; -} - -.color-segment { - width: 16px; - height: 16px; - border-radius: 50%; - border: 1px solid #333; -} - -.notification { - position: fixed; - top: 20px; - right: 20px; - padding: 15px 25px; - border-radius: 4px; - color: black; - z-index: 1000; - animation: slideIn 0.3s ease-out; -} - -.notification.success { - background-color: #28a745; - color: black !important; -} - -.notification.error { - background-color: #dc3545; - color: white !important; -} - -.notification.fade-out { - opacity: 0; - transition: opacity 0.3s ease-out; -} - -@keyframes slideIn { - from { - transform: translateX(100%); - opacity: 0; - } - to { - transform: translateX(0); - opacity: 1; - } -} - -/* Neue Styles für die Statistiken */ -.statistics-grid { - display: grid; - grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); - gap: 1rem; - margin-top: 15px; -} - -.statistics-column { - background: var(--inner-box-bg); - border: 1px solid rgba(99, 187, 103, 0.2); - border-radius: 0.5rem; -} - -.statistics-column h3 { - color: var(--inner-text-color); - border-bottom: 1px solid rgba(99, 187, 103, 0.2); - font-size: 1.1rem; -} - -.statistics-list { - list-style: none; - padding: 0; - margin: 0; -} - -.statistics-list li { - display: flex; - justify-content: space-between; - padding: 0.5rem; - border-bottom: 1px solid rgba(99, 187, 103, 0.1); -} - -.statistics-list li:last-child { - border-bottom: none; -} - -.stat-label { - color: var(--inner-text-color); -} - -.stat-value { - color: var(--stat-value-color); - font-weight: 500; -} - -/* Responsive Design Anpassung */ -@media (max-width: 768px) { - .statistics-grid { - grid-template-columns: 1fr; - } -} - -.statistics-header { - display: flex; - justify-content: space-between; - align-items: center; - margin-bottom: 15px; - padding-bottom: 0; - border-bottom: 1px solid #e9ecef; -} - -.refresh-button { - display: flex; - align-items: center; - padding: 8px 16px; - background-color: #007bff; - color: white; - border: none; - border-radius: 4px; - cursor: pointer; - font-size: 14px; - transition: background-color 0.2s; -} - -.refresh-button:hover { - background-color: #0056b3; -} - -.refresh-button:active { - background-color: #004494; -} - -.spools-info { - display: flex; - justify-content: flex-start; - gap: 20px; - margin-bottom: 15px; -} - -.spool-stat { - display: flex; - align-items: center; - gap: 8px; - background: var(--inner-box-bg); - border: 1px solid rgba(99, 187, 103, 0.2); - border-radius: 0.5rem; -} - -.spool-stat .stat-label { - color: var(--inner-text-color); -} - -.spool-stat .stat-value { - color: var(--stat-value-color); - font-weight: 500; -} - -/* Buttons und klickbare Elemente */ -button, -input[type="submit"], -.dropdown-button, -.dropdown-option, -.refresh-button, -.btn, -.styled-select, -select, -a { - cursor: pointer !important; -} - -/* Disabled Zustände */ -button:disabled, -input[type="submit"]:disabled, -.btn:disabled, -.styled-select:disabled { - cursor: not-allowed !important; - opacity: 0.7; -} - -/* Schreib-Button */ -#writeNfcButton, #writeLocationNfcButton { - background-color: #007bff; - color: white; - transition: background-color 0.3s, color 0.3s; - width: 160px; -} - -#writeNfcButton.writing, #writeLocationNfcButton.writing { - background-color: #ffc107; - color: black; - width: 160px; -} - -#writeNfcButton.success, #writeLocationNfcButton.success { - background-color: #28a745; - color: white; - width: 160px; -} - -#writeNfcButton.error, #writeLocationNfcButton.error { - background-color: #dc3545; - color: white; - width: 160px; -} - -#writeLocationNfcButton{ - width: 250px; -} - -@keyframes dots { - 0% { content: ""; } - 33% { content: "."; } - 66% { content: ".."; } - 100% { content: "..."; } -} - -#writeNfcButton.writing::after, #writeLocationNfcButton.writing::after { - content: "..."; - animation: dots 1s steps(3, end) infinite; -} - -/* Bambu Settings Erweiterung */ -.bambu-settings { - padding: 20px; - border-radius: 8px; - box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); - max-width: 400px; - margin: 20px auto; -} - -.bambu-settings .input-group { - margin-bottom: 15px; - text-align: left; -} - -.bambu-settings .input-group label { - display: block; - margin-bottom: 5px; -} - -.bambu-settings .input-group input { - width: 95%; -} - -#bambuStatusMessage { - margin-top: 15px; - display: flex; - align-items: center; - gap: 10px; - justify-content: center; -} - -.amsData { - border-color: black !important; - border-width: 1px !important; -} - -.tray { - position: relative; -} - -.tray-head { - color: var(--stat-value-color) !important; - text-align: center !important; - font-weight: bold !important; -} - -.spool-button:hover { - opacity: 0.8; -} - -.version { - font-size: 0.4em; - color: #000; - vertical-align: middle; - margin-left: 0.5rem; - text-shadow: none !important; -} - -.progress-container { - width: 100%; - margin: 20px 0; - display: none; - background: #f0f0f0; - border-radius: 4px; - overflow: hidden; -} -.progress-bar { - width: 0%; - height: 24px; - background-color: #4CAF50; - text-align: center; - line-height: 24px; - color: white; - transition: width 0.3s ease-in-out; - font-weight: bold; -} -.status { - margin: 10px 0; - padding: 15px; - border-radius: 4px; - display: none; -} -.error { - background-color: #ffebee; - color: #c62828; - border: 1px solid #ef9a9a; -} -.success { - background-color: #e8f5e9; - color: #2e7d32; - border: 1px solid #a5d6a7; -} -.update-form { - background: var(--primary-color); - box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05); - border: var(--glass-border); - padding: 20px; - border-radius: 8px; - margin: 0 auto; - width: 400px; - text-align: center; -} -.update-form input[type="file"] { - margin-bottom: 15px; - width: 80%; - padding: 8px; - border: 1px solid #ddd; - border-radius: 4px; - background-color: #4CAF50; -} -.update-form input[type="submit"] { - background-color: #4CAF50; - color: white; - padding: 10px 20px; - border: none; - border-radius: 4px; - cursor: pointer; - font-size: 16px; - transition: background-color 0.3s; -} -.update-form input[type="submit"]:hover { - background-color: #45a049; -} -.update-form input[type="submit"]:disabled { - background-color: #cccccc; - cursor: not-allowed; -} -.warning { - background-color: var(--primary-color); - border: 1px solid #ffe0b2; - margin: 20px auto; - border-radius: 4px; - max-width: 600px; - text-align: center; - color: #e65100; - padding: 15px; -} - -.update-options { - display: flex; - gap: 2rem; - margin: 2rem 0; -} -.update-section { - flex: 1; - background: var(--background-green); - padding: 1.5rem; - border-radius: 8px; -} -.update-section h2 { - margin-top: 0; - color: #333; -} -.update-section p { - color: #666; - margin-bottom: 1rem; -} -.progress-container { - margin: 20px 0; - background: #f0f0f0; - border-radius: 4px; - overflow: hidden; -} -.progress-bar { - width: 0; - height: 20px; - background: #4CAF50; - transition: width 0.3s ease-in-out; - text-align: center; - line-height: 20px; - color: white; -} -.status { - margin-top: 20px; - padding: 10px; - border-radius: 4px; - display: none; -} -.status.success { - background: #e8f5e9; - color: #2e7d32; -} -.status.error { - background: #ffebee; - color: #c62828; -} -.warning { - background: #fff3e0; - color: #e65100; - padding: 15px; - border-radius: 4px; - margin-bottom: 20px; -} \ No newline at end of file diff --git a/html/upgrade.html b/html/upgrade.html deleted file mode 100644 index 3ecbd75..0000000 --- a/html/upgrade.html +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - FilaMan - Filament Management Tool - - - - - - - -
-

Firmware Upgrade

- -
- Warning: Do not power off the device during update. -
- -
-
-

1) Firmware Update

-

Upload a new firmware file (upgrade_filaman_firmware_*.bin)

-
-
- - -
-
-
- -
-

2) Webpage Update

-

Upload a new webpage file (upgrade_filaman_website_*.bin)

-
-
- - -
-
-
-
- - -
-
- - - - diff --git a/html/waage.html b/html/waage.html deleted file mode 100644 index d82f435..0000000 --- a/html/waage.html +++ /dev/null @@ -1,136 +0,0 @@ - - - - - - FilaMan - Scale Configuration - - - - - - - -
-

Scale Configuration

- -
-
-
Scale Actions
- - -    Enable Auto-TARE -
-
-
- - -
- - - - diff --git a/html/wifi.html b/html/wifi.html deleted file mode 100644 index 8dcee67..0000000 --- a/html/wifi.html +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - FilaMan - Filament Management Tool - - - - - - - -
-

WiFi Configuration

-

Your device is connected to WiFi.

-

To change WiFi settings, you can reset the WiFi configuration by holding the hardware button (if available) or using the WiFi manager portal.

-
- - - - diff --git a/platformio.ini b/platformio.ini index 4c33fc0..ad819e1 100644 --- a/platformio.ini +++ b/platformio.ini @@ -58,15 +58,11 @@ build_flags = -DCONFIG_LWIP_TCP_MSL=60000 -DCONFIG_LWIP_TCP_RCV_BUF_DEFAULT=4096 -DCONFIG_LWIP_MAX_ACTIVE_TCP=16 + -DCONFIG_ASYNC_TCP_RUNNING_CORE=0 + -DCONFIG_ASYNC_TCP_USE_WDT=0 extra_scripts = scripts/extra_script.py - ${env:buildfs.extra_scripts} - -[env:buildfs] -extra_scripts = - pre:scripts/combine_html.py ; Combine header with HTML files - scripts/gzip_files.py ; Compress files for SPIFFS [platformio] default_envs = esp32dev diff --git a/scripts/combine_html.py b/scripts/combine_html.py deleted file mode 100644 index def4a95..0000000 --- a/scripts/combine_html.py +++ /dev/null @@ -1,34 +0,0 @@ -Import("env") -import os -import re - -def combine_html_files(source, target, env): - print("COMBINE HTML FILES") - - html_dir = "./html" - header_file = os.path.join(html_dir, "header.html") - - # Read header content - with open(header_file, 'r') as f: - header_content = f.read() - - # Process all HTML files except header.html - for filename in os.listdir(html_dir): - if filename.endswith('.html') and filename != 'header.html': - file_path = os.path.join(html_dir, filename) - - # Read content - with open(file_path, 'r') as f: - content = f.read() - - # Replace content between head comments with header content - pattern = r'().*?()' - new_content = re.sub(pattern, r'\1' + header_content + r'\2', content, flags=re.DOTALL) - - # Write back combined content - with open(file_path, 'w') as f: - f.write(new_content) - print(f"Combined header with {filename}") - -# Register the script to run before building SPIFFS -env.AddPreAction("buildfs", combine_html_files) \ No newline at end of file diff --git a/scripts/gzip_files.py b/scripts/gzip_files.py deleted file mode 100644 index b67c70a..0000000 --- a/scripts/gzip_files.py +++ /dev/null @@ -1,48 +0,0 @@ -import gzip -import os -import shutil - -## gzip files - -def compress_file(input_file, output_file): - with open(input_file, 'rb') as f_in: - with gzip.open(output_file, 'wb') as f_out: - f_out.writelines(f_in) - -def copy_file(input_file, output_file): - shutil.copy2(input_file, output_file) - -def should_compress(file): - # Skip compression for spoolman.html - if file == 'spoolman.html' or file == 'waage.html': - return False - # Komprimiere nur bestimmte Dateitypen - return file.endswith(('.js', '.png', '.css', '.html')) - -def main(source_dir, target_dir): - for root, dirs, files in os.walk(source_dir): - rel_path = os.path.relpath(root, source_dir) - for file in files: - input_file = os.path.join(root, file) - output_file_compressed = os.path.join(target_dir, rel_path, file + '.gz') - output_file_original = os.path.join(target_dir, rel_path, file) - - os.makedirs(os.path.dirname(output_file_compressed), exist_ok=True) - - if should_compress(file): - compress_file(input_file, output_file_compressed) - print(f'Compressed {input_file} to {output_file_compressed}') - else: - copy_file(input_file, output_file_original) - print(f'Copied {input_file} to {output_file_original}') - -def init(): - source_dir = 'html' - target_dir = 'data' - - if os.path.exists(target_dir): - shutil.rmtree(target_dir) - - main(source_dir, target_dir) - -init() \ No newline at end of file diff --git a/src/api.cpp b/src/api.cpp index 4cff372..ccee5dc 100644 --- a/src/api.cpp +++ b/src/api.cpp @@ -12,6 +12,20 @@ volatile filamanApiStateType filamanApiState = API_IDLE; bool filamanConnected = false; +struct ApiRequest { + FilamanApiRequestType type; + int id1; + int id2; + String str1; + String str2; + float val; + bool active = false; +}; + +#define MAX_API_QUEUE 10 +ApiRequest apiQueue[MAX_API_QUEUE]; +SemaphoreHandle_t queueMutex; + void saveFilamanConfig() { Preferences preferences; preferences.begin(NVS_NAMESPACE_API, false); @@ -36,136 +50,174 @@ bool checkFilamanRegistration() { bool registerDevice(const String& deviceCode) { if (filamanUrl.length() == 0) return false; - HTTPClient http; - String url = filamanUrl + "/api/v1/devices/register"; - - http.begin(url); + http.setTimeout(5000); + http.begin(filamanUrl + "/api/v1/devices/register"); http.addHeader("Content-Type", "application/json"); http.addHeader("X-Device-Code", deviceCode); - int httpCode = http.POST("{}"); - bool success = false; - - if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_CREATED) { - String payload = http.getString(); + if (httpCode == 200 || httpCode == 201) { JsonDocument doc; - DeserializationError error = deserializeJson(doc, payload); - if (!error && doc["token"].is()) { - filamanToken = doc["token"].as(); - filamanRegistered = true; - saveFilamanConfig(); - success = true; - Serial.println("Device successfully registered!"); + if (!deserializeJson(doc, http.getString())) { + if (doc["token"].is()) { + filamanToken = doc["token"].as(); + filamanRegistered = true; + saveFilamanConfig(); + http.end(); + return true; + } } - } else { - Serial.printf("Registration failed, HTTP code: %d\n", httpCode); } - http.end(); - return success; + return false; } bool sendHeartbeat() { - if (!checkFilamanRegistration()) return false; - + if (!checkFilamanRegistration() || WiFi.status() != WL_CONNECTED) return false; HTTPClient http; - String url = filamanUrl + "/api/v1/devices/heartbeat"; - - http.begin(url); + http.setTimeout(3000); + http.begin(filamanUrl + "/api/v1/devices/heartbeat"); http.addHeader("Content-Type", "application/json"); http.addHeader("Authorization", "Device " + filamanToken); - JsonDocument doc; doc["ip_address"] = WiFi.localIP().toString(); String payload; serializeJson(doc, payload); - int httpCode = http.POST(payload); - bool success = (httpCode == HTTP_CODE_OK); - - if (success) { - filamanConnected = true; - } else { - Serial.printf("Heartbeat failed, HTTP code: %d\n", httpCode); - if (httpCode == 401) { - filamanRegistered = false; // Token might be invalid - saveFilamanConfig(); - } - filamanConnected = false; - } - + filamanConnected = (httpCode == 200); http.end(); - return success; + return filamanConnected; } bool sendWeight(int spoolId, String tagUuid, float measuredWeight) { - if (!checkFilamanRegistration()) return false; - + if (!checkFilamanRegistration() || WiFi.status() != WL_CONNECTED) return false; HTTPClient http; - String url = filamanUrl + "/api/v1/devices/scale/weight"; - - http.begin(url); + http.setTimeout(3000); + http.begin(filamanUrl + "/api/v1/devices/scale/weight"); http.addHeader("Content-Type", "application/json"); http.addHeader("Authorization", "Device " + filamanToken); - JsonDocument doc; if (spoolId > 0) doc["spool_id"] = spoolId; if (tagUuid.length() > 0) doc["tag_uuid"] = tagUuid; doc["measured_weight_g"] = measuredWeight; - String payload; serializeJson(doc, payload); - int httpCode = http.POST(payload); - bool success = (httpCode == HTTP_CODE_OK); - - if (!success) { - Serial.printf("Weight update failed, HTTP code: %d\n", httpCode); - } - http.end(); - return success; + return (httpCode == 200); } bool sendLocation(int spoolId, String spoolTagUuid, int locationId, String locationTagUuid) { - if (!checkFilamanRegistration()) return false; - + if (!checkFilamanRegistration() || WiFi.status() != WL_CONNECTED) return false; HTTPClient http; - String url = filamanUrl + "/api/v1/devices/scale/locate"; - - http.begin(url); + http.setTimeout(3000); + http.begin(filamanUrl + "/api/v1/devices/scale/locate"); http.addHeader("Content-Type", "application/json"); http.addHeader("Authorization", "Device " + filamanToken); - JsonDocument doc; if (spoolId > 0) doc["spool_id"] = spoolId; if (spoolTagUuid.length() > 0) doc["spool_tag_uuid"] = spoolTagUuid; if (locationId > 0) doc["location_id"] = locationId; if (locationTagUuid.length() > 0) doc["location_tag_uuid"] = locationTagUuid; - String payload; serializeJson(doc, payload); - int httpCode = http.POST(payload); - bool success = (httpCode == HTTP_CODE_OK); - - if (!success) { - Serial.printf("Location update failed, HTTP code: %d\n", httpCode); - } - http.end(); - return success; + return (httpCode == 200); +} + +void filamanApiTask(void* pvParameters) { + for (;;) { + ApiRequest req; + bool hasReq = false; + + if (xSemaphoreTake(queueMutex, pdMS_TO_TICKS(100)) == pdTRUE) { + for(int i=0; i(); int sId = lastSpoolId.toInt(); - sendLocation(sId, "", locId, ""); + sendLocationAsync(sId, "", locId, ""); } else { @@ -1867,15 +1867,6 @@ void scanRfidTask(void * parameter) { foundNfcTag(nullptr, success); - // Reset activeSpoolId and activeTagUuid immediately when no tag is detected - if (!success) { - activeSpoolId = ""; - activeTagUuid = ""; - Serial.println("Tag entfernt"); - oledShowWeight(weight); - } - - // As long as there is still a tag on the reader, do not try to read it again if (success && nfcReaderState == NFC_IDLE) { @@ -1989,12 +1980,11 @@ void scanRfidTask(void * parameter) { if (!success && nfcReaderState != NFC_IDLE && !nfcReadingTaskSuspendRequest) { + Serial.printf("NFC: Tag removed (Previous state: %d)\n", nfcReaderState); nfcReaderState = NFC_IDLE; - //uidString = ""; nfcJsonData = ""; activeSpoolId = ""; activeTagUuid = ""; - Serial.println("Tag entfernt"); oledShowWeight(weight); } @@ -2012,7 +2002,7 @@ void scanRfidTask(void * parameter) { // Reduced from 5 seconds to 3 seconds } else { // Faster scanning when no tag or idle state - vTaskDelay(pdMS_TO_TICKS(150)); + vTaskDelay(pdMS_TO_TICKS(250)); // Faster scan interval } diff --git a/src/scale.cpp b/src/scale.cpp index 21a74d8..2b3415c 100644 --- a/src/scale.cpp +++ b/src/scale.cpp @@ -1,4 +1,5 @@ #include "nfc.h" +#include "scale.h" #include #include #include "config.h" @@ -35,6 +36,7 @@ uint8_t pauseMainTask = 0; bool scaleCalibrated; bool autoTare = true; bool scaleCalibrationActive = false; +volatile bool scaleCalibrationRequest = false; // ##### Weight stabilization functions ##### @@ -178,6 +180,12 @@ void scale_loop(void * parameter) { weight = 0; // Reset global weight variable after tare } + // Check for calibration request + if (scaleCalibrationRequest) { + scaleCalibrationRequest = false; + calibrate_scale(); + } + // Get raw weight reading float rawWeight = scale.get_units(); @@ -286,7 +294,8 @@ uint8_t calibrate_scale() { scaleCalibrationActive = true; if (RfidReaderTask != NULL) vTaskSuspend(RfidReaderTask); - if (ScaleTask != NULL) vTaskSuspend(ScaleTask); + // Do not suspend ScaleTask if we are running inside it + if (ScaleTask != NULL && xTaskGetCurrentTaskHandle() != ScaleTask) vTaskSuspend(ScaleTask); pauseMainTask = 1; @@ -393,7 +402,7 @@ uint8_t calibrate_scale() { } if (RfidReaderTask != NULL) vTaskResume(RfidReaderTask); - if (ScaleTask != NULL) vTaskResume(ScaleTask); + if (ScaleTask != NULL && xTaskGetCurrentTaskHandle() != ScaleTask) vTaskResume(ScaleTask); pauseMainTask = 0; scaleCalibrationActive = false; diff --git a/src/scale.h b/src/scale.h index aff65e1..3b14fc2 100644 --- a/src/scale.h +++ b/src/scale.h @@ -5,7 +5,7 @@ #include "HX711.h" uint8_t setAutoTare(bool autoTareValue); -uint8_t start_scale(bool touchSensorConnected); +void start_scale(bool touchSensorConnected); uint8_t calibrate_scale(); uint8_t tareScale(); @@ -20,12 +20,13 @@ extern HX711 scale; extern int16_t weight; extern uint8_t weightCounterToApi; extern uint8_t scale_tare_counter; -extern uint8_t scaleTareRequest; +extern bool scaleTareRequest; extern uint8_t pauseMainTask; extern bool scaleCalibrated; extern bool autoTare; extern bool scaleCalibrationActive; +extern volatile bool scaleCalibrationRequest; extern TaskHandle_t ScaleTask; -#endif \ No newline at end of file +#endif diff --git a/src/website.cpp b/src/website.cpp index 43d3454..bdefba0 100644 --- a/src/website.cpp +++ b/src/website.cpp @@ -16,8 +16,7 @@ #define VERSION "1.2.0" #endif -// Cache-Control Header definieren -#define CACHE_CONTROL "max-age=604800" // Cache für 1 Woche +#define NO_CACHE "no-cache, no-store, must-revalidate" AsyncWebServer server(webserverPort); AsyncWebSocket ws("/ws"); @@ -25,43 +24,26 @@ AsyncWebSocket ws("/ws"); uint8_t lastSuccess = 0; nfcReaderStateType lastnfcReaderState = NFC_IDLE; - void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type, void *arg, uint8_t *data, size_t len) { - HEAP_DEBUG_MESSAGE("onWsEvent begin"); if (type == WS_EVT_CONNECT) { - Serial.println("Neuer Client verbunden!"); + Serial.printf("WS Client #%u connected\n", client->id()); sendNfcData(); - foundNfcTag(client, 0); - sendWriteResult(client, 3); - - // Clean up dead connections - (*server).cleanupClients(); - Serial.println("Currently connected number of clients: " + String((*server).getClients().size())); - } else if (type == WS_EVT_DISCONNECT) { - Serial.println("Client getrennt."); - } else if (type == WS_EVT_ERROR) { - Serial.printf("WebSocket Client #%u error(%u): %s\n", client->id(), *((uint16_t*)arg), (char*)data); - } else if (type == WS_EVT_PONG) { - Serial.printf("WebSocket Client #%u pong\n", client->id()); + ws.text(client->id(), "{\"type\":\"nfcTag\", \"payload\":{\"found\": " + String(lastSuccess) + "}}"); + server->cleanupClients(); } else if (type == WS_EVT_DATA) { JsonDocument doc; DeserializationError error = deserializeJson(doc, (char*)data, len); - - if (error) { - Serial.println("JSON deserialization failed: " + String(error.c_str())); - return; - } + if (error) return; if (doc["type"] == "heartbeat") { - // Sende Heartbeat-Antwort ws.text(client->id(), "{" "\"type\":\"heartbeat\"," "\"freeHeap\":" + String(ESP.getFreeHeap()/1024) + "," "\"filaman_connected\":" + String(filamanConnected) + "," - "\"registered\":" + String(filamanRegistered) + "" + "\"registered\":" + String(filamanRegistered) + "," + "\"autoTare\":" + String(autoTare ? "true" : "false") + "" "}"); } - else if (doc["type"] == "writeNfcTag") { if (doc["payload"].is()) { String payloadString; @@ -69,222 +51,166 @@ void onWsEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventTyp startWriteJsonToTag((doc["tagType"] == "spool") ? true : false, payloadString.c_str()); } } - else if (doc["type"] == "scale") { - uint8_t success = 0; if (doc["payload"] == "tare") { scaleTareRequest = true; - success = 1; - } - - if (doc["payload"] == "calibrate") { - success = calibrate_scale(); - } - - if (doc["payload"] == "setAutoTare") { - success = setAutoTare(doc["enabled"].as()); - } - - if (success) { ws.textAll("{\"type\":\"scale\",\"payload\":\"success\"}"); - } else { - ws.textAll("{\"type\":\"scale\",\"payload\":\"error\"}"); + } + else if (doc["payload"] == "calibrate") { + scaleCalibrationRequest = true; + ws.textAll("{\"type\":\"scale\",\"payload\":\"success\"}"); + } + else if (doc["payload"] == "setAutoTare") { + setAutoTare(doc["enabled"].as()); + ws.textAll("{\"type\":\"scale\",\"payload\":\"success\"}"); } } - else if (doc["type"] == "reconnect") { if (doc["payload"] == "filaman") { - sendHeartbeat(); + sendHeartbeatAsync(); } } - - else { - Serial.println("Unbekannter WebSocket-Typ: " + doc["type"].as()); - } - doc.clear(); } - HEAP_DEBUG_MESSAGE("onWsEvent end"); -} - -String loadHtmlWithHeader(const char* filename) { - Serial.println("Lade HTML-Datei: " + String(filename)); - if (!LittleFS.exists(filename)) { - Serial.println("Fehler: Datei nicht gefunden!"); - return "Fehler: Datei nicht gefunden!"; - } - - File file = LittleFS.open(filename, "r"); - String html = file.readString(); - file.close(); - - return html; } void sendWriteResult(AsyncWebSocketClient *client, uint8_t success) { String response = "{\"type\":\"writeNfcTag\",\"success\":" + String(success ? "1" : "0") + "}"; - ws.textAll(response); + if (client) client->text(response); else ws.textAll(response); } void foundNfcTag(AsyncWebSocketClient *client, uint8_t success) { - if (success == lastSuccess) return; + if (success == lastSuccess && client == nullptr) return; ws.textAll("{\"type\":\"nfcTag\", \"payload\":{\"found\": " + String(success) + "}}"); - sendNfcData(); lastSuccess = success; } void sendNfcData() { - if (lastnfcReaderState == nfcReaderState) return; switch(nfcReaderState){ - case NFC_IDLE: - ws.textAll("{\"type\":\"nfcData\", \"payload\":{}}"); - break; - case NFC_READ_SUCCESS: - ws.textAll("{\"type\":\"nfcData\", \"payload\":" + nfcJsonData + "}"); - break; - case NFC_READ_ERROR: - ws.textAll("{\"type\":\"nfcData\", \"payload\":{\"error\":\"Empty Tag or Data not readable\"}}"); - break; - case NFC_WRITING: - ws.textAll("{\"type\":\"nfcData\", \"payload\":{\"info\":\"Schreibe Tag...\"}}"); - break; - case NFC_WRITE_SUCCESS: - ws.textAll("{\"type\":\"nfcData\", \"payload\":{\"info\":\"Tag erfolgreich geschrieben\"}}"); - break; - case NFC_WRITE_ERROR: - ws.textAll("{\"type\":\"nfcData\", \"payload\":{\"error\":\"Error writing to Tag\"}}"); - break; - case DEFAULT: - ws.textAll("{\"type\":\"nfcData\", \"payload\":{\"error\":\"Something went wrong\"}}"); + case NFC_IDLE: ws.textAll("{\"type\":\"nfcData\", \"payload\":{}}"); break; + case NFC_READ_SUCCESS: ws.textAll("{\"type\":\"nfcData\", \"payload\":" + nfcJsonData + "}"); break; + case NFC_READ_ERROR: ws.textAll("{\"type\":\"nfcData\", \"payload\":{\"error\":\"Read Error\"}}"); break; + case NFC_WRITING: ws.textAll("{\"type\":\"nfcData\", \"payload\":{\"info\":\"Writing...\"}}"); break; + case NFC_WRITE_SUCCESS: ws.textAll("{\"type\":\"nfcData\", \"payload\":{\"info\":\"Success\"}}"); break; + case NFC_WRITE_ERROR: ws.textAll("{\"type\":\"nfcData\", \"payload\":{\"error\":\"Write Error\"}}"); break; + default: break; } - lastnfcReaderState = nfcReaderState; } void setupWebserver(AsyncWebServer &server) { oledShowProgressBar(2, 7, DISPLAY_BOOT_TEXT, "Webserver init"); - Serial.setDebugOutput(false); ws.onEvent(onWsEvent); - ws.enable(true); + server.addHandler(&ws); - server.onRequestBody([](AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total){}); - server.onFileUpload([](AsyncWebServerRequest *request, const String& filename, size_t index, uint8_t *data, size_t len, bool final){}); - - loadFilamanConfig(); - - // Route für Start (Index) + // Static Routes server.on("/", HTTP_GET, [](AsyncWebServerRequest *request){ - String html = loadHtmlWithHeader("/index.html"); - request->send(200, "text/html", html); + Serial.println("Web: Request /"); + AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/index.html", "text/html"); + response->addHeader("Cache-Control", NO_CACHE); + request->send(response); }); - // Route für Waage server.on("/waage", HTTP_GET, [](AsyncWebServerRequest *request){ - String html = loadHtmlWithHeader("/waage.html"); - html.replace("{{autoTare}}", (autoTare) ? "checked" : ""); - request->send(200, "text/html", html); + Serial.println("Web: Request /waage"); + AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/waage.html", "text/html"); + response->addHeader("Cache-Control", NO_CACHE); + request->send(response); }); - // Route für Setup & Registration server.on("/setup", HTTP_GET, [](AsyncWebServerRequest *request){ - String html = loadHtmlWithHeader("/setup.html"); - html.replace("{{filamanUrl}}", filamanUrl); - html.replace("{{registered}}", filamanRegistered ? "Yes" : "No"); - request->send(200, "text/html", html); + Serial.println("Web: Request /setup"); + AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/setup.html", "text/html"); + response->addHeader("Cache-Control", NO_CACHE); + request->send(response); + }); + + server.on("/wifi", HTTP_GET, [](AsyncWebServerRequest *request){ + Serial.println("Web: Request /wifi"); + AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/wifi.html", "text/html"); + response->addHeader("Cache-Control", NO_CACHE); + request->send(response); + }); + + server.on("/upgrade", HTTP_GET, [](AsyncWebServerRequest *request) { + Serial.println("Web: Request /upgrade"); + AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/upgrade.html", "text/html"); + response->addHeader("Cache-Control", NO_CACHE); + request->send(response); + }); + + server.on("/style.css", HTTP_GET, [](AsyncWebServerRequest *request){ + AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/style.css", "text/css"); + response->addHeader("Cache-Control", NO_CACHE); + request->send(response); + }); + + server.on("/logo.png", HTTP_GET, [](AsyncWebServerRequest *request){ + AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/logo.png", "image/png"); + response->addHeader("Cache-Control", NO_CACHE); + request->send(response); + }); + + server.on("/favicon.ico", HTTP_GET, [](AsyncWebServerRequest *request){ + AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/favicon.ico", "image/x-icon"); + response->addHeader("Cache-Control", NO_CACHE); + request->send(response); + }); + + // API Routes + server.on("/api/config", HTTP_GET, [](AsyncWebServerRequest *request){ + JsonDocument doc; + doc["url"] = filamanUrl; + doc["registered"] = filamanRegistered; + String response; + serializeJson(doc, response); + request->send(200, "application/json", response); }); server.on("/api/register", HTTP_POST, [](AsyncWebServerRequest *request){}, NULL, [](AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total){ JsonDocument doc; - deserializeJson(doc, (const char*)data); - + DeserializationError error = deserializeJson(doc, (const uint8_t*)data, len); + if (error) { + request->send(400, "application/json", "{\"success\": false, \"error\": \"Invalid JSON\"}"); + return; + } if (doc["url"].is()) filamanUrl = doc["url"].as(); - String code = doc["code"].as(); - saveFilamanConfig(); - - if (registerDevice(code)) { + if (registerDevice(doc["code"].as())) { request->send(200, "application/json", "{\"success\": true}"); } else { request->send(400, "application/json", "{\"success\": false}"); } }); - // API for Backend to trigger Tag write server.on("/api/v1/rfid/write", HTTP_POST, [](AsyncWebServerRequest *request){}, NULL, [](AsyncWebServerRequest *request, uint8_t *data, size_t len, size_t index, size_t total){ - // Check Authorization? (TBD) JsonDocument doc; - deserializeJson(doc, (const char*)data); - + DeserializationError error = deserializeJson(doc, (const uint8_t*)data, len); + if (error) { + request->send(400, "application/json", "{\"success\": false, \"error\": \"Invalid JSON\"}"); + return; + } String payloadString; serializeJson(doc, payloadString); - - bool isSpool = !doc["spool_id"].isNull(); - startWriteJsonToTag(isSpool, payloadString.c_str()); - + startWriteJsonToTag(!doc["spool_id"].isNull(), payloadString.c_str()); request->send(200, "application/json", "{\"status\": \"writing\"}"); }); - // Route für WiFi - server.on("/wifi", HTTP_GET, [](AsyncWebServerRequest *request){ - AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/wifi.html.gz", "text/html"); - response->addHeader("Content-Encoding", "gzip"); - response->addHeader("Cache-Control", CACHE_CONTROL); - request->send(response); + server.on("/api/version", HTTP_GET, [](AsyncWebServerRequest *request){ + request->send(200, "application/json", "{\"version\": \"" VERSION "\"}"); }); server.on("/reboot", HTTP_GET, [](AsyncWebServerRequest *request){ + request->send(200, "text/plain", "Rebooting..."); + delay(500); ESP.restart(); }); - server.on("/style.css", HTTP_GET, [](AsyncWebServerRequest *request){ - AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/style.css.gz", "text/css"); - response->addHeader("Content-Encoding", "gzip"); - response->addHeader("Cache-Control", CACHE_CONTROL); - request->send(response); - }); - - server.on("/logo.png", HTTP_GET, [](AsyncWebServerRequest *request){ - AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/logo.png.gz", "image/png"); - response->addHeader("Content-Encoding", "gzip"); - response->addHeader("Cache-Control", CACHE_CONTROL); - request->send(response); - }); - - server.on("/favicon.ico", HTTP_GET, [](AsyncWebServerRequest *request){ - AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/favicon.ico", "image/x-icon"); - response->addHeader("Cache-Control", CACHE_CONTROL); - request->send(response); - }); - - server.on("/rfid.js", HTTP_GET, [](AsyncWebServerRequest *request){ - AsyncWebServerResponse *response = request->beginResponse(LittleFS,"/rfid.js.gz", "text/javascript"); - response->addHeader("Content-Encoding", "gzip"); - response->addHeader("Cache-Control", CACHE_CONTROL); - request->send(response); - }); - - server.on("/upgrade", HTTP_GET, [](AsyncWebServerRequest *request) { - AsyncWebServerResponse *response = request->beginResponse(LittleFS, "/upgrade.html.gz", "text/html"); - response->addHeader("Content-Encoding", "gzip"); - response->addHeader("Cache-Control", "no-store"); - request->send(response); - }); - handleUpdate(server); - server.on("/api/version", HTTP_GET, [](AsyncWebServerRequest *request){ - String fm_version = VERSION; - String jsonResponse = "{\"version\": \""+ fm_version +"\"}"; - request->send(200, "application/json", jsonResponse); - }); - server.onNotFound([](AsyncWebServerRequest *request){ - request->send(404, "text/plain", "Seite nicht gefunden"); + request->send(404, "text/plain", "Not found"); }); - ws.onEvent(onWsEvent); - server.addHandler(&ws); - ws.enable(true); - server.begin(); Serial.println("Webserver gestartet"); }