35 lines
1.5 KiB
Python
35 lines
1.5 KiB
Python
import sys
|
|
|
|
with open('esp32_serial_backend/esp32_serial_backend.ino', 'r', encoding='utf8') as f:
|
|
content = f.read()
|
|
|
|
replacements = [
|
|
# API setup
|
|
('showStatus("API FAIL", TFT_RED, testResp);', 'showStatus("SERVER DISABLE/RTO", TFT_RED, "");'),
|
|
|
|
# WiFi setup
|
|
('showStatus("WiFi FAIL", TFT_RED, "Timeout 15s");', 'showStatus("WIFI FAIL", TFT_RED, "Timeout 15s");'),
|
|
|
|
# JOB RESULT
|
|
('showStatus("JOB RESULT FAIL", TFT_YELLOW, jr);', 'showStatus("SERVER DISABLE/RTO", TFT_RED, "");'),
|
|
('showStatus("JOB RES FAIL", TFT_YELLOW, jr);', 'showStatus("SERVER DISABLE/RTO", TFT_RED, "");'),
|
|
|
|
# RFID Lookup
|
|
('showStatus("RFID GAGAL", TFT_RED, lookResp);', 'if (lookResp.startsWith("HTTP") || lookResp.startsWith("WIFI")) showStatus("SERVER DISABLE/RTO", TFT_RED, ""); else showStatus("RFID GAGAL", TFT_RED, lookResp);'),
|
|
|
|
# RECOG FAIL
|
|
('showStatus("GAGAL DETEKSI", TFT_RED, resp);', 'if (resp.startsWith("HTTP") || resp.startsWith("WIFI")) showStatus("SERVER DISABLE/RTO", TFT_RED, ""); else showStatus("GAGAL DETEKSI", TFT_RED, resp);'),
|
|
|
|
# Overlay in pollAndRunJob
|
|
('showOverlay(String("Err: ") + resp, TFT_RED);', 'showOverlay("SERVER DISABLE/RTO", TFT_RED);'),
|
|
('showOverlay("server disabled", TFT_RED);', 'showOverlay("SERVER DISABLE/RTO", TFT_RED);')
|
|
]
|
|
|
|
for old, new in replacements:
|
|
content = content.replace(old, new)
|
|
|
|
with open('esp32_serial_backend/esp32_serial_backend.ino', 'w', encoding='utf8') as f:
|
|
f.write(content)
|
|
|
|
print("Fix applied.")
|